text:
# pie-elements

A collection of pies. These packages are pie packages in that they have an optional `configure` and/or `controller` sub package.

## Install

```shell
yarn install # install monorepo dependencies
lerna bootstrap # symlinks any dependencies, uses yarn workspaces to speed up install
```

### pie global

For some of the scripts you'll need the pie cli installed (note that you must use npm to install this)

```shell
npm install -g pie
```

### Commands

| Action             | Notes                                                                   |
| ------------------ | ----------------------------------------------------------------------- |
| test               | runs all the tests, all tests run from the root of the monorepo         |
| build              | build the libs                                                          |
| lint               | runs eslint                                                             |
| clean              | removes all the lib dirs                                                |
| release            | cleans, runs tests, builds, then runs lerna publish                     |
| pie-clean          | cleans out the `docs/demo` dir                                          |
| pie-install        | installs in the `docs/demo` dir                                         |
| pie-pack-clean     | cleans out the `docs/demo` dir + any generated assets from a `pie pack` |
| scripts/info \$pkg | run `pie info` for a package, with watch enabled                        |

> when building make sure all watchers are disabled - we had an issue where a watcher was corrupting the build.

## running

Each package need to be built w/ babel before you can use it.

The following script:

```shell
scripts/info $package
```

Will run a watched babel process and the run `pie info`.

> You need to have `pie>=10.1.1` installed | `npm install -g pie`.

## Tests

All tests are run from the root of the repo.

> Don't add any test `devDependencies` or `jest.config.js` etc in the packages - it's unnecessary and can break the tests.

```shell
npm test
```

# publishing

## canary

```shell
yarn lerna publish --canary --dist-tag $TAG --preid $TAG --force-publish
```

### CI

We use circleci - see .circleci/config.yml

##

repository: pie-framework/pie-elements

branch_name: refs/heads/develop

gha_license_id: ISC

repo_name: pie-framework/pie-elements


text:
---
title: Use a data layer to set Analytics variables via Tags
description: Learn about using a data layer for sourcing Analytics data and other Experience Cloud solutions.
feature: Launch Implementation
role: Developer, Data Engineer
level: Beginner
kt: 1852
thumbnail: 25899.jpg
exl-id: 408ceb47-df05-4456-85bb-0ef2798a05a5
---
# Use a data layer to set Analytics variables via [!DNL Tags] {#use-a-data-layer-to-set-analytics-variables-in-adobe-analytics-via-tags}

Using a data layer for [!DNL Analytics] and other Experience Cloud solutions is a best practice. In this video, learn how to pull values out of the data layer and use them in [!DNL Experience Platform Tags] to populate variables in Adobe Analytics.

## Data layers {#data-layers}

A _data layer_ is a framework of JavaScript objects that developers add to digital web pages. Analytics solutions ultimately use the data layer to populate reports. Tag management systems, including [!DNL Experience Platform Tags]) are the intermediaries that read the data layer, map the values to variables, and  send that data to digital experience solutions.

