text:
# Sandbox Framework

This is a sandbox framework built around quickly building demos, prototypes, or web applications using [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for deployment with [GitHub actions](https://github.com/features/actions) to [GitHub Pages](https://pages.github.com/).

## Requirements

- [Nodejs >= 12.10.0](https://nodejs.org/en/)
- [GitHub Actions](https://github.com/features/actions)

## New Project Setup

1. Download the [latest release](https://github.com/codewithkyle/sandbox-framework/releases)
2. Install NPM packages

```sh
# Install NPM packages
npm i
```

3. Open the `.env` file and fill in the information for your project

## Usage

```sh
# Compile the source code
npm run compile

# Compile the source code and start an HTTP server
npm run build

# Start an HTTP server
npm run preview

# Deploy to gh-pages
npm run deploy
```

### Deploying to GitHub Pages

This project is set up to deploy to the gh-pages won push to the master branch. When deploying to gh-pages the project will need a secret named `ACCESS_TOKEN`. To generate a access token add a new [personal access token](https://github.com/settings/tokens) to your GitHub account with the "full control of private repositories" scope selected.

### Custom Domain

To set a custom domain for the project add a `CNAME` file to the projects root directory, the file will be bundled into the gh-pages deployment.

### Registering Files

Files are registered via script elements on the pages `.html` file. Use the following scripts to register your files.

```html
<!-- Web Components -->
<script defer>components = [...components, 'my-custom-component'];</script>

<!-- State Mangers -->
<script defer>modules = [...modules, 'state-manager'];</script>

<!-- Stylesheets -->
<script defer>stylesheets = [...stylesheets, 'my-custom-stylesheet'];</script>
```

### Building Pages

All HTML files that are created within the `src/` directory will be injected into the `shell.html` file and placed in the `build/` directory when compiled. The directory structures created within the `src/` directory will be recreated in the `build/` directory when compiling the `.html` files. The `.html` file **SHOULD NOT** be valid HTML documents since they will be injected into the `shell.html` file when compiled.

**Example**

I want a `/app` route for my project. In the `src/` directory I would create a `app/` directory and place an `index.html` file within it. Then, after running the `npm run build` command, my new `/app` route will be available when previewing the site.

### State Managers

When creating a global state manager it's recommended that you place the source code in the `web_modules/` directory. At then end of a state managers file the manager should instantiate itself onto the `window` object. State managers are loaded before web components and when mounted onto the `window` can be called by all components whenever required.

**Example**

```javascript
class StateManager
{
    constructor()
    {
        console.log('Hello world!');
    }
}

window.stateManager = new StateManager();
```

### Web Components

Web components can exist anywhere within the `src/` directory. It's recommended that global components exist directly within the `src/` directory while all the other components are placed relative to the pages that they'll be used on.

**Example**

I want to create a global outline input component. I'll start by creating a `outline-input-component/` directory in the `src/` directory. Then I'll create a `outline-input-component.ts` file, a `outline-input-component.scss`, and a `outline-input-component.example` file within the `outline-input-component/` directory. *Note:* the `.example` file will not be used, it just exist as an example of how the web components HTML should be structured. Below is an example of how to define web components, you can read more about web components [here](https://developer.mozilla.org/en-US/docs/Web/Web_Components).

```javascript
class OutlineInputComponent extends HTMLElement
{
    connectedCallback()
    {
        this.addEventListener('click', () => { console.log('Outline Input Component was clicked'); });
    }
}

customElements.define('outline-input-component', OutlineInputComponent);
```

repository: codewithkyle/sandbox-framework

repo_name: codewithkyle/sandbox-framework


text:
# Webex Activity Component

Webex activity component displays the activity content.

## Preview

To see all the different possible states of the Webex Activity component, you can run our Storybook:

```shell
  npm start
```

## Embed

1. Create a component adapters object from which the data will be retrieved (See [adapters](../../adapters)). For instance:

   ```js
   const jsonAdapters = {
     peopleJSONAdapter: new PeopleJSONAdapter(people),
     activitiesJSONAdapter: new ActivitiesJSONAdapter(activities),
   };
   ```

2. Create a component instance by passing the activity ID as a string and the component data adapters which contains [PeopleAdapter](../../adapters/PeopleAdapter.js) and [ActivitiesAdapter](../../adapters/ActivitiesAdapter.js) that we created previously

   ```js
   <WebexActivities activityID="activityID" adapters={jsonAdapters} />
   ```

The component knows how to manage its data. If anything changes in the data source that the adapter manages, the component will also update on its own.

license: MIT

repository: eazy-g/components

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: eazy-g/components


text:
# parallelized-apriori-data-mining
OpenMP based multicore implementation of APriori Algorithm

## Getting Started
  * Install OpenMP(MacOS)
  ```console
      brew install omp
      xcode-select --install
  ```
## Running the Project
  ```console
      gcc -fopenmp aprioriomp.cpp
  ```
## PseudoCode
* Pass 1
    *  Generate the candidate itemsets in C1
    *  Save the frequent itemsets in L1
* Pass k
  *  Generate the candidate itemsets in Ck from the frequent itemsets in Lk-1
      * Join Lk-1 p with Lk-1 q, as follows:
          * insert into Ck
          * select p.item1, p.item2, . . . , p.itemk-1, q.itemk-1 from Lk-1 p, Lk-1 q
             where p.item1 = q.item1, . . . p.itemk-2 = q.itemk-2, p.itemk-1 < q.itemk-1
      * Generate all (k-1) - subsets from the candidate itemsets in Ck
      * Prune all candidate itemsets from Ck where some (k-1) - subset of the candidate itemset is not in the frequent itemset Lk-1
  *  Distribute among p threads
   * Scan the transaction database to determine the support for each candidate itemset in Ck
  *  Save the frequent itemsets in Lk

<img src = "https://i.imgur.com/mmjLxJz.jpg">


text:
---
name: Elastic.io
description: Microservices-based hybrid integration platform for real-time data sync
  across disparate cloud-based and on-premise applications, platforms and databases.
image: http://api.specificationtoolbox.com/images/service-providers/elastic-io.jpg
created: "2020-12-23"
modified: 2020-12-24PST10:05:00-28800
specificationVersion: "0.14"
x-rank: "7"
x-alexaRank: "610835"
url: http://api.specificationtoolbox.com/resources/service-providers/elastic-io/
tags:
- Platform As A Service Providers
- IPaaS
- Interoperability
- Integrations
- Automation
apis: []
x-common:
- type: x-website
  url: http://elastic.io
- type: x-blog
  url: https://www.elastic.io/blog/
- type: x-blog
  url: http://www.elastic.io/blog
- type: x-case-studies
  url: https://www.elastic.io/resources/#casestudies
- type: x-connectors
  url: https://www.elastic.io/connectors/
- type: x-connectors
  url: https://www.elastic.io/connectors/rest-api/
- type: x-connectors
  url: https://www.elastic.io/connectors/soap/
- type: x-connectors
  url: https://www.elastic.io/connectors/odata/
- type: x-connectors
  url: https://www.elastic.io/connectors-tags/database/
- type: x-contact
  url: https://www.elastic.io/contact/
- type: x-crunchbase
  url: http://www.crunchbase.com/company/elastic-io
- type: x-crunchbase
  url: https://crunchbase.com/organization/elastic-io
- type: x-customers
  url: https://www.elastic.io/customers/
- type: x-documentation
  url: https://docs.elastic.io/getting-started/
- type: x-documentation
  url: https://docs.elastic.io/
- type: x-documentation
  url: https://docs.elastic.io/releases/
- type: x-documentation
  url: https://api.elastic.io/docs/v2/
- type: x-documentation
  url: https://docs.elastic.io/guides/mapping-data.html
- type: x-documentation
  url: http://docs.elastic.io/integrator-guide/recipient-list.html
- type: x-documentation
  url: http://docs.elastic.io/integrator-guide/content-based-router.html
- type: x-documentation
  url: https://docs.elastic.io/getting-started/first-flow.html
- type: x-documentation
  url: https://docs.elastic.io/references/
- type: x-documentation
  url: https://api.elastic.io/docs/
- type: x-documentation
  url: https://docs.elastic.io/references/sdk.html
- type: x-email
  url<EMAIL_ADDRESS>- type: x-email
  url<EMAIL_ADDRESS>- type: x-events
  url: https://www.elastic.io/resources/#events
- type: x-facebook
  url: https://www.facebook.com/ElasticIO
- type: x-github
  url: https://github.com/elasticio
- type: x-linkedin
  url: https://www.linkedin.com/company/elastic-io-gmbh
- type: x-login
  url: https://app.elastic.io/login
- type: x-partner
  url: https://www.elastic.io/integration-partner-program/
- type: x-plans
  url: https://www.elastic.io/plans/
- type: x-platform
  url: https://www.elastic.io/api-integration-platform/
- type: x-press
  url: https://www.elastic.io/pressroom/
- type: x-privacy
  url: https://www.elastic.io/privacy-policy/
- type: x-status
  url: https://status.elastic.io/
- type: x-support
  url: https://support.elastic.io/support/solutions/articles/14000069448-jsonata-powered-mapper
- type: x-support
  url: https://support.elastic.io/support/solutions/articles/14000064151-what-is-passthrough
- type: x-webinars
  url: https://www.elastic.io/resources/#webinar
- type: x-website
  url: https://www.elastic.io
- type: x-website
  url: http://www.elastic.io/
- type: x-white-papers
  url: https://www.elastic.io/resources/#whitepapers
- type: x-youtube
  url: https://www.youtube.com/channel/UCEwQ5hBig2Jp3vThIpS0EZg
include: []
maintainers:
- FN: Kin Lane
  x-twitter: apievangelist
  email<EMAIL_ADDRESS>...

repository: akpsgit/toolbox

branch_name: refs/heads/main

repo_name: akpsgit/toolbox


text:
---
title: Sprint 2 - Troposphere
parent: Progress and Results
nav_order: 2
---
# Sprint 2 - Troposphere
In our second sprint we continued to focus on improvements to [OpenShift Launchpad](https://github.com/bcgov/openshift-launchpad) in order to reach a stable point for a [public PR](https://github.com/bcgov/openshift-launchpad/pull/30) where we invite community feedback. This has been shared widely within the BC Exchange Lab and is publicly accessible for anyone to review and comment.

We also received our first contributions toward OpenShift Launchpad from the [Common Services Showcase Team](https://bcgov.github.io/common-service-showcase/) - a big shoutout for contributing a [Vue frontend](https://github.com/bcgov/openshift-launchpad-fe-vue) option and a [Node backend](https://github.com/bcgov/openshift-launchpad-be-node) option! In future sprints these will be integrated as easily-selected technology choices.

Additionally, we began work on a proof of concept to explore deployment to OpenShift using [GitHub Actions](https://github.com/features/actions). In this sprint we achieved PR-based deployments of Launchpad to OpenShift, which you can [see a demo of in this video](https://drive.google.com/open?id=1TS0Dsl4BEyKGJOg_B-dLKh-hKWl6vl3c).

Continuing our user research, we interviewed an additional two teams with connections to the BC Exchange Lab: one of the Registries teams and Mines Digital Services. From our user interviews to date we have identified four stages that teams progress through as they build a product:
1. Inception
1. Proof of Concept
1. Minimum Viable Product
1. Active Product Development

Finally, we successfully set up a public wiki space where our progress and results can be shared with anyone: the site you're reading this on right now!

## Sprint Goals
- Get [OpenShift Launchpad](https://github.com/bcgov/openshift-launchpad) polished enough to be something others can consume
- Distill our discovery findings into something shareable and actionable

## Sprint Review
Our sprint review slides are [shared here as a PDF](https://bcgov.github.io/common-components-wiki/media/sprint_slides/CoCo_Sprint_2-Troposphere.pdf) and include additional details on:
- The stages a team goes through during development
- How teams evaluate components as possible solutions

We host an open sprint review every two weeks that is available in the BC Exchange Lab events calendar. Please contact us if you would like an invitation!

## Next Sprint
In our next sprint we are reviewing our backlog and community feedback to determine what's **Still Relevant**. We will be focused on moving our user research forward while incorporating what we've learned so far into our products and the way we work.

repository: bcgov/common-components-wiki

gha_language: Ruby

repo_name: bcgov/common-components-wiki


text:
# Kylindria GENUS

#### Status
ACCEPTED

#### According to
Index Fungorum

#### Published in
Mycologia 75(6): 970 (1983)

#### Original name
Kylindria

### Remarks
null

repository: mdoering/backbone

repo_name: mdoering/backbone


text:
---
layout: post
status: publish
published: publish
title: Leaves on your desktop
author:
  display_name: Misterblue
  login: Misterblue
  email<EMAIL_ADDRESS>  url: http://misterblue.com
author_login: Misterblue
author_email<EMAIL_ADDRESS>author_url: http://misterblue.com

wordpress_id: 347
wordpress_url: /?p=347
date: 2003-10-25 09:19:25
categories:
- Blog

---

With autumn leaves falling outside, you should have leaves on your desktop.  One of the coolest programs around is
AutumnLeaves
which causes leaves to tumble down and collected on  the tops of your windows.
The occasional falling nut and growing mushroom adds to the
wet and cool feeling of a chilly autumn morning.
It's shareware and worth paying for.

And, to add to the autumn effect, use one of
these images (
2048x1536
,
1600x1200
,
1024x768
)
to complete your leafy desktop.

By the way, the AutumnLeaves author also has
Snow for Windows
and
Hanami
(falling cherry blossoms)
so you can enjoy all of the seasons.


text:
# Java Examples

This repository is a collection of Java sample projects.

## Project Overview

### Java Client/Server NTLMv2 Authentication Example

(Directory "__NTLMv2 Authentication__")

This is an example implentation of the NTLMv2 authentication protocol for the client and server side. For the authentication the [ntlmv2-auth](https://sourceforge.net/projects/ntlmv2auth) library is used and a minimal jetty server and a client is provided.

This example is merely an illustration of the NTLMv2 authentication workflow. Therefore things like error handling, content validation or synchronisation of variables are ignored.

## License

__MIT License__

>Copyright 2018 Marcel Kliemannel
>
>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


text:
---
layout: essay
type: essay
title: Setting up Hadoop on laptop VMs
published: false
date: 2018-04-26
labels:
  - Hadoop
  - VM
---
__Disclaimer__: This essay is my updated version of a tutorial called "building a virtualized 5-node HDP 2.0 cluster (all within a mac)" by Lester Martin which you can find (here)[https://martin.atlassian.net/wiki/spaces/lestermartin/blog/2014/01/19/34832444/building+a+virtualized+5-node+HDP+2.0+cluster+all+within+a+mac#buildingavirtualized5-nodeHDP2.0cluster(allwithinamac)-RemainingNodes]. In attempting to follow it, there were several things that were either not explained fully enough for me to understand (having work little with VM manager at that point) or were no longer correct (as VirtualBox and/or Hadoop had been updated).


text:
---
layout: post
title: Ancilla hardware migration
---

I recently migrated the family server, `ancilla`, to new hardware and new disks. This post is primarily a record of that process. Hopefully it will be helpful to someone; I suspect it will, at least, be useful to Future Me when planning the next migration.

It has also been edited somewhat to remove false starts and dead ends, along with several hours of swearing and swapping drives around necessitated by one of my USB drive enclosures failing halfway through a resilver.

To reduce ambiguity, I'm going to name every machine and disk discussed here. The old server is `ancilla-old`, and the new one is `ancilla-new`; disks in the old one all have names starting with `dO`, and in the new one, with `dN`.

To set the stage, the original server (`ancilla-old`) has an external four-disk raidz5 holding most of the system; one internal SSD with `/boot` and `/nix` on it, as well as serving as the ZIL (journal) and L2ARC (cache) for the raidz5 and as swap; and an external two-disk mirror used for storing local backups and as scratch space. In detail:

    zpool ancilla
      raidz5 dObig1 dObig2 dObig3 dObig4
      filesystems / /home /etc ...
      zil dOssd-part2
      l2arc dOssd-part5
    zpool internal
      disk dOssd-part4
      filesystems /boot /nix
    zpool backup
      mirror dOsmall1 dOsmall2
    swap dOssd-part3

`ancilla-new` doesn't have any data on it yet, just a bunch of internal disks:

    m.2: dNssd
    sata: dNbig1 dNbig2 dNbig3 dNbig4

The goal here is to move everything on `ancilla` and `internal` onto the internal disks in the new ancilla, and move `backup` onto the `dObig*` disks, with a minimum of downtime -- no sitting there for ages booted off a liveUSB while `dd` runs, for example. At the same time, I want to switch from MBR booting to UEFI.

So. Step one, shut down `ancilla-old` and physically move all the disks over. The external enclosures are disconnected from the old and connected to the new, and the internal SSD is removed and attached to the new system via a single-disk dock. So `ancilla-new` now looks like this:

    m.2: dNssd
    sata: dNbig1 dNbig2 dNbig3 dNbig4
    usb: dObig1 dObig2 dObig3 dObig4
    usb: dOsmall1 dOsmall2
    usb: dOssd

Now we fire it up and boot (in MBR mode) from `dOssd`...and up it comes! The `postBootCommands` discussed in the [previous post](http://toxicfrog.github.io/automounting-zfs-on-nixos/) ensure that all the zpools are correctly imported even though the devices have moved around.

My first priority now is to remove the dependency on the old SSD and switch to UEFI booting.

    $ parted dNssd
        [create some partitions:]
        part1 /boot, 1GB
        part2 ZIL, 1GB
        part3 swap, 16GB
        part4 /nix, 64GB
        part5 L2ARC, everything else
    $ zpool add ancilla log dNssd-part2
    $ zpool add ancilla cache dNssd-part5

The old ZIL and L2ARC can be removed immediately:

    $ zpool remove ancilla dOssd-part2
    $ zpool remove ancilla dOssd-part5

Similarly, swap doesn't require any transition period, we just turn on the new and turn off the old:

    $ mkswap -L m2-swap dNssd-part3
    $ swapon dNssd-part3
    $ swapoff dOssd-part3
    $ nano /etc/nixos/hardware-configuration.nix

    {
      swapDevices = [ { device = "/dev/disk/by-label/m2-swap"; } ];
    }

And the zpool itself is almost as easy to deal with. We just add the new disk as a mirror of the old, wait for the resilver, and then remove the old disk. The final `zpool online -e` command tells it to expand the pool to fill the entire device.

    $ zpool attach internal dOssd-part4 dNssd-part4
    ...wait a bunch...
    $ zpool detach internal dOssd-part4
    $ zpool online -e internal dNssd-part4

The only part that requires more care here is `/boot`, since we're switching from MBR boot with `/boot` on ZFS to UEFI boot with `/boot` (of necessity) on FAT32.

    $ mkfs.fat -F 32 -n BOOT dNssd-part1
    $ nano /etc/nixos/...

    {
      fileSystems."/boot" = {
        device = "/dev/disk/by-label/BOOT"; fsType = "vfat";
      };
      boot.loader.grub = {
        enable = true;
        efiSupport = true;
        efiInstallAsRemovable = true;
        version = 2;
        device = "nodev";
      };
    }

Of particular note here are `efiInstallAsRemovable = true`, which tells GRUB to install itself at `esp:/EFI/BOOT/BOOTX64.EFI`, guaranteeing that the system will find it at boot even if there are issues updating the EFI boot variables, and `device = "nodev"`, which tells GRUB not to even attempt installing an MBR-compatible stage1 bootloader.

Now we just mount the new `/boot` and update it:

    $ zfs set mountpoint=none internal/boot
    $ mount /dev/disk/by-label/BOOT /boot
    $ nixos-rebuild boot

If all has gone well, `/boot/EFI`, `/boot/grub`, and `/boot/kernels` should have been created and now contain the new (UEFI-compatible) boot configuration.

And with that the last dependency on the old SSD is gone, so we can go ahead and unplug it.

The rest is very straightforward. First of all, we move the `ancilla` zpool to the internal disks. At first I thought I could create mirrors from each one, then detach the old disks, similar to how `internal` was handled; unfortunately, ZFS requires that raidz vdev be composed of individual block devices -- you can't have a raidz-of-mirrors. Fortunately, it has the `replace` command for this use case:

    $ zpool replace ancilla dObig1 dNbig1
    $ zpool status ancilla
      ...
      raidz1-0
        replacing-0
          dObig1     ONLINE
          dNbig1     ONLINE (resilvering)
        dObig2       ONLINE
        dObig3       ONLINE
        dObig4       ONLINE

Once `dNbig1` is fully resilvered into the array, it automatically detaches `dObig1` and we replace the process with the other three drives. (We could do all four drives at once, but that will be slower overall than doing them one at a time; as more of the drives are moved onto the faster individual SATA connections, the performance of each subsequent resilver increases dramatically.)

Now the `dObig*` disks are unused, and we can move the `backup` pool onto them using the same mechanism as `internal` (since it's already a mirror):

    $ zpool attach backup dOsmall1 dObig1
    ...wait for resilver...
    $ zpool attach backup dOsmall1 dObig2
    ...wait for resilver...
    $ zpool detach backup dOsmall1
    $ zpool detach backup dOsmall2
    $ zpool online -e backup dObig1

And there we go! One reboot, a few minutes of downtime, a few days of resilvering, and all the data is warm and snug in its new home. And I have four extra drives (`dObig3-4` and `dOsmall1-2`) I need to figure out what to do with.


text:
# Garoevans Php Enum [![Build Status](https://travis-ci.org/garoevans/php-enum.png)](https://travis-ci.org/garoevans/php-enum)

This gives us a convenient way to always have an Enum object available and
utilise Spl Types if available. It does kick up a bit of a fuss in some IDEs
as it sees two classes with the same name, but we know this isn't an issue as
the code is fine and dandy :)

We also wrap the SplEnum class to stop IDEs thinking that the constructor
parameters are necessary. Force it to act like the documentation says it should.

The replacement is so closely tied to the expected usage of the Spl Enum that
you could just use the http://php.net/manual/en/class.splenum.php documentation;

```php
use Garoevans\PhpEnum\Enum;

class Fruit extends Enum
{
    // If no value is given during object construction this value is used
    const __default = self::APPLE;
    // Our enum values
    const APPLE     = 1;
    const ORANGE    = 2;
}

$myApple  = new Fruit();
$myOrange = new Fruit(Fruit::ORANGE);
$fail     = 1;

function eat(Fruit $aFruit)
{
    if ($aFruit->is(Fruit::APPLE)) {
        echo "Eating an apple.\n";
    } else if ($aFruit->is(Fruit::ORANGE)) {
        echo "Eating an orange.\n";
    }
}

// Eating an apple.
eat($myApple);
// Eating an orange.
eat($myOrange);

// PHP Catchable fatal error:  Argument 1 passed to eat() must be an
// instance of Fruit, integer given
eat($fail);
```

Apart from normalizing the Spl Enum construct there are additions including a
shorthand way of instantiating via a static method named the same as the desired
constant. Using the ```Fruit``` class from above we can do the following;

```php
// Eating an apple.
eat(Fruit::APPLE());
```

Also, the ```constantExists()``` method is available for use;

```php
$fruit = new Fruit();
if ($fruit->constantExists("apple")) {
    echo "Apple is available.\n";
}
```

repository: diegorec/microgest-php

repo_name: diegorec/microgest-php


text:
libgwater
=========

libgwater provides several GSources to integrate various events to the GLib main loop.

Composition of a GSource
------------------------

Each GSource is composed of three parts:

-   An m4 macro for Autoconf: `GW_CHECK_<SOURCE_NAME>`
    It takes two optional arguments:

    1. Additionnal `pkg-config` packages to check
    2. Additionnal headers to check

-   A `Makefile.am` snippet for Automake: `libgwater/<source-name>.mk`

    You have to include it in your `Makefile.am`. It defines two variables:

    - `GW_<SOURCE_NAME>_CFLAGS`: contains all the needed `CFLAGS` (including those from the `pkg-config` packages you passed to the m4 macro)
    - `GW_<SOURCE_NAME>_LIBS`: contains all the needed `LIBS` (including those from the `pkg-config` packages you passed to the m4 macro)

    This snippet is using Automake 1.14 features and Libtool. If you do not use both in your project, you need to adapt and ship it in your project.

-   A really basic API:
    - A `GWater<SourceName>Source` opaque struct
    - One or more `g_water_<source_name>_source_new()` constructor for said struct
    - One free function `g_water_<source_name>_source_free()`
    - Usually a getter, to access the underlaying struct used by the communication library

Non-Autotools setup are not covered upstream but should be easy enough to use.

Example usage of XCB GSource
----------------------------

1. Create your project with Autotools files

2. Add libgwater as a Git submodule
    ```shell
    git submodule add git://github.com/sardemff7/libgwater
    ```

3. Add the m4 macro call to your `configure.ac` (with an additionnal package, `xcb-util`)
    ```m4
    GW_CHECK_XCB([xcb-util])
    ```

4. Make sure aclocal will find the m4 file by adding the directory to `ACLOCAL_AMFLAGS` in your `Makefile.am`
    ```Makefile
    ACLOCAL_AMFLAGS = -I libgwater ${ACLOCAL_FLAGS}
    ```

5. Include the `Makefile.am` snippet
    ```Makefile
    include $(top_srcdir)/libgwater/xcb.mk
    ```

6. Use the `Makefile.am` variables
    ```Makefile
    xcb_example_client_SOURCES = client.c
    xcb_example_client_CFLAGS = $(GW_XCB_CFLAGS)
    xcb_example_client_LDADD = $(GW_XCB_LIBS)
    ```

7. Use the GSource in your `client.c`
    ```c
    #include <glib.h>
    #include <libgwater-xcb.h>

    gboolean
    callback(xcb_generic_event_t *event, gpointer user_data)
    {
        if ( event == NULL )
        {
            /* Error occured */
            return FALSE;
        }
        return TRUE;
    }

    int
    main()
    {
        GWaterXcbSource *source;
        GMainLoop *loop;

        loop = g_main_loop_new(NULL, FALSE);
        source = g_water_xcb_source_new(NULL, NULL, NULL, callback, NULL, NULL);

        g_main_loop_run(loop);
        g_main_loop_unref(loop);

        g_xcb_source_free(source);

        return 0;
    }
    ```

Dependencies
------------

-   Common dependencies
    - GLib 2.36 (or newer)
-   Wayland source
    - libwayland 1.1.91 (or newer)
-   XCB source
    - libxcb
-   MPD source
    - libmpdclient2
-   ALSA Mixer source
    - alsa-lib
-   Netlink protocol source
    - libnl-3.0
-   Windows source
    - `Windows.h`

Licence
-------

libgwater is licenced under the terms of the [MIT license](//opensource.org/licenses/MIT)

Author / Contact
----------------

Quentin “Sardem FF7” Glidic<EMAIL_ADDRESS>— [My other Free Software projects](//www.sardemff7.net/)

gha_language: C


text:
---
layout: post
title: E/OS, android without google
description:
date: '2022-05-01'
tags: android

---

Mobile phone operating systems don't fare well when it comes to giving users freedom over their expensively bought devices but luckily there are still alternatives like [e/os](https://e.foundation/e-os/)

I used [cyanogenmod](https://en.wikipedia.org/wiki/CyanogenMod) a popular custom android rom before it was discontinued many years ago. Since then I used the stock android on my phone as there was no other option.

Until now I managed to limit myself to owning one phone at time but the fear of what would happen if I would lose it given how central to our daily lives phones have become (think of two factor auth, bank account access etc) I decided to get a second backup device.

New, shiny and expensive is not my thing so a second hand samsung phone was just fine, and since I did not spend a ton of money on it I decided do try and swap the os with a more privacy conscious one; that's how I got acquainted to [e/os](https://e.foundation/e-os/)

After using it for more than a half of year I can say i'm pleased with it. While not without its little issues it does offer a way out of the google web and still have an almost 100% functional phone, which is quite remarkable I would say.

## E/foundation and e/os

The company has its roots in europe (France I believe) and offers a google free android experience. They offer the OS, which is a tweaked version of the open source android, they also sell phone with the os preinstalled, and have a cloud based solution as equivalent replacements for common google products; and they are privacy focused.

The os is open source, can be downloaded and installed on the more common android phones (ex the samsung s series). A list of supported devices is [here](https://doc.e.foundation/devices). Prerequisite for installing the os is unlocking a phone which requires a bit of tinkering but the process for every device is well documented.

Eos comes with its own app store [here](https://e.foundation/e-os-available-applications/) as the google app store is gone from the phone. While the more common apps are in there it's definitely a subset of the apps in the google store, but this too can be worked around using other 3rd party app stores. Os updates and security patches are published regularly.

To get more familiar with what it offers in terms of feature and privacy i recommend reading [this](https://doc.e.foundation/what-s-e#degoogling--ungoogling) page , and for the details of what `de-googled` means [this](https://e.foundation/wp-content/uploads/2020/09/e-state-of-degooglisation.pdf) page

## Other noteworthy candidates

While doing my research on the topic I found a bunch of other similar products, here's the list.

- Calyxos [here](https://calyxos.org/)
- Iode [here](https://iode.tech/en/)
- Lineageos [here](https://lineageos.org/)
- Ubuntu touch [here](https://ubuntu-touch.io/)
- Grapheneos [here](https://grapheneos.org/)


text:
PHP-XSS-Filter
==============

Example
```PHP
	require './xss_filter.class.php';
	$xss = new xss_filter();
	$string = '<iframe>blah';
	$string = $xss->filter_it($string );
	echo $string;
```

repository: roadahead/PHP-XSS-Filter

repo_name: roadahead/PHP-XSS-Filter


text:
---
title: Pandemics
keywords:
tags: need_content
sidebar: home_sidebar
permalink: /issues_that_can_occur/pandemics
summary: As we learned in 2020 with the COVID19 shutdowns, the show does not always go on.
---

## COVID19 Event Resources
* [Eventbrite Coronavirus Resources for Event Organizers](https://www.eventbrite.com/l/coronavirus-resources-event-organizers/)

## Moving from in-person to virtual Events
Many events were forced to go virtual in 2020, and there are lessons to be learned from those Events. See the [Going Virtual](/going_virtual/virtual_overview) page for more information.

repository: sabomade/maker-event-playbook

repo_name: sabomade/maker-event-playbook


text:
# Aeternum Map - Interactive map for New World

Get all the locations, farming spots, resources, lore documents, chests, mobs and more!

## Features

- Live Tracking of your In-Game position
- Check markers as done (like lore documents)
- Automatic detection of your In-Game character
- Auto start with New World
- Private and guild markers (Coming Soon)
- Areas (Coming Soon)
- Near by (Coming Soon)
- Dungeons (Coming Soon)

## Contribution

This app is Open Source. Contributors are highly welcome!

Join us on our [Discord](https://discord.com/invite/NTZu8Px).

## Development

Please follow the instructions on [Overwolf Developer](http://developers.overwolf.com/documentation/odk-2-0-introduction/creating-your-first-app/) to get white listed in Overwolf. Then you can start developing!
In addition, you need access to a [MongoDB](https://docs.mongodb.com/manual/).

### Set environment variables

You can start by copying the template environment variables file.

```
cp template.env .env
```

The following list shows the variables you need to set:

| KEY               | VALUE                                                           |
| ----------------- | --------------------------------------------------------------- |
| PORT              | Port for the server environment                                 |
| MONGODB_URI       | URI of your MongoDB server                                      |
| VITE_API_ENDPOINT | URL of your server environment                                  |
| SCREENSHOTS_PATH  | Server side path to a folder in which screenshots will be saved |

### Install dependencies

This project is based on [Node.js](https://nodejs.org/). Make sure you have Node.js installed before installing the dependencies with:

```
npm install
```

You need to install [Overwolf](https://download.overwolf.com/install/Download) too.

### Build project

You can build a production version of the server and client with:

```
npm run build
```

It is required to call this at least once before you can run this app in development mode.

### Install as "unpacked extension"

Based on this [guide](https://overwolf.github.io/docs/start/sample-app-overview#5-install-the-app-as-unpacked-extension) you can install the app.

- Open the Overwolf desktop client settings (by right-clicking the client and selecting "Packages"
  Or by clicking on the wrench icon in the dock and going to the "About" tab => "Development Options").

- Click on "Development options".

- In the opened window, click on "Load unpacked extension" and select the extracted 'ts/dist' folder.
  This will add the app to your Overwolf dock.

- Make sure you are logged in to the OW client. Otherwise, you will get an "Unauthorized App" error message. (Click on the "Appstore" icon in the OW dock to login to the OW client).

### Run development

```
npm run dev
```

This will run the server and client in development mode.

### Start the app

Click on the app's icon in your OW dock to run the app. This will open the app if you run `npm run dev` before.

## Licensing

MIT

repository: benjaminaudet/aeternum-map

repo_name: benjaminaudet/aeternum-map


text:
Simple Twitter Client
=====================
A simple implementation of twitter python client.

Installation Requirements
-------------------------
- Firstly get your own API keys from [twitter's dev page](https://dev.twitter.com/user/login).
- Install [Python Twitter](https://github.com/bear/python-twitter), A Python wrapper around the Twitter API.

		$ pip install python-twitter

- Start coding.

Useful Links
------------
- [http://grahamnic.wordpress.com/2013/09/15/python-using-the-twitter-api-to-datamine/](http://grahamnic.wordpress.com/2013/09/15/python-using-the-twitter-api-to-datamine/) **the source comes from this link**

Development Log
---------------
*Wed Jul 30 11:10:19 WIB 2014*
- Initiated the project.
- Got a copy of python twitter sample code.
- Cloning the user interface.

License
-------
The MIT License (MIT)

Copyright (c) 2014 Guntur D Putra

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

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

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

repository: gtrdp/simple-twitter-client

repo_name: gtrdp/simple-twitter-client


text:
---
layout: page
title: About
permalink: /about/
---

Welcome to Artifishell! I decided to create Arifishell in order to share my thoughts and opinions as well as post information about technologies that I find interesting. My goal is simple: present complex - or hard-to-understand - topics in a simple and intuitive way. It is my hope that people will be motivated to learn more about and research the topics and ideas on this website.

Artifishell's centered around:

- Machine/Deep Learning
- Artificial Intelligence
- Algorithms
- Data Structures
- Tech & more!

There may also be personal posts sprinkled throughout the site.

Please feel free to let me know about any interesting topics, ideas or projects that you'd like to see a post or article about.

## Content Creator

Hello, my name is Nicholas Guan. I'm a computer science major and a former intern at Facebook and IBM, with 7+ years of programming experience and currently pursing a specialization in machine learning. If you'd like to contact me, feel free to do so by messaging me on any of the platforms below :)

gha_language: CSS

gha_license_id: NOASSERTION


text:
### [CVE-2014-1498](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1498)
![](https://img.shields.io/static/v1?label=Product&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Version&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Vulnerability&message=n%2Fa&color=brighgreen)

### Description

The crypto.generateCRMFRequest method in Mozilla Firefox before 28.0 and SeaMonkey before 2.25 does not properly validate a certain key type, which allows remote attackers to cause a denial of service (application crash) via vectors that trigger generation of a key that supports the Elliptic Curve ec-dual-use algorithm.

### POC

#### Reference
- http://www.oracle.com/technetwork/topics/security/bulletinapr2016-2952098.html

#### Github
No PoCs found on GitHub currently.

repository: trickest/cve

gha_language: HTML

gha_license_id: MIT

repo_name: trickest/cve


text:
---
layout: post
title: OpenAI Gym Envs:Fetch
---

First we look at the structure of OpenAI Gym Envs code (shown below). [github code](https://github.com/openai/gym/blob/master/gym/envs/robotics/fetch_env.py)

![_config.yml]({{ site.baseurl }}/images/openaigym-envs.png)

The goal based environment is inherited from Env class.

**Goal based environment**

It functions just as any regular OpenAI Gym environment but it imposes a required structure on the observation_space. More concretely, the observation space is required to contain at least three elements, namely `observation`, `desired_goal`, and
`achieved_goal`. Here, `desired_goal` specifies the goal that the agent should attempt to achieve. `achieved_goal` is the goal that it currently achieved instead. `observation` contains the actual observations of the environment as per usual.

RobotEnv is inherited from Goal based environment.

**RobotEnv**

`Action space`: spaces.Box ranges in [-1, 1] with shape of `n_actions`

`Desired goal`: spaces.Box ranges in (-∞, ∞) with shape of `desired_goal` [[Error in source code?]](https://github.com/openai/gym/blob/master/gym/envs/robotics/robot_env.py)

`Achieved goal`: spaces.Box ranges in (-∞, ∞) with shape of `achieved_goal`

`Observation`: spaces.Box ranges in (-∞, ∞) with shape of `observation`

FetchEnv is inherited from RobotEnv.

**FetchEnv**

`n_actions` is 4.
The ```compute_reward()``` function computes distance between goal and the achieved goal. If the reward type is sparse, it returns -1 if not achieved and 0 is achieved.

repository: Psyche-mia/Psyche-mia-personal-blog

repo_name: Psyche-mia/Psyche-mia-personal-blog


text:
#  2048 Game (SwiftUI app)

This is a simple game to demonstrate the new SwiftUI framework.

> Note that the game algorithm may have issues, and this is still WIP.

![Screenshot](Screenshot.png)

## Supported Platforms

* iOS 13.0+
* macOS 10.15+
* macOS 11+ (macCatalyst version)

## License

MIT


text:
Checks an object for an empty value and returns a pre-set default value.

## Script Data
---

| **Name** | **Description** |
| --- | --- |
| Script Type | python3 |
| Tags | transformer, general, entirelist |
| Cortex XSOAR Version | 5.0.0 |

## Inputs
---

| **Argument Name** | **Description** |
| --- | --- |
| value | The object value to check, if empty. |
| defaultValue | The new value to return if the original value was empty. |
| applyIfEmpty | If set to true, empty strings, arrays and dictionaries and the strings "None" and "Null" are considered empty entities and the default value is returned. |

## Outputs
---
There are no outputs for this script.

repository: demisto/content

gha_language: Python

repo_name: demisto/content


text:
# Evernym Verity Interoperability

## Runsets with Verity

| Runset | ACME
(Issuer) | Bob
(Holder) | Faber
(Verifier) | Mallory
(Holder) | Scope | Results |
| ------ | :--------------: | :-------------: | :----------------: | :-----------------: | ----- | :-----: |
| [acapy-verity](#runset-acapy-verity) | verity
1.0 | acapy-main
1.0.0-rc1 | acapy-main
1.0.0-rc1 | acapy-main
1.0.0-rc1 | AIP 1.0 | [**0 / 2
0%**](https://allure.vonx.io/api/allure-docker-service/projects/acapy-b-verity/reports/latest/index.html?redirect=false#behaviors) |

## Runset Notes

### Runset **acapy-verity**

Runset Name: ACA-PY to Verity

```tip
**Latest results: 0 out of 2 (0%)**

*Last run: Fri Dec  2 01:39:56 UTC 2022*
```

#### Current Runset Status

All the Connection tests are running. All tests are passing

*Status Note Updated: 2021.09.13*

#### Runset Details

- [Results by executed Aries RFCs](https://allure.vonx.io/api/allure-docker-service/projects/acapy-b-verity/reports/latest/index.html?redirect=false#behaviors)
- [Test execution history](https://allure.vonx.io/allure-docker-service-ui/projects/acapy-b-verity/reports/latest)

Jump back to the [interoperability summary](./README.md).

repository: ianco/aries-agent-test-harness

repo_name: ianco/aries-agent-test-harness


text:
## Last Week's Accomplishments

> I have implemented a bare bones version of the parsing algorithms. While the production version of the website in still in progress, I made
> a small website with Flask to house the algorithms. Also, while the calendar view is still in progress, I have integrated a Google
> Calendar into the website. Very much in the prototype phase still but a big jump in progress to say the least. Here are the links to where
> you can find work related to the project:
> - Syllaview website repo: https://github.com/AlbMej/Syllaview
> - Information Extraction Algorithms: https://github.com/AlbMej/Natural-Language-Processing/tree/master/Syllabus%20Event%20Extraction%20for%20Google%20Calendar

## Future Plan

> Sorry for submitting this last status update late, I have been terribly busy. Essentially, the only future plans now is to continue working on the parsing algorithms, which I have dubbed DEEFCI. I also have to decide on the future of this project itself. With my team members gone, I question if I have enough time to continue working on this project in the Fall. If I do, I can have the rest of the website built. Until
then, here are the missing stories my team and I could not finish this semester:

> - Continue brainstorming a page for profiles and more features for the website.
> - Consider feature that when a user uploads a new syllabus, they are given the option to add to an existing calender or a new one.
> - Come up with a copy for the website. Currently most of the pages is filled with lorem ipsum.

> I now just need to check in with my team mates to talk about things they done and wanted to complete for the project. I could have someone
> pick up on their work in the future. It was a good semester and I had fun taking this project somewhere!

## Anything Blocking?

> The semester ending. T.T

## Notes

> Last Status update!

repository: AlbMej/rcos-status-updates

repo_name: AlbMej/rcos-status-updates


text:
[![Build Status](https://travis-ci.org/titsuki/p6-Algorithm-TernarySearchTree.svg?branch=master)](https://travis-ci.org/titsuki/p6-Algorithm-TernarySearchTree)

NAME
====

Algorithm::TernarySearchTree - the algorithm which blends trie and binary search tree

SYNOPSIS
========

    use Algorithm::TernarySearchTree;

    my $tst = Algorithm::TernarySearchTree.new();

    $tst.insert("Perl6 is fun");
    $tst.insert("Perl5 is fun");

    my $false-flag = $tst.contains("Kotlin is fun"); # False
    my $true-flag = $tst.contains("Perl6 is fun"); # True

    my $matched = $tst.partial-match("Perl. is fun"); # set("Perl5 is fun","Perl6 is fun")
    my $not-matched = $tst.partial-match("...lin is fun"); # set()

DESCRIPTION
===========

Algorithm::TernarySearchTree is a implementation of the ternary search tree. Ternary search tree is the algorithm which blends trie and binary search tree.

CONSTRUCTOR
-----------

### new

    my $tst = Algorithm::TernarySearchTree.new();

METHODS
-------

### insert(Str $key)

    $tst.insert($key);

Inserts the key to the tree.

### contains(Str $key) returns Bool:D

    my $flag = $tst.contains($key);

Returns whether given key exists in the tree.

### partial-match(Str $fuzzy-key) returns Set:D

    my Set $matched = $tst.partial-match($fuzzy-key);

Searches partially matched keys in the tree. If you want to match any character except record separator(hex: 0x1e), you can use dot symbol. For example, the query "Perl." matches "Perla", "Perl5", "Perl6", and so on.

METHODS NOT YET IMPLEMENTED
---------------------------

near-search, traverse, and so on.

AUTHOR
======

titsuki<EMAIL_ADDRESS>
COPYRIGHT AND LICENSE
=====================

Copyright 2016 titsuki

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

This algorithm is from Bentley, Jon L., and Robert Sedgewick. "Fast algorithms for sorting and searching strings." SODA. Vol. 97. 1997.

gha_language: Perl 6


text:
# Contributing to aceR

Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.

## overview

`aceR` is an [R package](http://www.statmethods.net/interface/packages.html). [It is not a *script* nor is it collection of scripts](https://youtu.be/r1yYJBzf1VQ?t=18). Please don't treat this repository as a script dump. The scripts provided in [scripts](/scripts) are meant to be examples to build on (not copy/paste).

### pull-requests

New features are great. They should remain focused in scope and avoid containing unrelated commits.

Please ask first before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.

## development pre-reqs

1. Install [R](http://cran.rstudio.com/)
2. Install [RStudio](http://www.rstudio.com/products/rstudio/download/)

#### R-dev package dependencies

```
dev_deps = c("devtools", "roxygen2", "testthat", "sciplot")
install.packages(dev_deps)
```

## development flow

In RStudio,

File `->` Open Project `->` aceR.Rproj

1. Make your changes.

   Build `->` Build & Reload

2. Test your changes (add unit tests).

3. Check changes with R check:

   Build `->` Check Package

4. Make a pull-request if your code passes tests and R checks.

## philosophy

1. Aside from some notable exceptions, functions should only do one thing. Break up larger functions into smaller general functions where possible.

2. Add new functions to existing files where possible. More files makes it harder to find things.

3. Use file name prefixes to organize files (no subdirectories). Use existing prefixes when possible.

4. function names should be general, concise, and descriptive. (ex. `make_box_plot` instead of `make_box_plot_for_seacrest_reaction_time`) - see 1.

5. variable names should be generic (ex. `x` instead of `age`)

A rule of thumb: make everything generic and re-usable.

## syntax style guide

Please refer to [this guide](http://r-pkgs.had.co.nz/style.html) when writing new functions or refactoring old ones.

#### tl;dr

1. snake_case
2. spaces around all infix operators (`=`, `+`, `-`, `<-`, etc)
3. curly braces on same line as first statement
4. use `=` within functions. otherwise use `<-`
5. 2 space indentation

#### function documentation

Use [roxygen2](http://r-pkgs.had.co.nz/man.html) for documenting functions.

## tests

We use the [testthat](https://github.com/hadley/testthat) package to run basic unit tests. Please make sure your code passes before checking-in your changes. Please add [unit tests](tests/testthat/) when possible.

**Never merge `development` into `master` if the tests are failing**

### Travis

Tests are automatically deployed on Travis after every push.

https://travis-ci.org/josegallegos07/aceR/builds

gha_language: R


text:
# Ping pong ball tracker (offline)

**Important note**: To have all elements displayed properly (for example images), please read this `README.md` file with a markdown renderer or as an easier alternative, on Github where this is hosted (https://github.com/aravindbattaje/ece6258project/blob/master/README.md).

This is part of the project for ECE-6258 (Digital image processing) at Georgia Tech. This is a segue project to an automatic ping pong ball refereeing system. This project only tries to implement reliable tracking of a ping pong ball in 3D space, using two cameras discreetly situated near the ends of the net of a ping pong table. [GoPro Hero3+ Silver](https://gopro.com/update/hero3_plus) and [GoPro Hero5 Black](https://gopro.com/update/hero5) cameras were used during development of this project, but the implementation should be reasonably extendable to any camera with a decent frame rate and wide enough view, for example [iPhone](https://www.apple.com/iphone-8/) with [Ollo clip-on lens](https://www.olloclip.com/shop/shop/connect-super-wide-lens/).

The ping pong tracker is developed in Python. Once the videos from the two calibrated cameras are captured, it can be simply supplied to the software. The undisorted image from each camera is displayed

![videos_gif](screenshots/videos.gif)

along with a nice looking user-interactive 3D visualization of the ball being tracked in the videos.

![visu_gif](screenshots/visu.gif)

## Prerequisites

- Python 2.7.x
- OpenCV 3.3.0+
- Numpy 1.13+
- Matplotlib 1.5+ (Not required if running only `ping_pong_tracker.py`)
- Mayavi 4.5.0+
  - Additional dependencies
    - Python bindings for VTK
    - PyQt4
    - Only Windows: Visual C++ for Python ([link](https://www.microsoft.com/en-us/download/details.aspx?id=44266))

All of the above libraries can be installed through package managers like `conda` (recommended) or `pip`. However, for Windows, if taking the `pip` route, it is recommended to get binary (wheels) from [Python Extension Packages for Windows](https://www.lfd.uci.edu/~gohlke/pythonlibs/).

Also in Windows, ensure `opencv_ffmpeg*.dll` file is present in the current directory or in `PATH`. This is required for using video files in the scripts.

**Important note**: `ping_pong_tracker.py` is optimized to run on Windows only. (It has been also tested on Linux.) However, there might be problems on Mac OS X due to the multiprocessing/multithreading constraints laid in its OS.

## Main scripts to use
- `calib_save_images.py`
- `calib_find_intrinsics_images.py`
- `calib_find_extrinsics_images.py`
- `ping_pong_tracker.py`

## File description and usage

### General usage

Get the usage instructions for a particular Python script `<python_file>.py` by typing the following in command line:

`python <python_file>.py -h`.

Also, generally use `q` key on the GUI to stop execution.

### Prepare for camera calibration

The camera intrinsic properties are found using a special calibration board. The calibration board can be generated by running

`python calib_generate_charuco.py`

This generates a calibration board in the root folder called `calib_charuco_board.png` like below image.

![calibration_board](calib_charuco_board.png)

The parameters of the calibration board can be changed by editing the script.

### Find intrinsic parameters of camera

After the above generated calibration board is printed to 100% scale, and carefully displayed in various views in front of the camera, and recording the corresponding video, the following scripts can be used to find the intrinsic parameters a camera.

#### From images

First, manually select (at least 25) candidate images from the calibration video by running

`python calib_save_images.py --video <path_to_video_file>`

This opens a GUI showing the first frame of the video file. Click on playback slider to start playing video and click on it again to pause. Use the following keyboard shortcuts:

- `s` - Save current image
- `b` - Seek back 1 second
- `n` - Go ahead 1 second

The images will be stored in the folder `calib_images`. Example saved image:

![example_calib_image](calib_images/two_1_gopr0010_6281.png)

These cherry-picked images will be used as input to the script that finds calibration parameters

`python calib_find_intrinsics_images.py --video <path_to_video_file> --model <P/F>`

The `--model/-m` argument specifies the camera projection model to use. The input can be either `P` for pinhole camera or `F` for fisheye model.

This script produces a file (`new_calib_<camera_model>.npz`) with the found calibration parameters. It also outputs the RMS error on terminal. Generally a _good_ calibration will have an RMS error less than 10. Also, the markers in the calibration board for each image are found and saved back in to the `calib_images` folder for inspection. Example:

![example_calib_image_markers](calib_images/two_1_gopr0010_6281_markers.png)

`calib_find_intrinsics_images.py` expects the folder `calib_images` to be present in the root directory. It also accepts the normal `--video` argument that other scripts expect, as `<video_file_name>` is used as prefix for finding calibration images. If calibration video not available, fool this script with a dummy video (file name).

If satisified with the calibration, copy over the newly generated calibration configuration `new_calib_<camera_model>.npz` to `config` folder as `intrinsic_calib_<camera_model>_camera_<1/2>.npz`.

#### Directly from video

**Note: Deprecated.** Don't use this now. The script is retained to easily update in the future (for example, online implementation).

`python calib_find_intrinsics_video.py --video <path_to_video_file>`

The intrinsic calibration will be written to the file `new_calib.npz` in the root directory.

### Test scripts

There are several _test_ scripts in the repository that were constructed during development, and they usually encapsulate individual features. Some of the _test_ scripts maybe run to test out these individual features if desired. However, these scripts serve more as a template if further development in an individual feature is desired. The usage instructions for these scripts can be obtained by running

`python test_*.py -h`

**Note**: One particular test script -- `test_undistort.py` -- is extremely helpful in finding if we have a _good_ intrinsic calibration and also to get images for the next step (i.e., extrinsic calibration.) The usage for this is:

`python test_undistort.py --video <path_to_video_file> --model <P/F>`

This script reads the intrinsic calibration `new_calib_<camera_model>.npz` and displays undistorted version of the video file. If there was a _good_ calibration, straight lines in the world, for example edges of walls or ping pong table, that were distorted due to the imager optics must appear straight again in the undistorted video. The keyboard shortcut `s` saves the current video frame being viewed to two image files: Original video frame (distorted image) to `image_for_markers_orig.png` and Undistorted image to `image_for_markers_undistorted.png`.

### Find extrinsic parameters of camera

After performing intrinsic calibration for each of the camera successfully, the pose of each camera with respect to the ping pong table needs to be found. Currently, only a manually intervened process for finding camera position is supported, although extending the software to do it automatically will not be too difficult.

An image from each camera needs to be obtained first. This can be done with the help of the script above (`test_undistort.py`) or any other means. The _standard positions_ on a ping pong table needs to be manually marked by the user using a decently sized circle of edge color _Aqua_ (`#8cfffb`). The standard positions are 4 corners of the left quarter part of ping-pong table directly in front of the player. Here is a marked image illustrating the _standard_ positions:

![markers_on_table](table_markers_distorted_2.png)

Any program can be used to place the markers on the table. For instance Microsoft Paint can be used as shown below:
![markers_marking](screenshots/markers_marking_in_paint.jpg)

**Note** that the markers can be marked on **either** distorted image or undistorted image. The following script needs to be notified which type of image is used. The following script finds the extrinsic parameters (pose of the camera) given the marked image.

`python calib_find_extrinsics_images.py --image <path_to_marked_image_file> --model <P/F> [--distorted]`

The `--model/-m` argument specifies the camera projection model to use. The input can be either `P` for pinhole camera or `F` for fisheye model. The optional argument `--distorted` specifies if the given image is original (distorted) image directly from the camera, or (if not specified,) then image that is undistorted.

The output will be the given image with the center of table (X-Y-Z axis at world origin) overlayed on top of it as shown below:

![extrinsic_calib_output](screenshots/extrinsic_calibration.jpg)

This script produces a file (`new_extrinsics.npz`) with the found calibration parameters. If satisified with the calibration, copy over the newly generated calibration configuration to `config` folder as `extrinsic_calib_<camera_model>_camera_<1/2>.npz`.

### Ping pong tracker

Given successful intrinsic and extrinsic calibration, ping pong tracker locates the ball if seen in the scene in 3D space and represents that on an interactive visualization. Note that this script uses multiple processes and so it would be advantageous to run this on a multi-core PC. The usage for this script is

`python ping_pong_tracker.py --video-1 <path_to_video_from_camera_1> --video-2 <path_to_video_from_camera_2> [--model <P/F>]`

The camera model parameter is optional as it defaults to pinhole camera model (`P`) if not mentioned.

Here is a screenshot of `ping_pong_tracker.py` running:

![screenshot_videos_visu](screenshots/videos_and_visu.png)

Note that depending on the system, VTK (the underlying visualization engine) might show "warnings" or "errors" on `vtkOutputWindow` opened in a separate window such as
> vtkWin32OpenGLRenderWindow (000000000EB2DEC0): We have determined that your graphics system is an Intel SandyBridge based system. These systems only partially  support VTK. If you encounter any issues please make sure your graphics drivers from Intel are up to date.

Such warnings can be completely ignored and feel free to close `vtkOutputWindow` too.

Fall back: If visualization is not working with Mayavi for some reason, an alternative would be to use `test_visualization_two_view.py` that uses Matplotlib for visualization in 3D space. However, because of the limitations in using Matplotlib for fast animation, and that the script is not optimized for multicore processing, this script is **not** preferred.

### Utils

During development some light wrapper utilities were written to aid in helping to use some OpenCV functions or saving/loading configuration files. They are present in the `utils` directory. These can be reused if anyone desires.

## Video data

Links to download some of the video files recorded with **Hero5 Black** is available in `captures` folder.

## Known bugs

- The fisheye camera model is not stable in OpenCV. So in some cases, even with a well defined set of calibration images, the extrinsic re-calculation for each image fails. Fortunately, the pinhole model is very stable, and the distortion effects due to the approximations in pinhole model don't seem to pose a big issue in locating the ball.
- On exit, `ping_pong_tracker.py` sometimes hangs up. This is probably to do with `vtkPython` not behaving well on exit.
- Video decoder problems exist with odd frame rates such as 80 fps on Windows. To solve this, convert all video inputs to standard rates -- 30 fp/60 fps/120 fps.
- Not really a bug, but the GUIs are not updated with seek positions of video playback. That is, when video moves forward, the seek bar is not updated, but the other way works -- when seek bar is moved, video position changes. This due to lack of complexity in OpenCV GUI API.


text:
# QFIELD application in QGIS
[Home](../README.md)

## Index
* [What is QFIELD](#What-is-QFIELD)
* [Basic steps from QGIS to QFIELD](#What-is-QFIELD)
* [QFIELD and Geodatpackages](#Quick-Mapservices-Plugin)
* [Qfield Best Practices](#Qfield-Best-Practices)
* [QField sync plugin overview](#QField-sync-plugin-overview)
   * [Project Configuration](#Project-Configuration)
   * [Preferences](#Preferences)
   * [Package for QField](#Package-for-QField)
   * [Syncronize from QField](#Syncronize-from-QField)
* [Making a QGIS project for QField](#Making-a-QGIS-project-for-QField)
   * [Start a new QGIS project, Settings and Project Folders](#Start-a-new-QGIS-project,-Settings-and-Project-Folders)
   * [Select and export data Geodatapackage](#Select-and-export-data-Geodatapackage)
   * [Adding Imagery](#Adding-Imagery)
   * [Create layers for capturing data in the field](#Create-layers-for-capturing-data-in-the-field)
   * [Controlling Data entry](#Controlling-Data-Entry)
   * [Set up data layers to capture photos linked to collected data](#Set-up-data-layers-to-capture-photos-linked-to-collected-data)
   * [QField Sync Plug in and prepare data for QField](#QField-Sync-Plug-in-and-prepare-data-for-QField)
* [Using QField on your Mobile device](#Using-QField-on-your-mobile-device)
   * [Add QField package and app to your device](#Add-QField-package-and-app-to-your-device)
   * [The QField App interface](#The-QField-App-interface)
   * [Syncronize the QField data package back to your master data package](#Syncronize-the-QField-data-package-back-to-your-master-data-package)

## What is QFIELD

QField is a mobile application built on QGIS open source software platform. The user makes a mapping project (.qgs project) in QGIS then converts it to a QFIELD mobile project. The user can then assess or collect data in the field and then syncronize it back to the master QGIS data sources that the mapping project was created from. The Qfield interface is simple to use as most of the set up is completed in the QGIS project before exporting to a QField project.

Currently Qfield is only built for Android operating systems, though Apple IOS is currently in development.

## Qfield and GeodataPackages

### Basic steps from QGIS to QFIELD and Back
 For new users to QGIS or QField, the basic steps for using QField is as follows.
 1. Create a new QGIS project in a project folder.
 2. Add features from data sources into QGIS and theme appropriately. Data generally should be in project folder to take application offline into the field.
 3. Load the Qsync plugin
 4. Run Package for Qfield in the Plugin. Selecting how you want layers to be used as offline or editable. Export the package to a new folder
 5. Take the new QField package folder and move it to your mobile device
 6. Open Qfield on your tablet and open the .qgs file in the package folder
 7. Collect field work data then copy Qfield package from field device to computer
 8. Syncronize field data back to Master data set that was used to make QField package

## Qfield Best Practices
QField is an effective mobile mapping solution, however there are some best practices to make the application work effectively and minimize .

1. Set your QGIS project to relative paths.
2. Use Geodatapackages. Other formats can be used, though reliability has not been tested.
3. Projections: QGIS and QField can use different projection sources in the data, though if issues arise a common projection of data may be beneficial. e.g. WGS 84 or BC Albers
4. Very large data sets can burden the application so be mindful of how much imagery and data you use.

# QField Sync Plugin overview

### Configure Current Project (QField Sync Project Properties)
Allows the user to control how data will be used when packaged for QField.
Choices include:
1. Lock Geometry for data copied to Qfield
2. Action: (Copy) data for use in QField
3. Action: (Offline Editing) Allow user to edit data in QField
4. Action: (Remove) Do not Package data for use in QField
5. Action: (Keep Existent) If data is already in a previous QField package then keep existing data.
![QField Configure](../images/QField_Configure.JPG)
6. Base Map. An image basemap can be created from an image layer. **This may require the image to be in the same projection as the data or it may not work.
7. Offline editing. Only copy features in the Map Area of Interest Window.

### Preferences
Where you can set your default import and export directories

### Package For QField

1. Select export directory.
2. Select Extent by zooming in view window the area of data you would like to export to QField.
![QField Configure](../images/QField_Package.JPG)

### Syncronize from QField
1. Open the Original QGIS project then select folder where import data from the field was placed.
2. Then Syncronize QGIS data, which will update source QGIS data with data collected from QField.
![QField Syncronize](../images/QField_Syncronize.JPG)

# Making a QGIS project for QField
### For this example data has been placed in a GeoDataPackage. "new_geodatapackage.gpkg". Data in the project includes.
- Local city data (Property, Street) EPSG:3157 - NAD83(CSRS) / UTM zone 10N - Projected
- Province of BC Data (Wells or(WLS...), Crown_Polygon, FWA_Streams) EPSG:4326 - WGS 84 - Geographic
- New Empty Layers to collect field data and will be used for offline editing. (Field_Lines, Field_Polygons, Field_Points)

### Start a new QGIS project, Settings and Project Folders
1. Create new empty folder to store data and your project. e.g. QField_Project_Main.
2. Open a new QGIS project and save .QGS project to the empty folder.
3. Set QGIS project projection and relative path setting. e.g. WGS 84 CRS projection

### Select and export data Geodatapackage
1. Select the data you want to use in QField and export it to a new geodatapackage in the project folder.
2. Add the data to your QGIS project, theme layers and save to the QField Project folder.

### Adding imagery
a. Offline Imagery: It is reccomended that when using offilne imagery to only use small image areas. Images like GEOTIFF or Geo JPEG can be used or MBtiles layer can be created to tile web imagery into an offline Spatial lite data format. The following example shows how to create image tiles of online imagery with a min zoom of 3 and max of 18. If you go above 18 it will likely create a huge file size that is not useable on your device.
MBTiles creation for offline imagery
![QField_MBtiles](../images/QField_MBtiles.JPG)

b. Online imagery: This can be added as datasource imagery in your QGIS project and will load in QField if your field device has data/WIFI availability. The benefits of this method means that large imagery datasets do not have to be added to the device using much less data space.  See web mapping and other remote data section for adding online imagery to a QGIS project.
![Add XYZ Tiles](../images/Add_XYZ_Tiles.gif)

### Create layers for capturing data in the field.
e.g. Field_Points, Field_Lines, Field_Polygons
Layer -> Create Layer -> New Geodatapackage Layer
![QField_NewGeodatapackage](../images/QField_NewGeodatapackage.JPG)

### Controlling Data entry.
#### Data entry in QField can be controlled and managed in QGIS Layer Properties.
a. Relation Reference: Creates a relation reference to a table and values can be added or deleted from the reference table.
b. Value Relation: Values to control data entry are based on a related table within the QGIS Project.
c. Attachment: Attachments can be tagged to a field such as PDF or photos.
d. Value Map: Values are set based on a value table developed in QGIS.
e. Constraints: Data entry is constrained to the values that have to be entered. Value Ranges or not null.
f: Default Values: If a feature is created in QField a default value will be entered. e.g. Force a date entry when new feature created.

An example of setting up data controls for 1 layer in QGIS. (Valuemap, Constraints, Attachment)
![QField Control Data_Entry](../images/QField_Control_Data_Entry.gif)

### Set up data layers to capture photos linked to collected data

Two methods can be set up to capture photos in QField
1. One photo for each feature collected in the field. One to One
- Add a (String) field to layer that photo will be attach to. e.g. Photo
- Set Widget Type for field to "Attachment" and Path to "Relative Paths"
- Under Actions add an item to the Action List. Type = Open and Action = [%"Photo"%]
![QField_Picture_One_to_One](../images/QField_Picture_One_To_One.gif)

2. Many Photos for each feature collected in the field. One to Many
- Add a (String) field to layer that photo will be related to. e.g. Photo_Link
- Create a seperate reference table with fields (Point Picture_ID = String) and (Photo_Path = String, Widget Type = Attachment and Path Relative)
- Create a Data relation between the feature layer and relate photo table. Create Relation Between UUID field in layer and Point Picture_ID in table.  Example to come but here is a link
https://qfield.org/docs/prepare/add-1-n-pictures.html

### QField Sync Plug in and prepare data for QField

When you feel your QGIS project has all the data , theme, property controls and imagery added, you can now export it to a QField package.
- Make an empty folder which to export the QFIELD package. e.g. QField_Project_Out
- Start the QField sync plugin and configure current project. Select which data you want for geometry lock, offline editing, data you just want to copy to QField or remove data to not be added to the exported QField project.
![QField_Configure_Project](../images/QField_Configure_Project.gif)
- Next in the Qsync Plugin. Package for QField and Export the project to "QField_Project_Out". If you open the exported .qgs file it will have (offline) in the name header as well as the data layers set to offline. Your project folder and all data in the folder can now be transfered to your android device.
![QField_Configure_Project](../images/QField_Package_Project.gif)

# Using QField on your Mobile device

### Add QField package and app to your device
- QField app can be added to your device from the Google play store and hopefully the Apple store in the future.
- https://play.google.com/store/apps/details?id=ch.opengis.qfield&utm_source=qgis.org
- Copy the exported folder to a location on your device you are familiar with and which you can can access.
![QField_Open_Project](../images/QField_Open_Project.gif)

### The QField App interface
#### Upper Left (Three Dashes) Map Legend
- Highlight Layer and hold to access new window for layer.
   - Show on map. (Turns layer on or off)
   - Zoom to extent. (Zoomes to full extent of layer)
   - Show feature list. (Will open data list)
   - Start Tracking.
      - Set interval you want data collected as you walk
      - Enter attributes for new feature to be created, then start walking.
      - Notice the black figure beside the layer when tracking is on.
      - When done walking go back to feature and stop tracking.
      Feature Collected!
- Digitize Mode (Editing Pencil)
   - This will initiate the layer that was highlighted to go into editing mode. Notice the Green add button in lower right when you switch to editing. The green button allows you to add features.
- Browse Mode (Paper Button Beside Pencil)
   - To turn off editing just toggle the browse mode button beside the pencil.
![QField_Legend_Functionality](../images/QField_Legend_Functionality.gif)

#### Lower right and Middle right buttons.
- Zoom in + and - Zoom out.
- Zoom to current GPS location (Circle with solid dot).
- Lock or unlock cursor to GPS position (Circle with Plus sign).
- Add feature. (Circle with Plus on bottom) Button will be Green sometimes and other times Grey.
   - To Edit. Highlight feature in legend. Find on map (Cursor Crosshairs) or zoom to GPS location, then use add button to add feature and attributes.
![QField_Edit_Add_Data](../images/QField_Edit_Add_Data.gif)

#### Click on Map features in main window to look at attribute tables.
- All features identified at that point will display in pop up window.
- Left and Right Arrow through records.
- A (Pencil) will allow editing of attributes.
- Line (Pencil) edits geometry ofthe feature identified.
- Geometry will not be editable if specified in initial QGIS set up.
![QField_Search_Features](../images/QField_Search_Features.gif)

#### Upper Right Search button.
- The search button in the upper right can be used to query all the layers for specific names or attributes.
- The example below searches for a creek of a specific name, then selects and zooms to it.
- Search ability can be controled in QGIS setup. (Project Properties-> Data Sources)

![QField_Search_Data](../images/QField_Search_Data.gif)

#### Digitizing and data creation/editing
- Please see the following location for more methods for digitizing and modifying data in QField.
https://qfield.org/docs/fieldwork/digitize.html

# Syncronize the QField data package back to your master data package
- Once you have used QField on a device and collected or modified data, copy the data package folder from the device to a new empty folder. e.g. QField_Project_in.
- Then using the original .qgs project used to make the QField package and syncronize. (QField plugin-> Syncronize from QField).
- All data from the field that was changed or added will be copied into the original data source.
![QField_Syncronize](../images/QField_Syncronize.gif)

# The Future

- QFIELD and cloud syncronizing of data. Spring 2021
https://qfield.cloud/

- Stay tuned for potential IOS development

### License
    Copyright 2019 BC Provincial Government

    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.

---
[Back to Top](#Index)

repository: bcgov/gis-pantry

gha_language: Jupyter Notebook

repo_name: bcgov/gis-pantry


text:
---
layout: default
---

# 1993-09-23 - H. Finney: #1 Cyberspatial Lawyer

## Header Data

From: "L. Detweiler"<EMAIL_ADDRESS>To<EMAIL_ADDRESS>Message Hash: 18afdf8e726dcf4617739d859fa2648f52d5fdc48e0b008d68ffc1eae2aac829

Message ID<EMAIL_ADDRESS>Reply To: _N/A_

UTC Datetime: 1993-09-23 21:47:23 UTC

Raw Date: Thu, 23 Sep 93 14:47:23 PDT

## Raw message

```
{% raw  %}From: "L. Detweiler"<EMAIL_ADDRESS>Date: Thu, 23 Sep 93 14:47:23 PDT
To<EMAIL_ADDRESS>Subject: H. Finney: #1 Cyberspatial Lawyer
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

I'm truly in awe. H. Finney gets my vote as Cypherpunk of the Week for
uncovering all this dazzlingly appropos information.

[U.S. vs. Posey decision]
>Technical data that is relatively harmless and even socially val-
>  uable when available domestically may, when sent abroad, pose unique
>  threats to national security.

gad -- they simply don't understand that cyberspace has no boundaries,
subject to the same delusions of the NSA. Maybe they should read that
extraordinary quote by Mr. President uncovered by Markoff.

>In any case, this decision and the earlier one it quotes both represent
>rejections by the 9th circuit appellate court (which includes California,
>where the grand jury investigations are taking place) of the argument
>that the ITARs infringe on First Amendment rights.  This will make it more
>difficult to use the First Amendment defense in any new charges of arms
>export violations.

either that, or we're TAKING THIS TO THE SUPREME COURT!

hee, hee. for the mentally challenged, that's *satire*, folks, don't get excited.

{% endraw %}
```

## Thread

+ Return to [September 1993](/archive/1993/09)

+ Return to "["L. Detweiler" <ld231782@longs.lance.colostate.edu>](/authors/l_detweiler_ld231782_at_longs_lance_colostate_edu_)"

+ 1993-09-23 (Thu, 23 Sep 93 14:47:23 PDT) - H. Finney: #1 Cyberspatial Lawyer - _"L. Detweiler"<EMAIL_ADDRESS>


text:
# Functions

Exposed provides basic support for classic SQL functions. This topic consists of definitions for those functions, and their
usage examples. It also explains how to define [custom functions](#custom-functions).

## How to use functions
If you want to retrieve a function result from a query, you have to declare the function as a variable:
```kotlin
val lowerCasedName = FooTable.name.lowerCase()
val lowerCasedNames = FooTable.slice(lowerCasedName).selectAll().map { it[lowerCasedName] }

```
Also, functions could be chained and combined:
```kotlin
val trimmedAndLoweredFullName = Concat(FooTable.firstName, stringLiteral(" "), FooTable.lastName).trim().lowerCase()
val fullNames = FooTable.slice(trimmedAndLoweredFullName).selectAll().map { it[trimmedAndLoweredFullName] }

```

## String functions
### LowerCase/UpperCase
Returns a lower-cased/upper-cased string value.
```kotlin
val lowerCasedName = FooTable.name.lowerCase()
val lowerCasedNames = FooTable.slice(lowerCasedName).selectAll().map { it[lowerCasedName] }

```
### Substring
Returns a substring value from the specified start and with the specified length.
```kotlin
val shortenedName = FooTable.name.substring(start = 1, length = 3)
val shortenedNames = FooTable.slice(shortenedName).selectAll().map { it[shortenedName] }

```
### Concat
Returns a string value that concatenates the text representations of all non-null input values, separated by an optional separator.
```kotlin
val userName = concat(stringLiteral("User - "), FooTable.name)
val userNames = FooTable.slice(userName).selectAll().map { it[userName] }

```
### Locate
Returns the index of the first occurrence of a specified substring or 0.
```kotlin
val firstAIndex = FooTable.name.locate("a")
val firstAIndices = FooTable.slice(firstAIndex).selectAll().map { it[firstAIndex] }

```
### CharLength
Returns the length, measured in characters, or `null` if the String value is null.
```kotlin
val nameLength = FooTable.name.charLength()
val nameLengths = FooTable.slice(nameLength).selectAll().map { it[nameLength] }

```

## Aggregating functions
These functions should be used in queries with [[groupBy|DSL#group-by]].
### Min/Max/Average
Returns minimum/maximum/average value and can be applied to any comparable expression:
```kotlin
val minId = FooTable.id.min()
val maxId = FooTable.id.max()
val averageId = FooTable.id.avg()
val (min, max, avg) = FooTable.slice(minId, maxId, averageId).selecAll().map {
    Triple(it[minId], it[maxId], it[averageId])
}

```

## Custom functions
If you can't find your most loved function used in your database (as Exposed provides only basic support for classic SQL functions), you can define your own functions.

Since Exposed 0.15.1 there multiple options to define custom functions:
1. Function without parameters:
```kotlin
val sqrt = FooTable.id.function("SQRT")
```
In SQL representation it will be `SQRT(FooTable.id)`

2. Function with additional parameters:
```kotlin
val replacedName = CustomFunction<String?>("REPLACE", VarCharColumnType(), FooTable.name, stringParam("foo"), stringParam("bar"))

```
`CustomFunction` class accepts a function name as a first parameter and the resulting column type as second. After that, you can provide any amount of parameters separated by a comma.

There are also shortcuts for string, long, and datetime functions:
* `CustomStringFunction`
* `CustomLongFunction`
* `CustomDateTimeFunction`

The code above could be simplified to:
```kotlin
val replacedName = CustomStringFunction("REPLACE", FooTable.name, stringParam("foo"), stringParam("bar"))

```
For example, the following could be used in SQLite to mimic its `date()` function:
```kotlin
val lastDayOfMonth = CustomDateFunction(
    "date",
    FooTable.dateColumn,
    stringLiteral("start of month"),
    stringLiteral("+1 month"),
    stringLiteral("-1 day")
)
```
3. Function that requires more complex query building:

All functions in Exposed extend the abstract class `Function`, which takes a column type and allows overriding `toQueryBuilder()`. This is what `CustomFunction` actually does, which can be leveraged to create more complex queries.

For example, Exposed provides a `trim()` function that removes leading and trailing whitespace from a String. In MySQL, this is just the default behavior as specifiers can be provided to limit the trim to either leading or trailing, as well as providing a specific substring other than spaces to remove. The custom function below supports this extended behavior:
```kotlin
enum class TrimSpecifier { BOTH, LEADING, TRAILING }

class CustomTrim<T : String?>(
    val expression: Expression<T>,
    val toRemove: Expression<T>?,
    val trimSpecifier: TrimSpecifier
) : Function<T>(TextColumnType()) {
    override fun toQueryBuilder(queryBuilder: QueryBuilder) {
        queryBuilder {
            append("TRIM(")
            append(trimSpecifier.name)
            toRemove?.let { +" $it" }
            append(" FROM ")
            append(expression)
            append(")")
        }
    }
}

fun <T : String?> Expression<T>.customTrim(
    toRemove: Expression<T>? = null,
    specifier: TrimSpecifier = TrimSpecifier.BOTH
): CustomTrim<T> = CustomTrim(this, toRemove, specifier)

transaction {
    FooTable.insert { it[name] = "xxxbarxxx" }

    val leadingXTrim = FooTable.name.customTrim(stringLiteral("x"), TrimSpecifier.LEADING)
    val trailingXTrim = FooTable.name.customTrim(stringLiteral("x"), TrimSpecifier.TRAILING)

    FooTable.slice(leadingXTrim).selectAll() // barxxx
    FooTable.slice(trailingXTrim).selectAll()  // xxxbar
}

```

## Window Functions

Window functions allow calculations across a set of table rows that are related to the current row.

Existing aggregate functions (like `sum()`, `avg()`) can be used, as well as new rank and value functions:
* `cumeDist()`
* `denseRank()`
* `firstValue()`
* `lag()`
* `lastValue()`
* `lead()`
* `nthValue()`
* `nTile()`
* `percentRank()`
* `rank()`
* `rowNumber()`

To use a window function, include the `OVER` clause by chaining `.over()` after the function call. A `PARTITION BY` and
`ORDER BY` clause can be optionally chained using `.partitionBy()` and `.orderBy()`, which both take multiple arguments:
```kotlin
FooTable.amount.sum().over().partitionBy(FooTable.year, FooTable.product).orderBy(FooTable.amount)

rowNumber().over().partitionBy(FooTable.year, FooTable.product).orderBy(FooTable.amount)

FooTable.amount.sum().over().orderBy(FooTable.year to SortOrder.DESC, FooTable.product to SortOrder.ASC_NULLS_FIRST)
```
Frame clause functions (like `rows()`, `range()`, and `groups()`) are also supported and take a `WindowFrameBound` option
depending on the expected result:
* `WindowFrameBound.currentRow()`
* `WindowFrameBound.unboundedPreceding()`
* `WindowFrameBound.unboundedFollowing()`
* `WindowFrameBound.offsetPreceding()`
* `WindowFrameBound.offsetFollowing()`
```kotlin
FooTable.amount.sum().over()
    .partitionBy(FooTable.year, FooTable.product)
    .orderBy(FooTable.amount)
    .range(WindowFrameBound.offsetPreceding(2), WindowFrameBound.currentRow())
```

<note>
If multiple frame clause functions are chained together, only the last one will be used.
</note>

repository: JetBrains/Exposed

gha_language: Kotlin

repo_name: JetBrains/Exposed


text:
# Memory Resolver Tutorial

The `MEMORY` resolver is a server built-in resolver for account JWTs. If there are a small number of accounts, or they do not change too often this can be a simpler configuration that does not require an external account resolver. Server configuration reload is supported, meaning the preloads can be updated in the server configuration and reloaded without a server restart.

The basic configuration for the server requires:

* The operator JWT
* `resolver` set to `MEMORY`
* `resolver_preload` set to an object where account public keys are mapped to account JWTs.

## Create Required Entities

Let's create the setup:

```shell
nsc add operator -n memory
```
```
Generated operator key - private key stored "~/.nkeys/memory/memory.nk"
Success! - added operator "memory"
```

Add an account 'A'

```shell
nsc add account --name A
```
```
Generated account key - private key stored "~/.nkeys/memory/accounts/A/A.nk"
Success! - added account "A"
```

Describe the account

```shell
nsc describe account -W
```
```
╭──────────────────────────────────────────────────────────────────────────────────────╮
│                                   Account Details                                    │
├───────────────────────────┬──────────────────────────────────────────────────────────┤
│ Name                      │ A                                                        │
│ Account ID                │ ACSU3Q6LTLBVLGAQUONAGXJHVNWGSKKAUA7IY5TB4Z7PLEKSR5O6JTGR │
│ Issuer ID                 │ ODWZJ2KAPF76WOWMPCJF6BY4QIPLTUIY4JIBLU4K3YDG3GHIWBVWBHUZ │
│ Issued                    │ 2019-04-30 20:21:34 UTC                                  │
│ Expires                   │                                                          │
├───────────────────────────┼──────────────────────────────────────────────────────────┤
│ Max Connections           │ Unlimited                                                │
│ Max Leaf Node Connections │ Unlimited                                                │
│ Max Data                  │ Unlimited                                                │
│ Max Exports               │ Unlimited                                                │
│ Max Imports               │ Unlimited                                                │
│ Max Msg Payload           │ Unlimited                                                │
│ Max Subscriptions         │ Unlimited                                                │
│ Exports Allows Wildcards  │ True                                                     │
├───────────────────────────┼──────────────────────────────────────────────────────────┤
│ Imports                   │ None                                                     │
│ Exports                   │ None                                                     │
╰───────────────────────────┴──────────────────────────────────────────────────────────╯
```

Create a new user 'TA'

```shell
nsc add user --name TA
```
```
Generated user key - private key stored "~/.nkeys/memory/accounts/A/users/TA.nk"
Generated user creds file "~/.nkeys/memory/accounts/A/users/TA.creds"
Success! - added user "TA" to "A"
```

## Create the Server Config

The `nsc` tool can generate a configuration file automatically. You provide a path to the server configuration. The `nsc` tool will generate the server config for you:

```shell
nsc generate config --mem-resolver --config-file /tmp/server.conf
```

If you require additional settings, you may want to consider using [`include`](/running-a-nats-service/configuration/README.md#include-directive) in your main configuration, to reference the generated files. Otherwise, you can start a server and reference the generated configuration:

```shell
nats-server -c /tmp/server.conf
```

You can then [test it](mem_resolver.md#testing-the-configuration).

## Manual Server Config

While generating a configuration file is easy, you may want to craft one by hand to know the details. With the entities created, and a standard location for the `.nsc` directory. You can reference the operator JWT and the account JWT in a server configuration or the JWT string directly. Remember that your configuration will be in `$NSC_HOME/nats/<operator_name>/<operator_name>.jwt` for the operator. The account JWT will be in `$NSC_HOME/nats/<operator_name>/accounts/<account_name>/<account_name>.jwt`

For the configuration you'll need:

* The path to the operator JWT
* A copy of the contents of the account JWT file

The format of the file is:

```
operator: <path to the operator jwt or jwt itself>
resolver: MEMORY
resolver_preload: {
    <public key for an account>: <contents of the account jwt>
    ### add as many accounts as you want
    ...
}
```

In this example this translates to:

```
operator: /Users/synadia/.nsc/nats/memory/memory.jwt
resolver: MEMORY
resolver_preload: {
ACSU3Q6LTLBVLGAQUONAGXJHVNWGSKKAUA7IY5TB4Z7PLEKSR5O6JTGR: eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJPRFhJSVI2Wlg1Q1AzMlFJTFczWFBENEtTSDYzUFNNSEZHUkpaT05DR1RLVVBISlRLQ0JBIiwiaWF0IjoxNTU2NjU1Njk0LCJpc3MiOiJPRFdaSjJLQVBGNzZXT1dNUENKRjZCWTRRSVBMVFVJWTRKSUJMVTRLM1lERzNHSElXQlZXQkhVWiIsIm5hbWUiOiJBIiwic3ViIjoiQUNTVTNRNkxUTEJWTEdBUVVPTkFHWEpIVk5XR1NLS0FVQTdJWTVUQjRaN1BMRUtTUjVPNkpUR1IiLCJ0eXBlIjoiYWNjb3VudCIsIm5hdHMiOnsibGltaXRzIjp7InN1YnMiOi0xLCJjb25uIjotMSwibGVhZiI6LTEsImltcG9ydHMiOi0xLCJleHBvcnRzIjotMSwiZGF0YSI6LTEsInBheWxvYWQiOi0xLCJ3aWxkY2FyZHMiOnRydWV9fX0._WW5C1triCh8a4jhyBxEZZP8RJ17pINS8qLzz-01o6zbz1uZfTOJGvwSTS6Yv2_849B9iUXSd-8kp1iMXHdoBA
}
```

Save the config at server.conf and start the server:

```shell
nats-server -c server.conf
```

You can then [test it](mem_resolver.md#testing-the-configuration).

## Testing the Configuration

To test the configuration, simply use one of the standard tools:

```shell
nats pub --creds ~/.nkeys/creds/memory/A/TA.creds hello world
```


text:
---
layout: default
---

## Matching strings

The most basic type of node in PEG grammars is the literal string match. This
grammar will only match the string `"I like parsers"` and nothing else.

###### parsers.peg

    grammar Parsers
      root  <-  "I like parsers"

Strings are delimited with double quotes.  You can create
case-insensitive strings by quoting the string with backticks:

###### parsers.peg

    grammar Parsers
      root  <-  `I like parsers`

It will then match any casing of the input:

```js
require('./parsers').parse('I like PARSERS')
   == { textValue: 'I like PARSERS',
        offset: 0,
        elements: [] }
```

repository: rctay/canopy

repo_name: rctay/canopy


text:
# symbols:
- A new JS primitive data type.(number, string, boolean, null, undefined, symbol)
- is "unique, and immutable data type that is used to identify object properties".
- created by invoking Symbol() function.
- Symbol('description') function can have an optional string description that is used for _debugging_.
- Description is a way to describe the created symbol. It can not access the symbol or affect its value. That's why the symbols with the same description are not equal.
- syntax:
  ```javascript

  const bowl = {
  [Symbol('apple')]: { color: 'red', weight: 136.078 },
  [Symbol('banana')]: { color: 'yellow', weight: 183.15 },
  [Symbol('orange')]: { color: 'orange', weight: 170.097 },
  [Symbol('banana')]: { color: 'yellow', weight: 176.845 }
  };
  console.log(bowl);//{Symbol(apple): {…}, Symbol(banana): {…}, Symbol(orange): {…}, Symbol(banana): {…}}

repository: WebDevCaptain/Code-Notes

repo_name: WebDevCaptain/Code-Notes