Review additional information about data layers in the [Experience Cloud documentation](https://experienceleague.adobe.com/docs/analytics/implementation/prepare/data-layer.html?lang=en).

## Data Layers, [!DNL Experience Platform Tags], and Adobe Analytics{#data-layers-launch-and-adobe-analytics}

1. Define or identify a data layer standard to use on your site.

    1. Position the data layer as high as possible in the head section of the page and before the call to [!DNL Experience Platform Tags]. This ensures that the values are accessed immediately by [!DNL Tags] and by Adobe solutions that need to be high on the page, like Adobe Target.

1. Populate the data in the data layer.
1. In [!DNL Experience Platform Tags], create "[!UICONTROL data elements]" that map the data points in the data layer. These data elements are used throughout [!DNL Experience Platform Tags] in [!UICONTROL rules] and [!UICONTROL extensions].
1. In either the [!DNL Analytics] extension's global variables section or in a [!DNL Tags rule], assign the values in [!UICONTROL data elements] to [!UICONTROL props], [!UICONTROL eVars], [!UICONTROL pageName], and other [!DNL Analytics] variables.
1. Trigger a beacon that sends the data into [!DNL Analytics].

The following video walks you through the process.

>[!VIDEO](https://video.tv.adobe.com/v/25899/?quality=12&learn=on)

>[!NOTE]
>
>The specific data layer used in this video may not be considered "best practice" for your organization. The concept of using a data layer for surfacing important data to your digital marketing solutions is best practice.

license: MIT

branch_name: refs/heads/main

extension: md

gha_license_id: MIT

license_type: permissive


text:
# Kubernetes

This example provisions a Kubernetes cluster with 1 master node, 1 worker node, and a dedicated etcd node. Each node uses a static IP address on the local network.

## Assets

Download the required CoreOS Beta image assets.

    ./scripts/get-coreos beta 877.1.0

Next, add or generate a root CA and Kubernetes TLS assets for each component.

### TLS Assets

Use the `generate-tls` script to generate throw-away TLS assets. The script will generate a root CA and `admin`, `apiserver`, and `worker` certificates in `assets/tls`.

    ./examples/kubernetes/scripts/generate-tls

Alternately, if you have existing Public Key Infrastructure, add your CA certificate, entity certificates, and entity private keys to `assets/tls`.

    * ca.pem
    * apiserver.pem
    * apiserver-key.pem
    * worker.pem
    * worker-key.pem
    * admin.pem
    * admin-key.pem

See the [Cluster TLS OpenSSL Generation](https://coreos.com/kubernetes/docs/latest/openssl.html) document or [Kubernetes Step by Step](https://coreos.com/kubernetes/docs/latest/getting-started.html) for more details.

Return the the general examples [README](../README).

## Usage

Install `kubectl` on your host and use the `examples/kubernetes/kubeconfig` file which references the top level `assets/tls`.

    cd /path/to/coreos-baremetal
    kubectl --kubeconfig=examples/kubernetes/kubeconfig get nodes

Watch pod events.

    kubectl --kubeconfig=examples/kubernetes/kubeconfig get pods --all-namespaces -w

Get all pods.

    kubectl --kubeconfig=examples/kubernetes/kubeconfig get pods --all-namespaces

On my laptop, it takes about 1 minute from boot until the Kubernetes API comes up. Then it takes another 1-2 minutes for all components including DNS to be pulled and started.

repository: philips/coreos-baremetal

branch_name: refs/heads/master

gha_language: Go

repo_name: philips/coreos-baremetal


text:
---
title: Custom Raspbian Image using Ansible
image: https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Ansible_logo.svg/220px-Ansible_logo.svg.png
excerpt: A durable solution for creating a custom Raspbian image
description: raspbian ansible
categories: raspbian
---
A while ago, I looked at PiBakery as a possible way of customizing a Raspbian image, but it had its limitation because you need to start
with a customized version of Raspbian.

I have been looking frantically for a more durable solution. In the DevOps developer community, they have used tools to provision computers
like Chef and Puppet, but I always found those tools overly complicated to use. Then arrives Ansible from RedHat.

I have created a project on github called raspberrypi-ansible.

- You start with a fresh installation of Raspbian.
- You run the Ansible playbook.
- You end up with a customized version of Raspbian with all sorts of goodies installed.

You need access to a PC with Ubuntu on it. I tested it with Bash on Ubuntu on Windows (Windows 10), but should work for Ubuntu 16.04.1
You can boot Ubuntu from a USB stick and try the instructions below. Feedback and suggestions welcome.

## Link
[Github repo for raspberrypi-ansible](https://github.com/mohankumargupta/raspberrypi-ansible)


text:
The JavaScript SDK provides a promise interface to relaying calls to the Dropbox SDK.

## Example request
Using an access token generated from your developer account you'll be able to access your Dropbox information using the Dropbox class to demonstrate the SDK is working correctly.

```javascript
var fetch = require('isomorphic-fetch');
var Dropbox = require('dropbox').Dropbox;
new Dropbox({
  fetch: fetch,
  accessToken: 'YOUR_ACCESS_TOKEN_HERE'
})
  .filesListFolder({path: ''})
  .then(console.log, console.error);
```

## API Classes

- [Dropbox](Dropbox.html)
- [DropboxTeam](DropboxTeam.html)

### Dropbox

For documentation of all of the available endpoints, the parameters they receive and the data they return, see the [Dropbox class definition](http://dropbox.github.io/dropbox-sdk-js/Dropbox.html). These methods are all available directly from an instance of the API class, e.g: `dbx.filesListFolder()`.

### DropboxTeam

The Dropbox API has a series of actions that can be completed on a team wide level. These endpoint methods are available by using the DropboxTeam class. It can be loaded like this: `var DropboxTeam= require('dropbox/team');`. For more information , see the [DropboxTeam class definition](http://dropbox.github.io/dropbox-sdk-js/DropboxTeam.html).

path: /docs/tutorials/JavaScript SDK.md

filename: JavaScript SDK.md

gha_language: JavaScript


text:
## 6.0.0 (roadmap)

- [ ] action's parameter will be reversed (ctx <--> action's data)
- [ ] The targets registry should be scoped by an App. It should be possible to run independent ForrestJS apps side by side.
- [ ] Move boot trace before the App execution
- [ ] write `service-pg-pubsub` accepting `PGSTRING`
- [ ] [core] Remove `log.trace()`

## 5.0.6

- [core] deprecate `log.trace()`

## 5.0.5

- [service-logger] removed
- [service-postgres] removed
- [service-postgres-pubsub] removed
- [service-env] removed
- [service-hash] removed
- [service-fastify-gql] removed
- [package-fastify] removed

## 5.0.4

- [service-fastify] remove Ajv schema in fastify tdd

## 5.0.0

- [core] remove support for declarative array definition `const f1 = [hook, handler]`
- [core] remove `runHookApp` and `createHookApp`
- [core] remove `createHook` support
- [core] remove `registerAction` support
- [core] remove `registerHook` support
- [core] add a better default logger
- [core] support `logLevel` in App config
- [core] support `logLevel` override at Extension level
- [service-fastify] remove `FASTIFY_GET` and other methods support
- [service-fetchq] Add a fullstack test in `service-fetchq` with a task entered by a route and then a polling to monitor completion of such task
- [service-hasura-cqrs] Introduced the service
- [core] add `results.getValues()` to all the extensions returning data
- [service-logger] deprecated
- [service-postgres] deprecated
- [service-postgres-pubsub] deprecated
- [service-env] deprecated
- [service-hash] deprecated
- [service-fastify-gql] deprecated
- [package-fastify] deprecated

## 4.7.2

- [core] Improve errors for invalid actions

## 4.7.1

- [service-fetchq-task] Customize queue name via configuration
- [service-fetchq-task] Add queue configuration
- [service-fetchq-task] Add worker configuration
- [service-fetchq-task] Reset on boot
- [kitchensink] Add example for `service-fetchq-task`

## 4.7.0

- Add `service-fetchq-task`

## 4.6.0

- Require `DANGEROUSLY_ENABLE_FASTIFY_TDD_ENDPOINT=yes` env variable to explicitly enable the TDD route support
- Add `service-hasura-client`

## 4.5.0

- [service-fastify-static] Update dependencies
- [service-fastify-cors] Update dependencies
- [service-fastify-cookie] Update dependencies
- [service-fastify-gql] Update dependencies
- [service-fastify-apollo] Update dependencies
- Deprecate `service-env`
- Deprecate `service-postgres`
- Deprecate `service-postgres-pubsub`
- [core] Deprecate `registerAction([name, handler, option])`
- [core] Deprecate `registerAction(name, handler, option)`
- [core] Deprecate `registerAction()` in favor of `registerExtension()`
- [core] Deprecate the `forrest.run([ feature, feature ])`
- [service-fastify] Deprecate `$FASTIFY_GET`
- [service-fastify] Deprecate `$FASTIFY_POST`
- [service-fastify] Deprecate `$FASTIFY_PUT`
- [service-fastify] Deprecate `$FASTIFY_DELETE`
- [core] The appTrace integration goes last in `$FINISH`
- [core] Moved the App tracing log out of the `$FINISH` extension
- [core] Improve `getConfig()` error trace
- [core] Improve `getContext()` error trace
- [core] Improve `registerAction()` error trace
- [core] Improve `createExtension()` error trace

## 4.4.2

- [core] Expose all registered targets

## 4.4.1

- [pg] Add `pg` dependency to the service-pg
- [service-fastify] Add `setConfig` to the server and request instances
- [service-fastify] Add `setContext` to the server and request instances
- [service-fastify] Deprecate `registerResetHandler()` in favor of `registerTddReset()`
- [service-fastify] Improve documentation

## 4.4.0

- deprecate `service-postgres` and write `service-pg` accepting `PGSTRING`
- add `service-pg`
- add `service-pg-schema`
- add `service-jwks`
- add `service-meta`
- add `service-hasura-auth`

## 4.3.0

- [core] `createExtension` accepts referenced Target names as in `$TARGET_NAME`
- [core] deprecate `getAction` for `getTarget`
- [core] allows to register a plain Action or list of Actions
- Fix Apollo Client service

## 4.2.0

- Deprecate `createHook` for `runActions`
- Deprecate `registerAction({ hook: 'xxx' })` for `registerAction({ target: 'xxx', name: 'yyy' })`
- Deprecate `registerAction` for `registerExtension`
- Deprecate `registerHook` for `registerTargets` who always get a map of hooks to add
- Deprecate `getHook()` for `getAction()`
- Fix kitchensink/mock-axios-e2e
- Fix service order dependency in `service-fetchq` - it should work seamlessly before/after `service-fastify`

## 4.1.0

- Deprecate array based declarative features [ hook, handler, ... ]
- Deprecate `runHookApp`
- Deprecate `createHookApp`
- Handle a list of declarative hooks as a Feature manifest
- Expose `forrestjs.run()` API

## 4.0.0

- Add VSCode and Prettier config
- Start Kitchensink demo package
  - Add examples and tests for `service-fastify`
- Bumped dependencies
  - @babel/core
  - @babel/runtime
  - @babel/cli
  - concurrently
  - jest
  - lerna
  - fastify-cookie
  - fastify-cors
  - fastify-static
  - apollo-server-fastify (still doesn't work at all)
- hooks
  - Removed babel
  - Features and services names defaults are derived by their registration form and automatically prefixed
  - Added support for positional definition in `registerRoute`
  - Allows for order-independent service2service and feature2feature integration
  - Deprecate "createHook" in favor of "runHook"
- service-env
  - Remove Babel
  - Update to `setContext` API
- service-jwt
  - Remove Babel
  - Injects the `jwt` API into Fetchq's registered workers
- service-hash
  - Remove Babel
- service-fetchq
  - Upgrade to `@fetchq/node-client` v4.1.0
  - Remove Babel
  - Integrate with `service-fastify`
    - Integrate with the test healthcheck
    - Provide `/test/fetchq/query` get/post utility
    - Provide `/test/fetchq/:queue/:subject` to retrieve a document status
    - Provide `/test/fetchq/await/:queue/:subject` to await a document status with a configurable timeout
  - Provides Jest global utility functions
  - Integrate with `service-fastify-healthz`
  - Add `FETCHQ_DECORATE_CONTEXT` waterfall hook to decorate workers' context
- service-apollo
  - Remove Babel
  - Integrate with `service-fastify`
- service-logger
  - Remove Babel
  - Remove custom methods
  - Rename context's instance api to `log`
  - Improve fastify integration
  - Injects the `log` API into Fetchq's registered workers
- service-fastify
  - Fixes `$REGISTER_ROUTE` hook so to be synchronous and report injections in the boot report
  - Remove babel and the build step
  - Add extendable `/test` route for E2E test support
  - Added globals utilities for E2E testing in Jest
  - Integrates with `service-env` to provide direct access to `getEnv` in the route handlers
  - Add `FASTIFY_OPTIONS` hook that lets hijack into the `fastify.instance.options` object at run time
  - `decoreateReuest` and `decorateReply` add the relative hooks
    automatically
  - Add Moxios for stubbing HTTP requests made with Axios from the
    test environment
- service-fastify-static
  - Remove Babel
- service-fastify-cors
  - Remove Babel
- service-fastify-cookie
  - Remove Babel
- service-fastify-gql
  - Remove Babel
  - Update to 3.0.0-lambda.0
- service-fastify-healthz
  - Remove Babel
  - Add support for healtz preHandler checks
- kitchensink
  - Added examples for `@forrestjs/hooks`
  - Added examples for `@forrestjs/service-fastify`
  - Added examples for `@forrestjs/service-fastify-static`
  - Added examples for `@forrestjs/service-fastify-cors`
  - Added examples for `@forrestjs/service-fastify-cookie`
  - Added examples for `@forrestjs/service-fastify-gql`
  - Added examples for `@forrestjs/service-fastify-healthz`
  - Added examples for `@forrestjs/service-jwt`
  - Added examples for `@forrestjs/service-hash`
  - Added examples for `@forrestjs/service-fetchq`
  - Added examples for `@forrestjs/service-apollo`
  - Added examples for `@forrestjs/service-logger`
  - Added `app01` examples for a complex app

## 3.20.2

- Bumped dependencies
  - fastify
  - fastify-jwt
  - fastify-cookie
  - fastify-static
  - fastify-cors
  - apollo-server-fastify
  - @apollo/federation
  - @fetchq/pg-pubsub
  - graphql

## 3.20.0

- Bump dev libraries
- Bump Fetchq library

repository: forrestjs/forrestjs

repo_name: forrestjs/forrestjs


text:
# Phaser Clone: 1942

This is a clone of the "1942" shoot'em up game. From the tutorial ["HTML5 Shoot 'em Up in an Afternoon"](https://leanpub.com/html5shootemupinanafternoon) by Bryan Bibat.


text:
# Coursera-Data-Strucutres-Programming-Assignmet-Solutions.
## 🛑 Warning : Provided solution doesn't help in cheating. So please try before process!
### This Repositiory contains **Java** solutions of the Programming Assignment of the course "Data strucutres by UC San Diego" uploaded on Coursera.
### (https://www.coursera.org/learn/data-structures/)

### Week 1 : 5 Questions
### Week 2 : Quiz (Screenshot)
### Week 3 : 3 Questions
### Week 4 : 6 Questions
### Week 5&6 : 5 Questions

##
 **Thank You😊**


text:
title: lxc-autostart for limited users, on systemd
slug: user-lxc-autostart
date: 2015-05-07T11:43:50+0100

[lxc](https://linuxcontainers.org/) comes with a tool named `lxc-autostart` which can help you start
your containers at boot, all you have to do is set `lxc.start.auto = 1` in the config file and it will
start your containers for you... if you're running your containers as root.

For convenience and security, I'm not running my containers as root.  Normally, if I wanted to start
something on boot, as a limited user (or possibly as a service), I'd use the `cron` `@reboot` hack:

    $ crontab -l
    @reboot /usr/bin/lxc-autostart

This, however, fails for `lxc-autostart` (and for `lxc-start`, for the same reason): `cron` runs your
command in a bizarre environment which, importantly, doesn't have the user's cgroups setup properly.
These are setup somewhere scary (`pam`?), and `cron` apparently doesn't do a proper log-in for your user.
You can observe the failure with some:

    * * * * * cat /proc/self/cgroup

...which will show you have junk cgroups, which makes `lxc-start` angry with terrible, terrible errors:

    cgmanager[1041]: cgmanager:do_create_main: pid 5679 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/blkio/system.slice/autostart.service
    cgmanager[1041]: cgmanager:do_create_main: pid 5679 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/cpu/system.slice/autostart.service
    ...
    cgmanager[1041]: cgmanager: Invalid path /run/cgmanager/fs/blkio/system.slice/autostart.service/lxc/utopic
    cgmanager[1041]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/blkio/system.slice/autostart.service/lxc/utopic
    cgmanager[1041]: cgmanager: Invalid path /run/cgmanager/fs/cpu/system.slice/autostart.service/lxc/utopic
    cgmanager[1041]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/cpu/system.slice/autostart.service/lxc/utopic
    ...

The easiest way for a limited user to solve this is, as far as I'm aware, `ssh` to `localhost`.
Limited users can't configure `sudo` to be passwordless, and can't `su` without entering their password on a
proper terminal, meaning neither work from `cron`.

    $ ssh-keygen -t ed25519
    $ ssh-copy-id localhost
    $ crontab -l
    @reboot /usr/bin/ssh me@localhost /usr/bin/lxc-autostart

This was working great, until the Ubuntu Vivid upgrade, which has bought the wonders of `systemd`.

Under `systemd`, the `@reboot` entries are sometimes processed before `sshd` has started, so the above
*massive hack* fails.

    $ crontab -l
    @reboot sleep 10 && /usr/bin/ssh ...

NO.  NO NO NO.

Under `systemd`, we can write a simple service file that does the auto-start.  `systemd` understands cgroups,
so if you ask it to run a service as a `User=`, it'll run the service in the user's cgroup, right?
Nope: It runs everything in the service cgroup.  Fair enough.

However, as the service is started as root, we can use `su`.
A `systemd` service: `/etc/systemd/system/autostart.service`:

    [Unit]
    Description=lxc-autostart
    After=network.target

    [Install]
    WantedBy=multi-user.target

    [Service]
    Type=oneshot
    ExecStart=/bin/su me -c '/usr/bin/lxc-autostart'

And install it:

    $ sudo systemctl enable lxc-autostart.service

This seems to work.  I'm not sure if the `After=` is necessary;
[`network.target` is a complex beast](http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/)
but I still feel safer waiting for something to be alive.

repository: FauxFaux/blog

repo_name: FauxFaux/blog


text:
---
title: "Starting from scratch"
metaTitle: "Quick start guide"
metaDescription: "Introduces the concepts involved in building data driven apps on the Hypi platform"
---
##  Overview

It's easy to start using Hypi. Below are incremental steps that will get you moving quickly. With Hypi you can start building cloud applications and web services that just works.

### Creating an account

Navigate to hypi.app/auth/register, and create a new Hypi account. Fill in the required fields and click `complete my registration`.

`Realm name` — A namespace for all your apps, this should be unique and memorable. It cannot be changed once created and is used in URLs.

`Organisation` — Name of your company, team, group or organisation.

![Registration!](../assets/img/hypi-new-account.png)

### Creating an app

To create an app, click the `New app` button. And fill in the required fields. `App label` —  a human-friendly way to recognised your apps.`App name` — a string used as a unique identifier for your apps; cannot be changed and is used in URLs.

![New App!](../assets/img/new-app.gif)

### Creating a release
Creating a new app will trigger a release/versioning modal dialog. If it doesn't appear, go to the releases tab and click `New Release`. Fill in the required fields. `Release name` — is unique to the release being created and `Release notes`  — are an easy way to document your release/versions and can be updated anytime.

> By default `core` a system app is added as a dependency.
>
> Speed and accuracy are crucial in our modern world, which is why we designed a system app called `core`, it as a schema with essential types any app or service would need. Such as `Account`, `Person`, `Email`, `Password` and lots more.
>
> Dependencies promote software reuse by enabling you to build small reusable apps that you can add as dependencies in other apps. Learn about dependencies here.

#### Required fields
![New Release!](../assets/img/release-fields.png)
#### Adding app as a dependency
Start by searching for the app you like to use as a dependency, then select the release of that app by clicking `Add`. After saving the release, your app's release will inherit the behaviour of the dependent app that you have added.
![New Release!](../assets/img/release-dependency-search.png)

![New Release!](../assets/img/new-release.gif)

### Modelling your schema
Navigate to the editor to create your data types for a release. In Hypi, by defining types and modelling a release schema, you are actually defining the data tables for your release and building relationships between them. If you want to learn more about Graphql Schemas & Types click here.

  ![Modelling Schema!](../assets/img/modelling.gif)

### Creating an instance API

Great! Now that you have a release/version for your app,  you can quickly generate a unique API where you can post your CRUD operations and more. There are two ways to access the modal that will generate your API.

 1: Click the `New Instance` cube icon button to the right of your release. A modal will appear, type in a domain name.
 ![Instance!](../assets/img/new-instance.png)
 2: Navigate to the instance tab and click `New instance`. A modal will appear type in a domain name.
     ![Instance!](../assets/img/new-instance.gif)

### Querying your instance API

Here's the fun part! You can start querying your APIs instantly by clicking on the `API editor` icon button to the right of your domain. In the editor, you can run any GraphQL query on the left and see results instantly on the right. Also, take advantage of the editor's inspection tabs `Docs`  and `Schema`.
  ![Api Editor!](../assets/img/api-editor.png)
  ![API Request!](../assets/img/api-request.gif)

### Next steps
Learn how to add Hypi to your front end client using your favourite front-end client here. Also, see  Hypi's Graphql CRUD tutorial here.

![Front-end frameworks!](../assets/img/frontend-framework.png)

repository: mustafa-qamaruddin/docs

repo_name: mustafa-qamaruddin/docs


text:
[![Generic badge](https://img.shields.io/badge/M.ver-1-red.svg)](#mver1) **The source code must be version controlled using [Git](https://git-scm.com).**

>Rationale
>: Version control is essential for collaborative development and change tracking. Git is the most popular version control system by a wide margin, many sophisticated web-based collaboration tools are available for it, and new developers will be immediately productive in your Git repository.
>
>Ref
>: *WSC 2.1*
>
>Tag
>: Tools

---

[![Generic badge](https://img.shields.io/badge/M.ver-2-red.svg)](#mver2) **Provide a transparent, online contribution process based on pull requests and issues collection. The preferred platform is [GitHub](https://github.com).**

>Rationale
>: GitHub is one of the most-used repositories of open-source software that includes collaboration tools such as issue tracking, pull requests, and wikis. Pull requests allow project maintainers to review changes, comment, and iterate with developers before new features are committed to a code base. Pull requests and branching simplify management of large numbers of contributions (particularly contributions across teams), and they enable many features to be developed concurrently. The product maintainer can review code and associated test results before merging it into a public branch. Pull requests can also be linked to GitHub issues, which can be created by anyone.
>
>Ref
>: *Enforce WSC 2.3, 2.4, part of [xSDK M10](https://github.com/xsdk-project/xsdk-community-policies/blob/master/package_policies/M10.md) and [R1](https://github.com/xsdk-project/xsdk-community-policies/blob/master/package_policies/R1.md).*
>
>Tag
>: Tools

---


text:
# React Carousel Liron
A responsive carousel for react that is very easy to use.
Comes with a simple fading animation between slides.
You can also have auto cycling between slides by adding some props.

### Features
* Responsive
* Mobile friendly
* Custom auto play interval
* Stop play when mouse inside carousel and continue auto play when mouse outside the carousel
* Infinite loop
* Supports images , text content or anything you want.
* Each direct child represents one slide.
* Supports previuos/next
* Custom active slide

### Installing as a package
`npm i react-carousel-liron --save`

### Usage
```javascript
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Carousel from 'react-carousel-liron';
class DemoCarousel extends Component {
  render() {
    return (
      <div className="container">
        <Carousel>
            <div>
                <img src="assets/someimage1.jpg" />
                <h1>some text 1</h1>
                <p>some paragraph text 1</p>
            </div>
            <div>
                <img src="assets/someimage2.jpg" />
                <h1>some text 2</h1>
                <p>some paragraph text 2</p>
            </div>
        </Carousel>
      </div>
    );
  }
}
ReactDOM.render(<DemoCarousel />, document.querySelector('.demo-carousel'));
```

# API
### Carousel
```javascript
import Carousel from 'react-carousel-liron'
```
Name |Type |Default |Description
---- | --- | ------ | ----------
timer | number | null | The amount of time to delay between automatically cycling an item. If *null*, carousel will not automatically cycle
selectedIndex | number | 0 | Controls the current visible slide

### Demo
https://codesandbox.io/s/1o5lmx9kjj

repository: LironWeiner/react-carousel-liron

repo_name: LironWeiner/react-carousel-liron


text:
---
versionFrom: 8.0.0
versionTo: 10.0.0
---

# Circular Dependencies

In some cases you might experience that a circular dependency is preventing your Umbraco installing from starting up.

An example of this, could be a circular dependency on `IUmbracoContextFactory`, which would happen if your service interacts with third party code that also depends on an `IUmbracoContextFactory` instance.

In this situation, you can request a lazy version of the dependency so it won't evaluate during boot, and would only be evaluated when accessed:

```csharp
public class SiteService : ISiteService
{
    private readonly Lazy<IUmbracoContextFactory> _umbracoContextFactory;
    public SiteService(Lazy<IUmbracoContextFactory> umbracoContextFactory)
    {
        _umbracoContextFactory = umbracoContextFactory;
    }
     public IPublishedContent GetNewsSection()
    {
         using (UmbracoContextReference umbracoContextReference = _umbracoContextFactory.Value.EnsureUmbracoContext())
         {
             // Do your thing
         }
    }
}
```

repository: umbraco/UmbracoDocs

repo_name: umbraco/UmbracoDocs


text:
---
title: "Httpoxy - Proxy Header Misuse"
alertid: 10107
alertindex: 1010700
alerttype: "Active"
alertcount: 1
status: beta
type: alert
risk: High
solution: "The best immediate mitigation is to block Proxy request headers as early as possible, and before they hit your application."
references:
   - https://httpoxy.org/
other: ""
cwe: 20
wasc: 20
alerttags:
  - OWASP_2017_A09
  - OWASP_2021_A06
code: https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrulesBeta/src/main/java/org/zaproxy/zap/extension/ascanrulesBeta/HttPoxyScanRule.java
linktext: "org/zaproxy/zap/extension/ascanrulesBeta/HttPoxyScanRule.java"
---
The server initiated a proxied request via the proxy specified in the HTTP Proxy header of the request.Httpoxy typically affects code running in CGI or CGI like environments.
This may allow attackers to:
* Proxy the outgoing HTTP requests made by the web application
* Direct the server to open outgoing connections to an address and port of their choosing or
* Tie up server resources by forcing the vulnerable software to use a malicious proxy

repository: zaproxy/zaproxy-website

gha_language: HTML

repo_name: zaproxy/zaproxy-website


text:
# Statistics Survival Kit

This is a Statistics survival kit for GITM students @Epita.

The course aims at giving a practical knowledge of basic statistics
for descriptive data analysis and elementary hypothesis testing. It is
structured around the following themes:

  - Descriptive Statistics;
  - Statistical Inference;
  - Hypothesis Testing;
  - Linear correlation.

References for the course include:

  - Introductory Statistics with R - P Dalgaard.
  - Introduction to Scientific Programming and Simulation Using R - O. Jone and Al.


text:
---
layout: post
title: "LQ Vol 2 Issue 4 Article 1: Reading Study"
date: 2013-11-25 16:20
comments: true
categories: [LQ Autoethno Field Notes, research, Author-Waples, Author-Carnovsky, Author-Randall, Affil-University of Chicago]
---

For an explanation of this post, see:
[Preface](/blog/2013/08/14/lq-autoethnography-research-journal-preface/)

---

This entry is about:

Waples, Douglas, Carnovsky, Leon, & Randall, William M.
(1932). The Public Library in the Depression. *The Library
Quarterly, 2*(4), 321-343.
url:[http://www.jstor.org/stable/4301919](http://www.jstor.org/stable/4301919)

---

**Note:** The first article of the fourth issue of the second
volume of *The Library Quarterly* is titled "The Public Library in
the Depression."

It was *prepared* by Douglas Waples, Leon Carnovsky, and William
M. Randall, who were affiliated with:

**Affiliation:** University of Chicago

**Note:** I use the word *prepared* above because this article has
no official author. Instead, the first footnote states the
following, as a footnote to the title of the article:

> This article was prepared by Douglas Waples, Leon Carnovsky, and
> William M. Randall from data collected by the *Library
> quarterly* (p. 321).

I feel, then, as if I'm violating something (perhaps a rule) by
explicitly placing Waples, Carnovsky, and Randall's names in the
reference above. It's as if the *Library Quarterly* itself is the
author of this piece (supposed corporate authorship?). However,
according to the [index](http://www.jstor.org/stable/4301917) for
the volume, these three men are listed as the authors. Randall, it
should be noted, is the journal's managing editor.

**Note:** Aside from the authorship issue, given the topic of this
article and the recent recession, this should make for a really
interesting piece.

To get started:

> First, decreased revenues from taxation have resulted in smaller
> appropriations for library purposes (p. 321).

Huh, sounds current.

> The second respect in which the library has felt the effects of
> the depression is in the increased service the library is called
> upon to render (p. 322).

That also sounds current.

And then this:

> We read that people out of work are spending more time either in
> reading for recreation - to "kill time" - or in reading
> seriously, to learn the fundamental economics involved in the
> depression or to acquire new educational equipment in the hope
> of improving their chances for a new job (p. 322).

And this, the reaction, sounds current:

> Small wonder, then, that the leaders in the profession have
> raised the cry against drastic reductions in library
> acquisitions, for seldom before has the library stood out so
> sharply as a source of individual hope and social amelioration
> (p. 322).

**Note:** This is a good question / assumption to highlight:

> Theoretically, if library service is to remain constant, the
> library appropriation should be actually increased (p. 325).

**Note:** Lots of relevant (to today) questions being explored in
this piece -- about collections, service, salaries, buildings, and
so on. I'll leave that out of these notes, but this is a nice
piece of wisdom, I think:

> The foregoing data should interest the librarian in so far as he
> can place his own institution in the general picture. But such
> orientation demands a knowledge of local conditions affecting
> other libraries like his own. Without such knowledge it does him
> little good to know whether or not the other libraries are
> effecting the same economies. The fact that other libraries of
> the same size and type are reducing the same items of expense in
> the same proportion does not in itself show whether his own
> budgeting is wise or unwise (p. 337).

The questions raised in the paragraph following the above passage
are brilliant.

**Note:** My goodness, this sounds like the ROI literature of
today:

> Library officials will be forced, as never before in this
> country, to rest their claims for appropriations, not upon
> sentimental appeals, but upon the sort of evidence that city
> officials obtain from other departments. Library development may
> easily receive a permanent setback if, when called to account,
> the profession cannot demonstrate, specifically and
> convincingly, the nature and scope of its service (p. 338).

**Note:** This article continues to be brilliant.

**Note:** On not being trivial (this is also brilliant):

> Most librarians testify to large increases in economics,
> sociology, political science, and history. But what are we to
> conclude? That the muddle which politics has made of economics
> is driving men to John Stuart Mill and his peers for
> consolation, that the reading is mostly current history of the
> [Charles A.
> Beard](https://en.wikipedia.org/wiki/Charles_A._Beard) type, or
> that the readers are at last taking the crisis seriously enough
> to read forthright explanations of it in [Stuart
> Chase](https://en.wikipedia.org/wiki/Stuart_Chase),
> [Laidler](https://en.wikipedia.org/wiki/Harry_W._Laidler), and
> the unfettered spokesman of the left (p. 341)?

**Note:** This is fascinating (it immediately follows the above
paragraph:

> The writer has checked a list of the better-known left-wing
> writers against the catalogues of two city libraries and found
> them very poorly represented. The problem of censorship involved
> here is incidentally a matter of critical importance to public
> confidence in the library (p. 341).

**Reflection:** This is simply one of the best articles I've read.
Waples, Carnovsky, and Randall deserve their status as
intellectual giants in library science.

repository: cseanburns/research-notebook

extension: markdown

repo_name: cseanburns/research-notebook


text:
Development Workflow
====================

```bash
# Setup local dependencies and repo for work
npm run setup

# See what commands you can run
npm start
```

To simplify workspace development and maintenance we provide an interactive menu via `npm start` which lists all the commands you can run. You can type to filter the list and hit ENTER to run. Each command invokes a [Nx](https://nx.dev) workspace command which you can even copy/paste to run directly if you don't want to use the interactive menu any longer.

## Initial Setup

Clone (or fork/clone) the repo and run setup script:

```bash
git clone https://github.com/NativeScript/NativeScript.git
cd NativeScript
npm run setup
```

## Unit Testing

### Run unit tests with jest with either option:

A. Using convenient start menu:

```bash
npm start
> (Type) "core.test" (...to isolate the menu to "@nativescript.core.test"), hit ENTER
```

B. Using direct Nx command:

```bash
npx nx run core:test
```

### Watch mode

To enable live watch mode you can add the `--watch` flag, for example:

```bash
npx nx run core:test --watch
```

### Isolate tests by name

Run a single test by it's describe name, for example to run just the `xml/index.spec.ts`, the describe block is named `XmlParser` therefore:

```
npx nx run core:test --watch -t 'XmlParser'
```

## Running the `e2e` Test Apps

There are a couple of application used for development and testing.
* `apps/automated` Automated e2e tests
* `apps/toolbox` Used for local development experimentation and confirming cases. More simplistic, use this one most often.
* `apps/ui` Also used for local development experimentation and confirming cases. More sophisticated setup.

Run automated e2e test suite with:

```bash
npx nx run apps-automated:ios

// or...

npx nx run apps-automated:android
```

# Documentation API reference

The following will build the API reference pages in `bin/dist/apiref`:

```bash
npm run typedoc
```

If you want to improve on the documentation you can also build and start up dev web server:

```bash
npm run dev-typedoc
```

The terminal will point the address you can open in your web browser.

repository: NativeScript/NativeScript

gha_language: TypeScript

repo_name: NativeScript/NativeScript


text:
# Qiniu Uploader for Python
[中文介绍](http://inspoy.cc/wordpress/index.php/46.html)

## Descirption
A tool with GUI which can upload files to Qiniu conveniently.

## Requirement
### Python
Developed by python2.7

### qiniu module
You can install that easily by `pip install qiniu`

## Usage
1. Get your keys from the [qiniu portal](https://portal.qiniu.com/user/key)
2. Put your **Access Key** and **Secret Key** into the key.txt
3. Fill in your **Bucket Name** and **Domain Prefix**(like www.xxx.com/pic) into the key.txt
4. Double-click the qiniuUploader.pyw
5. Choose your file to upload and click **Upload** button
6. Copy the external link from **Output**
7. Enjoy it~ XD

## Hint
* Test pass in Windows 10
* macOS should also be supported

##LICENSE
MIT License

Copyright (c) 2016 Inspoy Cheng

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

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

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


text:
# Versioning and releasing

OpenTelemetry Auto-Instrumentation for Java uses [SemVer standard](https://semver.org) for versioning of its artifacts.

Instead of manually specifying project version (and by extension the version of built artifacts)
in gradle build scripts, we use [nebula-release-plugin](https://github.com/nebula-plugins/nebula-release-plugin)
to calculate the current version based on git tags. This plugin looks for the latest tag of the form
`vX.Y.Z` on the current branch and calculates the current project version as `vX.Y.(Z+1)-SNAPSHOT`.

## Snapshot builds
Every successful CI build of the master branch automatically executes `./gradlew snapshot` as the last task.
This signals Nebula plugin to build and publish to
[Sonatype OSS snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/)
next _minor_ release version. This means version `vX.(Y+1).0-SNAPSHOT`.

## Starting the Release

Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/release-build.yml).

You will see a button that says "Run workflow". Press the button, enter the version number you want
to release in the input field that pops up, and then press "Run workflow".

This triggers the release process, which builds the artifacts, publishes the artifacts, and creates
and pushes a git tag with the version number.

## Announcement

Once the GitHub workflow completes, go to Github [release
page](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases), press
`Draft a new release` to write release notes about the new release. If there is already a draft
release notes, just point it at the created tag.

## Patch Release

All patch releases should include only bug-fixes, and must avoid
adding/modifying the public APIs.

Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/patch-release-build.yml).

You will see a button that says "Run workflow". Press the button, enter the version number you want
to release in the input field for version that pops up and the commits you want to cherrypick for the
patch as a comma-separated list. Then, press "Run workflow".

If the commits cannot be cleanly applied to the release branch, for example because it has diverged
too much from main, then the workflow will fail before building. In this case, you will need to
prepare the release branch manually.

This example will assume patching into release branch `v1.2.x` from a git repository with remotes
named `origin` and `upstream`.

```
$ git remote -v
origin	git@github.com:username/opentelemetry-java.git (fetch)
origin	git@github.com:username/opentelemetry-java.git (push)
upstream	git@github.com:open-telemetry/opentelemetry-java.git (fetch)
upstream	git@github.com:open-telemetry/opentelemetry-java.git (push)
```

First, checkout the release branch

```
git fetch upstream v1.2.x
git checkout upstream/v1.2.x
```

Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit.
Use a commit message such as "Manual cherrypick for commits commithash1, commithash2".

After committing the change, push to your fork's branch.

```
git push origin v1.2.x
```

Create a PR to have code review and merge this into upstream's release branch. As this was not
applied automatically, we need to do code review to make sure the manual cherrypick is correct.

After it is merged, Run the patch release workflow again, but leave the commits input field blank.
The release will be made with the current state of the release branch, which is what you prepared
above.

repository: XiaoMi/mone

gha_language: Java

repo_name: XiaoMi/mone


text:
# Game2048
Build game2048 by yourself.
Written in C++ and tested in XCode.

## Disclaimer
This code is posted for informational purposes only. If you feel this code fails to obey your company's terms & policy or any law, contact me at<EMAIL_ADDRESS>
Use this code at your own risk.

If you find any bug in running the code, free feel to contact me at<EMAIL_ADDRESS>I will make effect to fix it, but I cannot guarantee the fix in time. It is possible the code won't work any more if changes occur to the instagram website design.

## Code Purpose
Build and play the game2048.

## Installation

This game is written in C++ and I have tested in XCode 6.2 (6C131e) on Mac OSX 10.10.3 without any issue.

SFML (www.sfml-dev.org) library is required.

## License

Copyright (c) 2015 Chi Gao. See the LICENSE file for license rights and limitations (MIT).


text:
Overload Resolution
===================

Besides the small overload resolution changes to the C# language spec in C# 6, the Roslyn C# compiler implements some overload resolution rules not in the specification in order to behave in a way compatible with the (pre C# 6) native compiler. These changes are supported by unit tests in `OverloadResolutionTests.cs` and `OperatorTests.cs`.

Here are some of the changes

### No conversion from old-syntax anon delegate to expression tree

Like the native compiler, Roslyn C# will not convert an old-style anonymous method expression to an expression tree.

```cs
using System;
using System.Linq.Expressions;
class Program
{
    static void Main()
    {
        Foo(delegate { }); // No error; chooses the non-expression version.
    }
    static void Foo(Action a) { }
    static void Foo(Expression<Action> a) { }
}
```

### Enum operator -

The native compiler had some odd behavior around the subtraction operator on enum types. These are unlikely to affect real code, but we reproduce them to ensure we don't break programs by changing their behavior.

The old compiler implemented the built-in operator

```cs
	E operator-(I, E)
```

where `E` is an enum type with underlying type `I`.

A precise reading of the spec suggests that, for an enum variable `e` where the enum's underlying type is not int, the expression `e - 0` is ambiguous (the 0 can be converted to either the enum type or the underlying type, but neither conversion is an exact match). We resolve the ambiguity the same as the old compiler did.

You can turn off these compatibility features using the compiler flag
/features:strict

### Tie-breaking rule with multiple interface inheritance

The old compiler implemented special rules for overload resolution (not in the language specification) in the presence of optional and `params ` parameters, and Roslyn's more strict interpretation of the specification (now fixed) prevented some programs from compiling.

Specifically, a problem occurred if two extension methods with the same name are implemented on different interfaces, and both interfaces are extended by one single interface, called e.g. `IFinalInterface`, so that this interface contains two extension methods with the same name.

The first extension method has a `params int[]` as parameter:

```cs
public static int Properties(this IFirstInterface source, params int[] x)
{
    return 0;
}
```

The second extension method has an additional optional parameter:

```cs
public static bool Properties(this ISecondInterface source, int x = 0, params int[] y)
{
return true;
}
```

Now, the following call would cause an ambiguous error:

```cs
var x = default(IFinalInterface);
var properties = x.Properties();
```

See #2298 for more details, and #2305 for the implementation and tests that enable Roslyn to compile this code.

### Tie-breaking rule with unused param-array parameters

The old compiler implemented special rules for overload resolution (not in the language specification) in the presence of unused param-array parameters, and Roslyn's more strict interpretation of the specification (now fixed) prevented some programs from compiling.

Specifically, a problem occurred if two methods have the same parameter types with exception of param-array types, and an attempt is made to call them without supplying any arguments for param-array parameter.

```
public class Test
{
    public Test(int a, params string[] p) { }
    public Test(int a, params List<string>[] p) { }
}
```

Now, the following call would cause an ambiguous error:

```
var x = new Test(10);
```

Old compiler calls the second overload (```Test(int a, params List<string>[] p)```)

See https://github.com/dotnet/roslyn/issues/4458 for more details, and https://github.com/dotnet/roslyn/issues/4761 for the implementation and tests that enable Roslyn to compile this code.

### Compiler won't lift asymmetric `operator==` and `operator!=`

The C# compiler (all versions) won’t lift user-defined equality operators

``` c#
public static bool operator ==(Type1 x, Type2 y)
public static bool operator !=(Type1 x, Type2 y)
```

unless `Type1` and `Type2` are identical types. The spec requires all user-defined equality operators defined on value types to also be considered in lifted form, so this is technically a spec violation.  We believe that fixing this longstanding behavior might break some programs, so we do not expect to change it.

See https://github.com/dotnet/roslyn/issues/13686 for more details.

repository: dotnet/roslyn

filename: Overload Resolution.md

gha_language: C#

repo_name: dotnet/roslyn


text:
### New features

* [#547](https://github.com/rubocop/rubocop-rails/pull/547): Add new `Rails/ActionOrder` cop. ([@mollerhoj][])
* [#565](https://github.com/rubocop/rubocop-rails/issues/565): Add cop Rails/WhereNotWithMultipleConditions. ([@niklas-hasselmeyer][])
* [#771](https://github.com/rubocop/rubocop-rails/pull/771): Add new `Rails/IgnoredColumnsAssignment` cop. ([@fsateler][], [@kkitadate][])
* [#790](https://github.com/rubocop/rubocop-rails/issues/790): Make `Style/HashExcept` aware of TargetRubyVersion: 2.x because Rails has `Hash#except`. ([@koic][])

### Bug fixes

* [#786](https://github.com/rubocop/rubocop-rails/issues/786): Fix a false negative for `Rails/ActionControllerTestCase` when extending `ActionController::TestCase` and having a method definition. ([@koic][])
* [#792](https://github.com/rubocop/rubocop-rails/issues/792): Fix a false negative for `Rails/RedundantPresenceValidationOnBelongsTo` when belongs_to at least one block and one hash like `belongs_to :company, -> { where(foo: true) }, inverse_of: :employee`. ([@PedroAugustoRamalhoDuarte][])
* [#781](https://github.com/rubocop/rubocop-rails/issues/781): Make `Rails/DynamicFindBy` aware of `find_by_token_for`. ([@koic][])
* [#809](https://github.com/rubocop/rubocop-rails/issues/809): Fix an error for `Rails/FreezeTime` when using `travel_to` without argument. ([@koic][])
* [#794](https://github.com/rubocop/rubocop-rails/issues/794): Fix an error for `Rails/RedundantReceiverInWithOptions` when calling a method with a receiver in `with_options` without block arguments. ([@koic][])
* [#782](https://github.com/rubocop/rubocop-rails/issues/782): Fix an incorrect autocorrect for `Rails/EagerEvaluationLogMessage` when using `Style/MethodCallWithArgsParentheses`'s autocorrection together. ([@koic][])
* [#776](https://github.com/rubocop/rubocop-rails/issues/776): Fix an incorrect autocorrect for `Rails/Presence` when using arithmetic operation in `else` branch. ([@koic][])
* [#813](https://github.com/rubocop/rubocop-rails/pull/813): Fix errors that occur when unrelated `tag` is investigated by `Rails/ContentTag`. ([@r7kamura][])
* [#808](https://github.com/rubocop/rubocop-rails/issues/808): Fix false positive for `Rails/ActionControllerFlashBeforeRender` when `render` call precedes `flash` call. ([@americodls][])
* [#778](https://github.com/rubocop/rubocop-rails/issues/778): Fix a false positive for `Rails/DynamicFindBy` when using `page.find_by_id` as a Capybara testing API. ([@koic][])
* [#816](https://github.com/rubocop/rubocop-rails/pull/816): Fix an incorrect autocorrect for `Rails/Presence` when a right-hand side of the relational operator. ([@ydah][])

### Changes

* [#779](https://github.com/rubocop/rubocop-rails/issues/779): Add `mail` to `AllowedMethods` of `Style/SymbolProc`. ([@koic][])
* [#796](https://github.com/rubocop/rubocop-rails/issues/796): Add several directories to `Exclude` to prevent slow investigation. ([@koic][])
* [#822](https://github.com/rubocop/rubocop-rails/issues/822): Extends `Rails/HttpStatus` cop to check `routes.rb`. ([@anthony-robin][])
* [#787](https://github.com/rubocop/rubocop-rails/issues/787): Make `Rails/Pluck` aware of all keys. ([@koic][])
* [#800](https://github.com/rubocop/rubocop-rails/issues/800): Make `Rails/TimeZone` aware of timezone UTF offset. ([@inkstak][])

[@mollerhoj]: https://github.com/mollerhoj
[@niklas-hasselmeyer]: https://github.com/niklas-hasselmeyer
[@fsateler]: https://github.com/fsateler
[@kkitadate]: https://github.com/kkitadate
[@koic]: https://github.com/koic
[@PedroAugustoRamalhoDuarte]: https://github.com/PedroAugustoRamalhoDuarte
[@r7kamura]: https://github.com/r7kamura
[@americodls]: https://github.com/americodls
[@ydah]: https://github.com/ydah
[@anthony-robin]: https://github.com/anthony-robin
[@inkstak]: https://github.com/inkstak

gha_language: Ruby


text:
---
path: '/Big-O-Notation'
cover: '../Programming-Foundations-Coding-Efficiency/speed.jpg'
slug: 'Big-O-Notation'
date: '2019-04-20'
title: 'Big O Notation'
tags: ['Big O Notation', 'time complexity']
published: true
---

### Space complexity
Aamount of storage space for the function and how that changes relative to input size.

### Time complexity
Measure of time / performance, calculated by the number of steps or operations taken in a function, and how that changes relative to size of input.

### Rules:

  1) If an algorithm has more than one time complexity involved, the lowest performing complexity is the one used to describe the algorithm - if you have one function that runs in _O(n)_ time and another that runs in _O(n log n)_ time and they work together to form an algorithm, the algorithm is said to be _O(n log n)_ - assuming that the same _n_ is used in both.

  2) Constants get dropped (for the most part).  In the big picture sense, an algorithm that runs a for loop twice (_O(2n)_) vs an algorithm that runs a for loop three times (_O(3n)_) both equate to _O(n)_.  However, when dealing with time/performance pressure, the constants will matter, so it's good to be mindful of them even if you don't take them into account during Big O analysis

  3) If an algorithm works on different inputs, each input has to be evaluated separately for Big O.

### Examples for Rule 3:

```
  function summingTwoArrays(a, b) {
    let sum = 0;
    for (let i = 0; i < a.length; i++) {
      sum += a[i];
    }
    for (let j = 0; j < b.length; j++) {
      sum += b[i];
    }
  }
```
In this `summingTwoArrays` function, each for loop works on every element of a given array independent of one another.  Because they are different input and can't be simplified, we would characterize the Big O to be _O(n + m)_ because it is _O(n)_ and then _O(m)_ and we have to add those together to get the time complexity.

```
  function bothContainNumber(a, b) {
    for (let j = 0; j < a.length; j++) {
      for (let i = 0; i < b.length; i++) {
        if (a[j] === b[i]) {
          return true;
        }
      }
    }
    return false;
  }
```
In `bothContainNumber`, we operate on both inputs nested together so that for every instance of an element in one input, we loop through the other input in its entirety.  While it might be tempting to call this _O(n2)_, for the same reasons as our earlier example, each input has to be regarded separately, giving this the Big O of _O(nm)_.

### Time Complexities:

**_O(1)_** - AKA: **Constant time**

- The amount of steps/operations a function takes is independent from the size of the input

**_O(log n)_** - AKA: **Logarithmic time**

- As the function progresses, the number of steps is halfed

**_O(n)_** - AKA: **Linear time**

- The amount of steps/operations is directly related to the size of the input

**_O(n log n)_** - AKA: **Log-linear/Linearithmic**

- Requires iterating over every element of the input and then the number of steps is halfed each iteration

**_O(n2)_** - AKA: **N-squared/Quadratic time**

- The number of operations taken by a function is the square of the input size

**_O(cn)_** - AKA: **Exponential**

- `c` represents a constant greater than 1 and `n` still represents input size

**_O(n!)_** - AKA: **Factorial**

- Given an input size of 5, the number of steps/ops taken would be calculated as `5 * 4 * 3 * 2 * 1`

### O(1) - Constant time example
```
function isFirstElementEven(arr) {
  return arr[0] % 2 === 0;
}

isFirstElementEven([10,2,1])
```

### O(log(n)) - Logarithmic time example

#### Function
```
function findNeedleInSortedHaystack(needle, haystack) {
  let length = haystack.length;
  let mid = Math.floor(length/2);
  let currentPosition = 0;
  let count = 0;
  let currentPositions = [];
  let answer;
  while (mid > 0) {

    while ((currentPosition + mid) < length && haystack[currentPosition + mid] <= needle) {
      count++;
      console.log('currentPosition', currentPosition, 'mid', mid)
      currentPositions.push(currentPosition);
      currentPosition += mid;
    }
    mid = Math.floor(mid/2);
    if (haystack[currentPosition] === needle) {
        break;
      }
  }
  count++;
  currentPositions.push(currentPosition);

  console.log('currentPosition', currentPosition, 'mid', mid)
  if (haystack[currentPosition] === needle) {
    answer = currentPosition;
    return { '# of loops in while': count, 'list of positions': currentPositions, 'size of input': length, 'percentage of array input accessed': `${(count / length) * 100}%`}
  }
}

findNeedleInSortedHaystack(100, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])
```

#### Console Output:
```
currentPosition 0 mid 50
currentPosition 50 mid 25
currentPosition 75 mid 12
currentPosition 87 mid 12
currentPosition 99 mid 6
=> { '# of loops in while': 5,
  'list of positions': [ 0, 50, 75, 87, 99 ],
  'size of input': 100,
  'percentage of array input accessed': '5%' }
```

### O(n) - Linear time example

#### Function:
```
function reverseString(n) {
  let reversed = "";
  let count = 0;
  for (let i = n.length - 1; i >= 0; i--) {
    reversed += n[i];
    count++;
    console.log('reversed', reversed)
    console.log('count', count)
  }
  console.log('size of input', n.length)
  return {'# of loops of i': count, 'size of input': n.length}
}

reverseString("Wobblewobble")
```

#### Console Output:
```
reversed e
count 1
reversed el
count 2
reversed elb
count 3
reversed elbb
count 4
reversed elbbo
count 5
reversed elbbow
count 6
reversed elbbowe
count 7
reversed elbbowel
count 8
reversed elbbowelb
count 9
reversed elbbowelbb
count 10
reversed elbbowelbbo
count 11
reversed elbbowelbboW
count 12
size of input 12
=> { '# of loops of i': 12, 'size of input': 12 }
```

### Advice: Not all Nested Loops are Quadratic

#### Example with nested loops that doesn't equate to n^2:

Some people consider this to be O(n) because they're counting each element in the matrix as a part of a single 'n' and you only access each element once.

Others consider it O(nm) where n is number of rows and m is number of columns

#### Function:
```
function nWithNesting(matrix) {
  let count = [0,0];
  let rows = [];
  for (let i = 0; i < matrix.length; i++) {
    ++count[0];
    for (let j = 0; j < matrix.length; j++) {
      ++count[1];
      if (count[1] < 10) {
        console.log('count', count, '\t\ti', i, 'j', j);
      } else {
        console.log('count', count, '\ti', i, 'j', j);
      }

    }
    console.log('\n')
  }

  return { '# of loops of i': count[0], '# of total loops': count[1], 'size of input': matrix.length * matrix.length}
}

let matrix = [
  [,,2,6,,,3,4,],
  [,5,1,,9,4,8,2,],
  [,,,,2,1,,,6],
  [,3,,,8,,6,,],
  [4,6,,,,,,8,2],
  [,,5,,6,,,9,],
  [3,,,8,7,,,,],
  [,1,8,2,4,,7,6,],
  [,9,4,,,6,2,,]
]

console.log(nWithNesting(matrix))
```

#### Console Output
```
count [ 1, 1 ] 		i 0 j 0
count [ 1, 2 ] 		i 0 j 1
count [ 1, 3 ] 		i 0 j 2
count [ 1, 4 ] 		i 0 j 3
count [ 1, 5 ] 		i 0 j 4
count [ 1, 6 ] 		i 0 j 5
count [ 1, 7 ] 		i 0 j 6
count [ 1, 8 ] 		i 0 j 7
count [ 1, 9 ] 		i 0 j 8

count [ 2, 10 ] 	i 1 j 0
count [ 2, 11 ] 	i 1 j 1
count [ 2, 12 ] 	i 1 j 2
count [ 2, 13 ] 	i 1 j 3
count [ 2, 14 ] 	i 1 j 4
count [ 2, 15 ] 	i 1 j 5
count [ 2, 16 ] 	i 1 j 6
count [ 2, 17 ] 	i 1 j 7
count [ 2, 18 ] 	i 1 j 8

count [ 3, 19 ] 	i 2 j 0
count [ 3, 20 ] 	i 2 j 1
count [ 3, 21 ] 	i 2 j 2
count [ 3, 22 ] 	i 2 j 3
count [ 3, 23 ] 	i 2 j 4
count [ 3, 24 ] 	i 2 j 5
count [ 3, 25 ] 	i 2 j 6
count [ 3, 26 ] 	i 2 j 7
count [ 3, 27 ] 	i 2 j 8

count [ 4, 28 ] 	i 3 j 0
count [ 4, 29 ] 	i 3 j 1
count [ 4, 30 ] 	i 3 j 2
count [ 4, 31 ] 	i 3 j 3
count [ 4, 32 ] 	i 3 j 4
count [ 4, 33 ] 	i 3 j 5
count [ 4, 34 ] 	i 3 j 6
count [ 4, 35 ] 	i 3 j 7
count [ 4, 36 ] 	i 3 j 8

count [ 5, 37 ] 	i 4 j 0
count [ 5, 38 ] 	i 4 j 1
count [ 5, 39 ] 	i 4 j 2
count [ 5, 40 ] 	i 4 j 3
count [ 5, 41 ] 	i 4 j 4
count [ 5, 42 ] 	i 4 j 5
count [ 5, 43 ] 	i 4 j 6
count [ 5, 44 ] 	i 4 j 7
count [ 5, 45 ] 	i 4 j 8

count [ 6, 46 ] 	i 5 j 0
count [ 6, 47 ] 	i 5 j 1
count [ 6, 48 ] 	i 5 j 2
count [ 6, 49 ] 	i 5 j 3
count [ 6, 50 ] 	i 5 j 4
count [ 6, 51 ] 	i 5 j 5
count [ 6, 52 ] 	i 5 j 6
count [ 6, 53 ] 	i 5 j 7
count [ 6, 54 ] 	i 5 j 8

count [ 7, 55 ] 	i 6 j 0
count [ 7, 56 ] 	i 6 j 1
count [ 7, 57 ] 	i 6 j 2
count [ 7, 58 ] 	i 6 j 3
count [ 7, 59 ] 	i 6 j 4
count [ 7, 60 ] 	i 6 j 5
count [ 7, 61 ] 	i 6 j 6
count [ 7, 62 ] 	i 6 j 7
count [ 7, 63 ] 	i 6 j 8

count [ 8, 64 ] 	i 7 j 0
count [ 8, 65 ] 	i 7 j 1
count [ 8, 66 ] 	i 7 j 2
count [ 8, 67 ] 	i 7 j 3
count [ 8, 68 ] 	i 7 j 4
count [ 8, 69 ] 	i 7 j 5
count [ 8, 70 ] 	i 7 j 6
count [ 8, 71 ] 	i 7 j 7
count [ 8, 72 ] 	i 7 j 8

count [ 9, 73 ] 	i 8 j 0
count [ 9, 74 ] 	i 8 j 1
count [ 9, 75 ] 	i 8 j 2
count [ 9, 76 ] 	i 8 j 3
count [ 9, 77 ] 	i 8 j 4
count [ 9, 78 ] 	i 8 j 5
count [ 9, 79 ] 	i 8 j 6
count [ 9, 80 ] 	i 8 j 7
count [ 9, 81 ] 	i 8 j 8

{ '# of loops of i': 9,
  '# of total loops': 81,
  'size of input': 81 }
```

### Another example where nested loops !== O(n^2)

#### Function:
```
function printCurrentNum(arr) {
  let count = 0;
   for (let i = arr; i > 0; i--) {
    for (let j = i; j < arr; j++) {
        ++count;
      }
   }
    console.log('count', count)
}
printCurrentNum(9);
```

#### Console Output
```
count 36
```

### O(n log(n)) - Linearithmic/Log-linear example
This is the best time complexity achievable by comparison-based sorting algorithms.

#### Function
```
let length;
function quickSort(nums) {
   console.count('Number of times quickSort is called');
  if (!length) {
    length = nums.length;
  }
  if (nums.length <= 1) return nums;

  const pivot = nums[nums.length - 1];
  let left = [];
  let right = [];
   console.log('lengthOfInput:', length);
  for (let i = 0; i < nums.length - 1; i++) {
    console.count('Number of times an index is accessed in a for loop');

    if (nums[i] < pivot) {
      left.push(nums[i]);
    } else {
      right.push(nums[i]);
    }
  }
  console.log('right', right, 'left', left);
  return [...quickSort(left), pivot, ...quickSort(right)];
}

console.log(quickSort([1,2, 5, 4, 3,6, 8, 7, 12,10]));
console.log('\n');
console.countReset('Number of times quickSort is called');
console.log(quickSort([5,2,8,9,4,5,1,3,7,6]));
console.log('\n');
console.countReset('Number of times quickSort is called');
console.log(quickSort([1,2,3,4,5,6,7,8,9,10,11,12,13]));
// This last quickSort example is the worst case for quicksort because the pivot is always the same end of the array and the array is always sorted, which results in the split between left/right being one empty array and one array with all of the other elements.  This is the situation where quickSort has a time complexity of O(n^2) - but it's so rare in practice that we still consider quickSort to be O(n log n);
```

#### Console Output
```
Number of times quickSort is called: 1
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
right [ 12 ] left [ 1, 2, 5, 4, 3, 6, 8, 7 ]
Number of times quickSort is called: 2
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
right [ 8 ] left [ 1, 2, 5, 4, 3, 6 ]
Number of times quickSort is called: 3
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
right [] left [ 1, 2, 5, 4, 3 ]
Number of times quickSort is called: 4
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
right [ 5, 4 ] left [ 1, 2 ]
Number of times quickSort is called: 5
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
right [] left [ 1 ]
Number of times quickSort is called: 6
Number of times quickSort is called: 7
Number of times quickSort is called: 8
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
right [ 5 ] left []
Number of times quickSort is called: 9
Number of times quickSort is called: 10
Number of times quickSort is called: 11
Number of times quickSort is called: 12
Number of times quickSort is called: 13
[ 1, 2, 3, 4, 5, 6, 7, 8, 10, 12 ]

Number of times quickSort is called: 1
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
right [ 8, 9, 7 ] left [ 5, 2, 4, 5, 1, 3 ]
Number of times quickSort is called: 2
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
right [ 5, 4, 5 ] left [ 2, 1 ]
Number of times quickSort is called: 3
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
right [ 2 ] left []
Number of times quickSort is called: 4
Number of times quickSort is called: 5
Number of times quickSort is called: 6
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
right [ 5 ] left [ 4 ]
Number of times quickSort is called: 7
Number of times quickSort is called: 8
=> undefined
Number of times quickSort is called: 9
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
right [ 8, 9 ] left []
Number of times quickSort is called: 10
Number of times quickSort is called: 11
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
right [] left [ 8 ]
Number of times quickSort is called: 12
Number of times quickSort is called: 13
[ 1, 2, 3, 4, 5, 5, 6, 7, 8, 9 ]

Number of times quickSort is called: 1
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
Number of times an index is accessed in a for loop: 10
Number of times an index is accessed in a for loop: 11
Number of times an index is accessed in a for loop: 12
right [] left [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
Number of times quickSort is called: 2
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
Number of times an index is accessed in a for loop: 10
Number of times an index is accessed in a for loop: 11
right [] left [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
Number of times quickSort is called: 3
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
Number of times an index is accessed in a for loop: 10
right [] left [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
Number of times quickSort is called: 4
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
Number of times an index is accessed in a for loop: 9
right [] left [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Number of times quickSort is called: 5
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
Number of times an index is accessed in a for loop: 8
right [] left [ 1, 2, 3, 4, 5, 6, 7, 8 ]
Number of times quickSort is called: 6
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
Number of times an index is accessed in a for loop: 7
right [] left [ 1, 2, 3, 4, 5, 6, 7 ]
Number of times quickSort is called: 7
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
Number of times an index is accessed in a for loop: 6
right [] left [ 1, 2, 3, 4, 5, 6 ]
Number of times quickSort is called: 8
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
Number of times an index is accessed in a for loop: 5
right [] left [ 1, 2, 3, 4, 5 ]
Number of times quickSort is called: 9
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
Number of times an index is accessed in a for loop: 4
right [] left [ 1, 2, 3, 4 ]
Number of times quickSort is called: 10
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
Number of times an index is accessed in a for loop: 3
right [] left [ 1, 2, 3 ]
Number of times quickSort is called: 11
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
Number of times an index is accessed in a for loop: 2
right [] left [ 1, 2 ]
Number of times quickSort is called: 12
lengthOfInput: 10
Number of times an index is accessed in a for loop: 1
right [] left [ 1 ]
Number of times quickSort is called: 13
Number of times quickSort is called: 14
Number of times quickSort is called: 15
Number of times quickSort is called: 16
Number of times quickSort is called: 17
Number of times quickSort is called: 18
Number of times quickSort is called: 19
Number of times quickSort is called: 20
Number of times quickSort is called: 21
Number of times quickSort is called: 22
Number of times quickSort is called: 23
Number of times quickSort is called: 24
Number of times quickSort is called: 25
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
```

### O(n^2) - Quadratic time example
As the input size increases, performance is directly proprotional to the square of `n`.
#### Function
```

function containsDuplicates(string) {
  let count = [0, 0]
  let truth;
  let inputSize = string.length;
  for (let i = 0; i < string.length; i++) {
    count[0]++;
    for (let j = 0; j < string.length; j++) {
      count[1]++;
      if (j === i) {
        continue;
      }
      if (string[i] === string[j]) {
        truth = true;
      }
      if (count[1] < 10) {
        console.log('count', count, '\t\ti', i, 'j', j)
      } else {
        console.log('count', count, '\ti', i, 'j', j)
      }

    }
      console.log('\n')
  }
  truth = false;
  return {'# of i loops': count[0], '# of total loops': count[1], 'inputSize': inputSize, 'inputSizeSquared': Math.pow(inputSize, 2)}
}

console.log(containsDuplicates('fasteeee'))
console.log(containsDuplicates('fastereee'))
```

#### Console Output
```
count [ 1, 2 ] 		i 0 j 1
count [ 1, 3 ] 		i 0 j 2
count [ 1, 4 ] 		i 0 j 3
count [ 1, 5 ] 		i 0 j 4
count [ 1, 6 ] 		i 0 j 5
count [ 1, 7 ] 		i 0 j 6
count [ 1, 8 ] 		i 0 j 7

count [ 2, 9 ] 		i 1 j 0
count [ 2, 11 ] 	i 1 j 2
count [ 2, 12 ] 	i 1 j 3
count [ 2, 13 ] 	i 1 j 4
count [ 2, 14 ] 	i 1 j 5
count [ 2, 15 ] 	i 1 j 6
count [ 2, 16 ] 	i 1 j 7

count [ 3, 17 ] 	i 2 j 0
count [ 3, 18 ] 	i 2 j 1
count [ 3, 20 ] 	i 2 j 3
count [ 3, 21 ] 	i 2 j 4
count [ 3, 22 ] 	i 2 j 5
count [ 3, 23 ] 	i 2 j 6
count [ 3, 24 ] 	i 2 j 7

count [ 4, 25 ] 	i 3 j 0
count [ 4, 26 ] 	i 3 j 1
count [ 4, 27 ] 	i 3 j 2
count [ 4, 29 ] 	i 3 j 4
count [ 4, 30 ] 	i 3 j 5
count [ 4, 31 ] 	i 3 j 6
count [ 4, 32 ] 	i 3 j 7

count [ 5, 33 ] 	i 4 j 0
count [ 5, 34 ] 	i 4 j 1
count [ 5, 35 ] 	i 4 j 2
count [ 5, 36 ] 	i 4 j 3
count [ 5, 38 ] 	i 4 j 5
count [ 5, 39 ] 	i 4 j 6
count [ 5, 40 ] 	i 4 j 7

count [ 6, 41 ] 	i 5 j 0
count [ 6, 42 ] 	i 5 j 1
count [ 6, 43 ] 	i 5 j 2
count [ 6, 44 ] 	i 5 j 3
count [ 6, 45 ] 	i 5 j 4
count [ 6, 47 ] 	i 5 j 6
count [ 6, 48 ] 	i 5 j 7

count [ 7, 49 ] 	i 6 j 0
count [ 7, 50 ] 	i 6 j 1
count [ 7, 51 ] 	i 6 j 2
count [ 7, 52 ] 	i 6 j 3
count [ 7, 53 ] 	i 6 j 4
count [ 7, 54 ] 	i 6 j 5
count [ 7, 56 ] 	i 6 j 7

count [ 8, 57 ] 	i 7 j 0
count [ 8, 58 ] 	i 7 j 1
count [ 8, 59 ] 	i 7 j 2
count [ 8, 60 ] 	i 7 j 3
count [ 8, 61 ] 	i 7 j 4
count [ 8, 62 ] 	i 7 j 5
count [ 8, 63 ] 	i 7 j 6

{ '# of i loops': 8,
  '# of total loops': 64,
  inputSize: 8,
  inputSizeSquared: 64 }
count [ 1, 2 ] 		i 0 j 1
count [ 1, 3 ] 		i 0 j 2
count [ 1, 4 ] 		i 0 j 3
count [ 1, 5 ] 		i 0 j 4
count [ 1, 6 ] 		i 0 j 5
count [ 1, 7 ] 		i 0 j 6
count [ 1, 8 ] 		i 0 j 7
count [ 1, 9 ] 		i 0 j 8

count [ 2, 10 ] 	i 1 j 0
count [ 2, 12 ] 	i 1 j 2
count [ 2, 13 ] 	i 1 j 3
count [ 2, 14 ] 	i 1 j 4
count [ 2, 15 ] 	i 1 j 5
count [ 2, 16 ] 	i 1 j 6
count [ 2, 17 ] 	i 1 j 7
count [ 2, 18 ] 	i 1 j 8

count [ 3, 19 ] 	i 2 j 0
count [ 3, 20 ] 	i 2 j 1
count [ 3, 22 ] 	i 2 j 3
count [ 3, 23 ] 	i 2 j 4
count [ 3, 24 ] 	i 2 j 5
count [ 3, 25 ] 	i 2 j 6
count [ 3, 26 ] 	i 2 j 7
count [ 3, 27 ] 	i 2 j 8

count [ 4, 28 ] 	i 3 j 0
count [ 4, 29 ] 	i 3 j 1
count [ 4, 30 ] 	i 3 j 2
count [ 4, 32 ] 	i 3 j 4
count [ 4, 33 ] 	i 3 j 5
count [ 4, 34 ] 	i 3 j 6
count [ 4, 35 ] 	i 3 j 7
count [ 4, 36 ] 	i 3 j 8

count [ 5, 37 ] 	i 4 j 0
count [ 5, 38 ] 	i 4 j 1
count [ 5, 39 ] 	i 4 j 2
count [ 5, 40 ] 	i 4 j 3
count [ 5, 42 ] 	i 4 j 5
count [ 5, 43 ] 	i 4 j 6
count [ 5, 44 ] 	i 4 j 7
count [ 5, 45 ] 	i 4 j 8

count [ 6, 46 ] 	i 5 j 0
count [ 6, 47 ] 	i 5 j 1
count [ 6, 48 ] 	i 5 j 2
count [ 6, 49 ] 	i 5 j 3
count [ 6, 50 ] 	i 5 j 4
count [ 6, 52 ] 	i 5 j 6
count [ 6, 53 ] 	i 5 j 7
count [ 6, 54 ] 	i 5 j 8

count [ 7, 55 ] 	i 6 j 0
count [ 7, 56 ] 	i 6 j 1
count [ 7, 57 ] 	i 6 j 2
count [ 7, 58 ] 	i 6 j 3
count [ 7, 59 ] 	i 6 j 4
count [ 7, 60 ] 	i 6 j 5
count [ 7, 62 ] 	i 6 j 7
count [ 7, 63 ] 	i 6 j 8

count [ 8, 64 ] 	i 7 j 0
count [ 8, 65 ] 	i 7 j 1
count [ 8, 66 ] 	i 7 j 2
count [ 8, 67 ] 	i 7 j 3
count [ 8, 68 ] 	i 7 j 4
count [ 8, 69 ] 	i 7 j 5
count [ 8, 70 ] 	i 7 j 6
count [ 8, 72 ] 	i 7 j 8

count [ 9, 73 ] 	i 8 j 0
count [ 9, 74 ] 	i 8 j 1
count [ 9, 75 ] 	i 8 j 2
count [ 9, 76 ] 	i 8 j 3
count [ 9, 77 ] 	i 8 j 4
count [ 9, 78 ] 	i 8 j 5
count [ 9, 79 ] 	i 8 j 6
count [ 9, 80 ] 	i 8 j 7

{ '# of i loops': 9,
  '# of total loops': 81,
  inputSize: 9,
  inputSizeSquared: 81 }
```

### O(c^n) - Exponential time example
Function taken from [here](https://adrianmejia.com/blog/2018/04/05/most-popular-algorithms-time-complexity-every-programmer-should-know-free-online-tutorial-course/)

#### Function
```
function getSubsets(n = '') {
  const array = Array.from(n);
  const base = [''];
  console.log('base length', base[0])

  const results = array.reduce((previous, element) => {
    const previousPlusElement = previous.map(el => {
      return `${el}${element}`;
    });
    return previous.concat(previousPlusElement);
  }, base);

  console.log(`getSubsets(${n}) // ${results.slice(0, 15).join(', ')}... `);
  console.log(`n: ${array.length}, counter: ${results.length};`);
  return results;
}

getSubsets('abacab')
```

#### Console Output
```
getSubsets(abacab) // , a, b, ab, a, aa, ba, aba, c, ac, bc, abc, ac, aac, bac...
n: 6, counter: 64;
=> [ '',
  'a',
  'b',
  'ab',
  'a',
  'aa',
  'ba',
  'aba',
  'c',
  'ac',
  'bc',
  'abc',
  'ac',
  'aac',
  'bac',
  'abac',
  'a',
  'aa',
  'ba',
  'aba',
  'aa',
  'aaa',
  'baa',
  'abaa',
  'ca',
  'aca',
  'bca',
  'abca',
  'aca',
  'aaca',
  'baca',
  'abaca',
  'b',
  'ab',
  'bb',
  'abb',
  'ab',
  'aab',
  'bab',
  'abab',
  'cb',
  'acb',
  'bcb',
  'abcb',
  'acb',
  'aacb',
  'bacb',
  'abacb',
  'ab',
  'aab',
  'bab',
  'abab',
  'aab',
  'aaab',
  'baab',
  'abaab',
  'cab',
  'acab',
  'bcab',
  'abcab',
  'acab',
  'aacab',
  'bacab',
  'abacab' ]
```

### Another O(c^n) example
Recursive fibonacci exmaple:
In order to compute fib(5), a tree
```
                                      fib(5)
                                  /           \
                                /               \
                              /                   \
                            /                       \
                          /                           \
                       /                                \
                  fib(4)                               fib(3)
                /         \                           /       \
              /             \                       /           \
          fib(3)             fib(2)            fib(2)         fib(1)
        /      \             /    \             /   \            |
      /         \           /       \         /       \          1
    fib(2)    fib(1)     fib(1)  fib(0)     fib(1) fib(0)
fib(1) fib(0)   |           |       |          |      |
  |       |     1           1       0          1      0
  1       0
```

#### Function

This illustrative example found on [Stack Overflow](https://stackoverflow.com/questions/8845154/how-does-the-fibonacci-recursive-function-work)

```
let calls = 0;
function fibonacci(n, c) {
  calls++;
    var indent = "";
    for (var i = 0; i < c; i++) {
        indent += " ";
    }
    console.log(indent + "fibonacci(" + n + ")");

    if (n < 2) {
        return 1;
    } else {
        return fibonacci(n - 2, c + 4) + fibonacci(n - 1, c + 4);
    }
}

console.log({'n': 7, 'answer': fibonacci(7, 0), '# of calls': calls});
calls = 0;
console.log('\n');
console.log({'n': 8, 'answer': fibonacci(8, 0), '# of calls': calls});
```

#### Console Output
```
fibonacci(7)
    fibonacci(5)
        fibonacci(3)
            fibonacci(1)
            fibonacci(2)
                fibonacci(0)
                fibonacci(1)
        fibonacci(4)
            fibonacci(2)
                fibonacci(0)
                fibonacci(1)
            fibonacci(3)
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
    fibonacci(6)
        fibonacci(4)
            fibonacci(2)
                fibonacci(0)
                fibonacci(1)
            fibonacci(3)
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
        fibonacci(5)
            fibonacci(3)
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
            fibonacci(4)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
                fibonacci(3)
                    fibonacci(1)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
{ n: 7, answer: 21, '# of calls': 41 }

fibonacci(8)
    fibonacci(6)
        fibonacci(4)
            fibonacci(2)
                fibonacci(0)
                fibonacci(1)
            fibonacci(3)
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
        fibonacci(5)
            fibonacci(3)
=> undefined
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
            fibonacci(4)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
                fibonacci(3)
                    fibonacci(1)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
    fibonacci(7)
        fibonacci(5)
            fibonacci(3)
                fibonacci(1)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
            fibonacci(4)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
                fibonacci(3)
                    fibonacci(1)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
        fibonacci(6)
            fibonacci(4)
                fibonacci(2)
                    fibonacci(0)
                    fibonacci(1)
                fibonacci(3)
                    fibonacci(1)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
            fibonacci(5)
                fibonacci(3)
                    fibonacci(1)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
                fibonacci(4)
                    fibonacci(2)
                        fibonacci(0)
                        fibonacci(1)
                    fibonacci(3)
                        fibonacci(1)
                        fibonacci(2)
                            fibonacci(0)
                            fibonacci(1)
{ n: 8, answer: 34, '# of calls': 67 }
```

### O(n!)


text:
# Rust driver for Rainbow HAT

[![Build Status](https://travis-ci.com/yannart/rainbow-hat-rs.svg?branch=master)](https://travis-ci.com/yannart/rainbow-hat-rs)
[![](http://meritbadge.herokuapp.com/rainbow-hat-rs)](https://crates.io/crates/rainbow-hat-rs)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Minimum rustc version](https://img.shields.io/badge/rustc-v1.45.0-lightgray.svg)](https://blog.rust-lang.org/2019/02/28/Rust-1.45.0.html)
[![Documentation](https://docs.rs/rainbow-hat-rs/badge.svg)](https://docs.rs/rainbow-hat-rs)

This repository contains an unofficial Rust driver library for [Rainbow HAT](https://shop.pimoroni.com/products/rainbow-hat-for-android-things), for use with Raspberry Pi OS on your Raspberry Pi.
For the official Python driver see: https://github.com/pimoroni/rainbow-hat.
For the official AndroidThings driver see: https://github.com/androidthings/contrib-drivers/tree/master/rainbowhat.

This library depends on https://github.com/golemparts/rppal for access to the Raspberry Pi peripherals.

Current periferials supported:
| Periferial                             | Supported | Structs                                |
|----------------------------------------|-----------|----------------------------------------|
| Multicolour LEDs                       | X         | rainbow_hat_rs::apa102::APA102         |
| Four 14-segment alphanumeric displays  | X         | rainbow_hat_rs::alphanum4::Alphanum4   |
| Three capacitive touch buttons         | X         | rainbow_hat_rs::touch::Buttons         |
| Temperature and pressure sensor        |           |                                        |
| Blue, green and red LEDs               | X         | rainbow_hat_rs::lights::Lights         |
| Piezo buzzer                           | X         | rainbow_hat_rs::buzzer::Buzzer         |

## References
* https://pinout.xyz/pinout/rainbow_hat

## Usage
Add a dependency for `rainbow-hat-rs` to your `Cargo.toml`.

```toml
[dependencies]
rainbow-hat-rs = "0.2.1"
```

Call `new()` on any of the peripherals to construct a new instance.

```rust
use rainbow_hat_rs::lights::Lights;
use rainbow_hat_rs::alphanum4::Alphanum4;
use rainbow_hat_rs::touch::Buttons;
use rainbow_hat_rs::apa102::APA102;
use rainbow_hat_rs::buzzer::Buzzer;

let mut apa102 = APA102::new()?;
let mut lights = Lights::new()?;
let mut buttons = Buttons::new()?;
let mut alphanum = Alphanum4::new()?;
let mut buzzer = Buzzer::new()?;
```

## Examples
See folder [examples](examples/README.md).

## Multicolour LEDs
```rust
let mut apa102 = APA102::new()?;

 // Sets color for all LED.
 apa102.set_all(255, 0, 0, 0.5);

 // Sets color for first LED.
 apa102.set_pixel(0, 0, 255, 0, 0.5);

// Shows on the device.
apa102.show()?;
```

### Lights

```rust
let mut lights = Lights::new()?;

// Turn on red and green lights
lights.rgb(true, true, false);

// Turn off red light
lights.red.off()

// Turn on blue light
lights.blue.on()

// Toggle green light
lights.green.toggle()
```

### Buttons
```rust
let mut buttons = Buttons::new()?;

// Identify if button A is pressed
if buttons.a.is_pressed() {
    println!("Button A touched!");
}
```

### Display
```rust
let mut alphanum = Alphanum4::new()?;

// Print a message on the display
alphanum.print_str("1234", false);
alphanum.show()?;
```

### Buzzer
```rust
let mut buzzer = Buzzer::new()?;

// Play a note
buzzer.midi_note(69, 0.3)?;
```

## Caution

Always be careful when working with the Raspberry Pi's peripherals, especially if you attach any external components to the GPIO pins. Improper use can lead to permanent damage.

## Copyright and license
Copyright (c) 2020 Yann Nicolas. Released under the [MIT license](LICENSE).

repository: yannart/rainbow-hat-rs

gha_language: Rust

repo_name: yannart/rainbow-hat-rs


text:
+++
title = "Reporting"
description = ""
keywords = ["grafana", "reporting"]
type = "docs"
[menu.docs]
parent = "features"
weight = 8
+++

# Reporting

> Reporting is only available in Grafana Enterprise. Read more about [Grafana Enterprise]({{< relref "enterprise" >}}).

> Only available in Grafana v6.4+

Reporting allows you to generate PDFs from any of your Dashboards and have them sent out to interested parties on a schedule.

{{< docs-imagebox img="/img/docs/enterprise/reports_list.png" max-width="500px" class="docs-image--no-shadow" >}}

## Dashboard as a Report

With Reports there are a few things to keep in mind, most importantly, any changes you make to the Dashboard used in a report will be reflected in the report. If you change the time range in the Dashboard the time range will be the same in the report as well.

## Setup

> SMTP must be configured for reports to be sent

We recommend using the new image rendering plugin with reporting as it supports a wider range of panels than the built-in image rendering. Read more about it [here]({{< relref "administration/image_rendering.md#grafana-image-renderer-plugin" >}})

## Usage

{{< docs-imagebox img="/img/docs/enterprise/reports_create_new.png" max-width="500px" class="docs-image--no-shadow" >}}

Currently only Organisation Admins can create reports. To get to report click on the reports icon in the side menu. This will allow you to list, create and update your reports.

| Setting       | Description                                                       |
| --------------|------------------------------------------------------------------ |
| Name          | name of the Report                                                |
| Dashboard     | what dashboard to generate the report from                        |
| Recipients    | emails of the people who will receive this report                 |
| ReplyTo       | your email address, so that the recipient can respond             |
| Message       | message body in the email with the report                         |
| Schedule      | how often do you want the report generated and sent               |

## Debugging errors

If you have problems with the reporting feature you can enable debug logging by switching the logger to debug (`filters = report:debug`). Learn more about making configuration changes [here]({{< relref "installation/configuration.md#filters" >}}).

repository: spartanaorg/grafana

repo_name: spartanaorg/grafana


text:
# latex4matlab
MATLAB class that allows you to generate, view and compile LaTeX code from a MATLAB array.

This code was modified from the original latexTable function by Eli Duenisch, which can be found here:
https://github.com/eliduenisch/latexTable

What I changed:

- The code is now a class definition, allowing you to modify settings after creating the object.
- I added an extra method that generates code for the amsmath package's bmatrix environment, since I use it frequently.
- I added support for symbolic variables, for easy inclusion of e.g. Jacobian matrices in your reports.
- I added preview functionality, which largely runs outside MATLAB and creates a PNG image of whatever LaTeX object you are creating.
- Added clickable buttons to copy LaTeX code or view the preview.

The 'tex' folder is where the preview .tex, .pdf and .png files are generated.
You can modify preview.tex if you wish, just make sure to leave the lines containing BEGIN PREVIEW and END PREVIEW.
The preview function in MATLAB uses these lines to identify where to put the generated code.
Please be aware that the preview function will attempt to run system commands on your computer.
This is necessary to compile the preview code and as far as I am aware should be completely harmless.

If you wish to use the preview function, make sure the following (free) software is installed:

- LaTeX compiler with the following packages:
  - standalone
  - amsmath
  - booktabs

If you are using MiKTeX, it should prompt you to install these packages automatically. See https://miktex.org/download

- ImageMagick (See https://imagemagick.org/script/download.php#windows). I use version 7.0.10
- GhostScript (See https://www.ghostscript.com/download/gsdnld.html). I use version 9.52

If all these are installed and verified to be working, you are good to
go!


text:
---
layout: recipe
date: 2020-11-15T10:17:10-05:00
title:  "Garden Salsa" # The title of your awesome recipe
image: # Name of image in recipe bundle
imagecredit: # URL to image source page, website, or creator
YouTubeID:  # The F2SYDXV1W1w part of https://www.youtube.com/watch?v=F2SYDXV1W1w
authorName: # Name of the recipe/article author
authorURL: # URL of their home website
sourceName: # Name of the source website
sourceURL: # Actual URL of the recipe itself
category: Appetizer # The type of meal or course your recipe is about. For example: "dinner", "entree", or "dessert".
cuisine: Mexican # The region associated with your recipe. For example, "French", Mediterranean", or "American".
tags: # You don't have to have 3, feel free to have 10, 1, or none
  - snack
  - appetizer
yield: 8
prepTime: 20
cookTime: 0

ingredients:
- 6-8 medium tomatoes
- 1/2 - 1 clove of garlic
- 1/2 large yellow onion
- 1 lime
- 1/2 bunch of cilantro
- 1 teaspoons of salt.
- 1-2 Serrano or jalapeño peppers

directions:
- Boil a pot of hot water, after it boils, turn it off and let the tomatoes set for 3-5 min.
- Chop up onion, garlic and peppers.
- Separate the stems from the cilantro.
- Either use a food processor or blender.
- Cut lime in half and squeeze the juice.
- Add salt to taste.
- Make it hotter by adding another pepper.

---

repository: seanlane/recipes

repo_name: seanlane/recipes