text:
---
layout: page
title: "How is LLaMa.cpp possible?"
articles: True
math: True
---

_If you want to read more of my writing, I have a [Substack](https://finbarrtimbers.substack.com/). Articles will be posted simultaneously to both places._

_Note: This was written in March of '23, and is out of date (AI moves quickly!). This is an attempt at answering the question "How is it possible to run Llama on a single CPU?" and is not an attempt at documenting the current status of the Llama.cpp project. You should not rely on any of this post for specific details on how Llama.cpp functions._

Recently, a [project](https://github.com/ggerganov/llama.cpp) rewrote the [LLaMa inference code](https://github.com/facebookresearch/llama) in raw C++. With some optimizations and quantizing the weights, this allows running a LLM locally on a wild variety of hardware:

- On a [Pixel5](https://twitter.com/rgerganov/status/1635604465603473408), you can run the 7B parameter model at 1 tokens/s.
- On a [M2 Macbook Pro](https://simonwillison.net/2023/Mar/11/llama/), you can get ~16 tokens/s with the 7B parameter model
- You can [even run the 7B model on a 4GB RAM Raspberry Pi](https://twitter.com/miolini/status/1634982361757790209), albeit at 0.1 tokens/s.

If you are like me, you saw this and thought: What? How is this possible? Don’t large models require expensive GPUs? I took my confusion and dove into the math surrounding inference requirements to understand the constraints we’re dealing with.

Let’s start with GPUs. GPUs have two main benefits for deep learning:

1. They have a large amount of memory bandwidth ([A100](https://www.nvidia.com/content/dam/en-zz/Solutions/Data-Center/a100/pdf/nvidia-a100-datasheet-us-nvidia-1758950-r4-web.pdf): 1935 GB/s, [4090](https://images.nvidia.com/aem-dam/Solutions/geforce/ada/ada-lovelace-architecture/nvidia-ada-gpu-architecture-whitepaper-1.03.pdf): 1008 GB/s)
2. They have a large amount of compute ([A100](https://www.nvidia.com/content/dam/en-zz/Solutions/Data-Center/a100/pdf/nvidia-a100-datasheet-us-nvidia-1758950-r4-web.pdf): 312 TFLOPS of FP16, [4090](https://images.nvidia.com/aem-dam/Solutions/geforce/ada/ada-lovelace-architecture/nvidia-ada-gpu-architecture-whitepaper-1.03.pdf): 82.6 TFLOPS of FP16)

When we talk about memory bandwidth, we’re talking about how long it takes to move things from the HBM memory (i.e. the RAM) into the on-chip memory. To actually do math with the GPU, we need to move the matrices in question into the on-chip memory, which is quite small (40MB on an A100, compared to 40-80GB of RAM). Note that the memory bandwidth is ~2 orders of magnitude smaller than the compute performance— this will matter later, as the memory bandwidth tends to be the bottleneck for inference.

What does this mean in the context of serving LLaMa? Let’s start with some [inference arithmetic](https://kipp.ly/blog/transformer-inference-arithmetic/). We can do some rough calculations on the inference performance of a LLM using [Kipply’s article](https://kipp.ly/blog/transformer-param-count/)[^1]. First, some notation on the dimensions of the model:

- The $$Q$$, $$K$$, and $$V$$ weight matrices are all shape [ $$d_{\text{model}}$$, $$d_{\text{head}}$$], and we have $$n_{\text{heads}}$$ of them per layer; the attention output matrix has the same shape, for a total of  $$4 \times$$ [ $$d_{\text{model}}$$, $$n_{\text{heads}} \cdot d_{\text{head}}$$]. By convention, GPT-style networks have $$d_{\text{head}} \cdot n_{\text{heads}} = d_{\text{model}}$$.
- The MLP has two weight matrices, of shape [ $$d_{\text{model}}$$, $$4 \cdot d_{\text{model}}$$] and [ $$4\cdot d_{\text{model}}$$, $$d_{\text{model}}$$]
- The embeddings matrix is of size [ $$d_{\text{vocab}}$$, $$d_{\text{model}}$$].

This gives us a handy equation for the number of parameters in a GPT-style model:[^2]

$$P = n_{\text{blocks}} \left( 4 \cdot d_{\text{model}}^2 + 2 \cdot 4 \cdot d_{\text{model}}^2\right) + n_{\text{vocab}} \cdot d_{\text{model}}$$

[^2]: Although we don’t need it, as we already know the number of parameters. This is mostly useful as a sanity check for the rest of our math.

For the duration of the post, I’m going to focus on the case where we’re running a ChatGPT style service locally, which is what LLaMa.cpp does, letting me assume a batch size of 1.

For efficient inference, the KV cache has to be stored in memory; the KV cache requires storing the KV values for every layer, which is equal to storing:

$$n_{\text{bytes}} \cdot 2 \cdot d_{\text{model}}$$

I use $$n_{\text{bytes}}$$ here to indicate the number of bytes per param; for float32s, this is 4, for float16s, this is 2, etc. The 2 in the middle is because we have to store one set of weights for the K values, and one for the Vs.

Given a model with n layers, the total memory for the KV cache is:

$$n_{\text{blocks}} \cdot n_{\text{bytes}} \cdot 2 \cdot d_{\text{model}}$$

In addition to storing the KV cache in memory, we also need to store the weights themselves in memory; this requires $$n_{\text{bytes}} \cdot P$$ bytes.

![Screenshot of table showing the memory required for LLaMa weights](/static/images/llama-memory-weights.png)

This is the advantage of quantization. By using less precision, we can radically decrease the amount of memory needed to store our models in memory. Note that, with int4 precision, *all of these models fit into memory on an A100* (which is the standard datacenter GPU right now), and all of them, except for the biggest model, fit into memory on high-end consumer GPUs (3090s/4090s, which have 24GB of RAM).

It takes approximately $$2P$$ FLOPS to run inference on our model for a single token, because we are doing a bunch of matmuls with a total of $$P$$ parameters, and multiplying a matrix of size $$(m, n)$$ with a vector of size $$(n,)$$ has a cost of $$2mn$$.[^3]

[^3]: For a more detailed discussion showing that this is the case, check out [kipply’s article](https://kipp.ly/blog/transformer-inference-arithmetic/#flops-counting).

With all that math out of the way, let’s calculate the requirements for running inference with LLaMa. The main requirements when it comes to sampling are:

1. Keep the KV cache in memory, in addition to all the parameters.
2. Read all the weights from HBM into the on-chip memory. Because we sample auto-regressively, we have to repeat this for each token we sample.
3. Do the actual matmuls to calculate the output of our network.

The latency is the maximum of either the compute or the memory latency, as reading parameters into on-chip memory happens asynchronously in all modern tensor programming libraries. As a result, we write:

$$
\begin{align*}
\text{latency}_\text{model} &= \text{max}(\text{latency}_\text{compute}, \text{latency}_\text{memory})\\
\text{latency}_\text{memory} &= \dfrac{2 \cdot P \cdot n_{\text{bytes}}\cdot B}{n_{\text{memory bandwidth}}},\\
\text{latency}_\text{compute} &= \dfrac{2 \cdot P}{n_{\text{flops}}},
\end{align*}
$$

where $$B$$ is the batch size. As $$n_{\text{memory bandwidth}} = 1.935e12$$, and  $$n_{\text{flops}} = 3.12e14,$$ as long as the batch size is less than 161, the model is memory-bound.[^4]

[^4]: If you’re following along with [kipply’s post](https://kipp.ly/blog/transformer-inference-arithmetic/#latency-calculations), there’s a slight discrepancy here, as I assume a 80GB A100 PCIe, which is what I see as the standard GPU. Their post assumes a 40GB A100 PCIe, which has slightly lower memory bandwidth.

With a batch size of 1, this is the same equation, as on most hardware (e.g. Nvidia GPUs), there is a linear speedup as you decrease the precision (you get twice the FLOPS when using fp16 vs fp32, which doubles again as you go to int8, and doubles once more as you go to int4s).

As LLaMa.cpp uses int4s, the RAM requirements are reduced to 1.33GB of memory for the KV cache, and 16.25GB of VRAM for the model parameters. That’s pretty good!

As the memory bandwidth is almost always[^5] much smaller than the number of FLOPS, memory bandwidth is the binding constraint.

[^5]: I hedge with “almost” here, but I’m not aware of any counterexamples.

![Screenshot fo table showing the inference times to run the varying LLaMa models with varying precision levels on an A100](/static/images/llama-inference-times.png)

## Running LLaMa on an A100

On an A100 (80GB PCIe), the memory bandwidth is 1935GB/s. The int4 compute is 1248 TOPS. As such, the model is (heavily) memory-bound. We should expect to see inferences as given in the table; roughly 30 tokens/s with the 65B model, and 277 tokens/s with the 7B model.

## Running LLaMa on a M1 Macbook Air

The M1 GPU has a bandwidth of [68.25 GB/s](https://www.macworld.com/article/783678/m2-vs-m1-chip-performance-graphics-ram.html), while the M1 GPU can do up to [5.5 TFLOPS](https://tlkh.dev/benchmarking-the-apple-m1-max#heading-gpu-matrix-multiplication-gemm-performance) of fp16 compute. As such, we should expect a ceiling of ~1 tokens/s for sampling from the 65B model with int4s, and 10 tokens/s with the 7B model.

As the M2 Pro has 200 GB/s of bandwidth, and the M2 Max has 400 GB/s of bandwidth, we should expect massive improvements with them, going up to 6 tokens/s with the M2 Max with the 65B model. That’s pretty darn good for a laptop.

## Running LLaMa on a Raspberry Pi 4

A Raspberry Pi 4 has [13.5 GFLOPS of compute](https://web.eece.maine.edu/~vweaver/group/green_machines.html), and [~4GB/s of memory bandwidth](https://forums.raspberrypi.com/viewtopic.php?t=281183). Given this, we’d expect to see ~2 tokens/s with the 7B model if it was memory bound. Given that we’re currently seeing ~0.1 tokens/s, I suspect we’re actually compute-bound (although this is a stab in the dark— I can’t find enough information about the specs for a Raspberry Pi to determine this with any precision).

## Summary

Memory bandwidth is the limiting factor in almost everything to do with sampling from transformers. Anything that reduces the memory requirements for these models makes them *much* easier to serve— like quantization! This is yet another reason why distillation, or just [training smaller models for longer](https://finbarr.ca/llms-not-trained-enough/), is really important.

*Note: I’m not an expert in CUDA, so I probably have errors in my math. If so, please shoot me an<EMAIL_ADDRESS>and let me know- I’d love to hear from you so I can learn more about how this works and update this post.*

Resources on transformer inference performance:

- [Large Transformer Model Inference Optimization](https://lilianweng.github.io/posts/2023-01-10-inference-optimization/)
- [Transformer inference arithmetic](https://kipp.ly/blog/transformer-inference-arithmetic/)
- [LLM parameter counting](https://kipp.ly/blog/transformer-param-count/)
- [Efficient Transformers](https://arxiv.org/abs/2009.06732)

*Thank you to [Kaushik Patnaik](https://twitter.com/kaushikpatnaik?lang=en), [Arthur Allshire](https://twitter.com/arthurallshire), [Stanislav Fort](https://twitter.com/stanislavfort), and [Tom McGrath](https://twitter.com/banburismus_) for reading early drafts of this.*

[^1]: Almost all of this math is taken from their article; they deserve full credit.

[^2]:  Although it’s an open question of how much Mac specific optimization is being done with LLaMa, or indeed, any of the tensor programming frameworks.


text:
[shark-graph](../../index.md) / [shark](../index.md) / [HprofHeapGraph](index.md) / [primitiveArrays](./primitive-arrays.md)

# primitiveArrays

`val primitiveArrays: `[`Sequence`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence/index.html)`<`[`HeapObject.HeapPrimitiveArray`](../-heap-object/-heap-primitive-array/index.md)`>`

Overrides [HeapGraph.primitiveArrays](../-heap-graph/primitive-arrays.md)

Sequence of all primitive arrays in the heap dump.

This sequence does not trigger any IO reads.

repository: Pvredev/leakcanary

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: Pvredev/leakcanary


text:
## Extensions

**JavaScript**

* [livr-extra-rules](https://github.com/koorchik/js-livr-extra-rules) available at [npm](https://www.npmjs.com/package/livr-extra-rules), maintainer [@koorchik](https://github.com/koorchik)

> The module contains extra rules for LIVR. It is absolutely ok for LIVR to have your own custom rules in your project. But there are some rules that are useful cross projects.

* [react-livr-validation](https://github.com/one-more/react-livr-validation) available at [npm](https://www.npmjs.com/package/react-livr-validation), maintainer [@one-more](https://github.com/one-more)

> Validation component for React with LIVR as validation engine

* [confme](https://github.com/koorchik/node-confme) available at [npm](https://www.npmjs.com/package/confme), maintainer [@koorchik](https://github.com/koorchik)

> Opinionated config library that allows you to have complex config and behaves according to "Twelve Factor App" rules.

* [vue-livr](https://github.com/grupozap/vue-livr) available at [npm](https://www.npmjs.com/package/vue-livr), maintainer [@grupozap](https://github.com/grupozap)

> Validation component for Vue.js with LIVR as validation engine

**Perl**

* [LIVR::Contract](https://github.com/koorchik/LIVR-Contract) available at [CPAN](https://metacpan.org/pod/LIVR::Contract), maintainer [@koorchik](https://github.com/koorchik)

> LIVR::Contract design by Contract in Perl with Language Independent Validation Rules (LIVR). Uses Validator::LIVR underneath.

* [MVC::Neaf::X::Form::LIVR](https://metacpan.org/pod/MVC::Neaf::X::Form::LIVR) avaliable at [CPAN](https://metacpan.org/pod/MVC::Neaf::X::Form::LIVR), maintainer [@KHEDIN](https://metacpan.org/author/KHEDIN)

> Do input validation using Validator::LIVR. Return an object with is_valid(), data(), error(), and raw() methods.

repository: koorchik/LIVR

gha_language: Less

repo_name: koorchik/LIVR


text:
#### This is a `tcpdump` experiment dataset directory.
You can run the script `tcpdumptest.sh` to generate more dataset to run the framework yourself. Certain requirements apply.

* The system must install `camflow` to track the program

* `tcpdump` should be of version `4.5.1` (or any version that contains the access violation vulnerability)

* Bad instance is created through giving bad input to `tcpdump`. We supply a good input `okay.pcap` and a bad input `crash.pcap` for the experiment. In our generated 10 datasets, one of which is generated using `crach.pcap` and the rest are using `okay.pcap`

* To run the script: `./tcpdumptest.sh <file_path>` (You need to specify where you want the result input file to be. That file will be the input to the framework)

repository: michael-hahn/frap

repo_name: michael-hahn/frap


text:
---
layout: layout.njk
eleventyNavigation:
  key: plugin-system-logger
  title: Diagnostics and Logging
  order: 15
---

Parcel includes support for rich diagnostics that are used to describe errors and warnings in a format-agnostic way. It also includes a built in logging system that allows Reporter plugins to handle all logs and errors and present them to the user.

## Diagnostics

A [`Diagnostic`](/plugin-system/logging/#Diagnostic) is a JavaScript object with a set of properties that are required to create a useful log message. This can be anything from a verbose message to a warning or error. Diagnostics can include a message, information about the file being processed, a code frame, error information, hints on how to potentially resolve the issue, and a link to documentation to learn more.

The `ThrowableDiagnostic` class in the `@parcel/diagnostic` package extends the JavaScript `Error` object with support for diagnostics. When throwing an error within your plugin, use a `ThrowableDiagnostic` object to attach a diagnostic with context about the error. Parcel will automatically attach your plugin name as the origin of the diagnostic.

```js
import ThrowableDiagnostic from '@parcel/diagnostic';

throw new ThrowableDiagnostic({
  diagnostic: {
    message: 'An error occurred'
  }
});
```

You can also throw multiple diagnostics at once by passing an array to the `diagnostic` option of a `ThrowableDiagnostic`.

### Formatting messages

To format the messages in a diagnostic, a very minimal version of Markdown is supported. This format has been specifically built to be compatible with terminals and other render targets such as browsers and editors, while also not being too cryptic when displayed without any formatting. `@parcel/reporter-cli` uses the `@parcel/markdown-ansi` library to convert these Markdown strings to ANSI escape sequences for rendering in a terminal.

The supported Markdown features are `**bold**`, `*italic*`/`_italic_`, `__underline__` and `~~strikethrough~~`.

The `@parcel/diagnostic` package includes some utilities for working with Markdown messages. The `md` tagged template literal handles escaping any interpolated expressions within Markdown strings. This ensures that any special Markdown characters within expressions do not affect the formatting.

```js
import {md} from '@parcel/diagnostic';

throw new ThrowableDiagnostic({
  diagnostic: {
    message: md`**Error**: Could not parse ${filePath}`
  }
});
```

There are also utilities for formatting interpolated expressions, including `md.bold`, `md.italic`, `md.underline`, and `md.strikethrough`.

```js
import {md} from '@parcel/diagnostic';

throw new ThrowableDiagnostic({
  diagnostic: {
    message: md`**Error**: Could not parse ${md.underline(filePath)}`
  }
});
```

### Code frames

A [`Diagnostic`](/plugin-system/logging/#Diagnostic) can have one or more code frames attached. A code frame includes a file path along with one or more code highlights, which give context about where in a file an error occurred. Code highlights are defined by the line and column position within the file, and may also have a message to be displayed at that position.

Code frames should also include the source code for the file the error occurred in. If omitted, Parcel will read the file from the file system. However, in many cases the input source code may have come from another plugin that ran before, so the code will have been modified in some way. Including the code in the code frame avoids this issue.

```js
throw new ThrowableDiagnostic({
  diagnostic: {
    message: md`Could not parse ${asset.filePath}`,
    codeFrames: [{
      filePath: asset.filePath,
      code: await asset.getCode(),
      codeHighlights: [
        {
          start: {
            line: 1,
            column: 5,
          },
          end: {
            line: 2,
            column: 3,
          },
          message: 'Expected a string but got a number'
        }
      ]
    }]
  }
});
```

### Hints

Diagnostics can also include hints about how to fix a problem, and a link to documentation for users to learn more. These are provided via the `hints` and `documentationURL` properties.

```js
throw new ThrowableDiagnostic({
  diagnostic: {
    message: 'Could not find a config file',
    hints: ['Create a tool.config.json file in the project root.'],
    documentationURL: 'http://example.com/'
  }
});
```

## Logger

Parcel's logger can be used to log messages in plugins. Every function of a plugin is passed a [`Logger`](#PluginLogger) instance as a parameter. This instance has all the information Parcel needs to identify your plugin as the origin of the message.

The logger accepts [diagnostics](#diagnostics), which are JavaScript objects with a standardized set of properties that describe the log message, its origin, and context such as a code frame. [Reporter](/plugin-system/reporter/) plugins use this information to log your message while having complete freedom over how this data is formatted and displayed.

A [`Logger`](#PluginLogger) has a function for each log level, including `verbose`, `info`, `log`, `warn` and `error`. These log levels specify the severity of log messages, which is useful for formatting and filtering. For example, the [`--log-level`](/features/cli/#parameters) CLI option can be used to choose which messages you want to see. Each logging function also has a single parameter, which can either be a single [`Diagnostic`](#Diagnostic) object or an array of diagnostics, depending on how many messages you want to log.

{% note %}

**Note**: The results of Parcel plugins are cached. This means any logs or warnings that a plugin emits will only be shown during a rebuild, and not when cached.

{% endnote %}

### Log levels

| Level   | When to use                                                                                | function(s)                                             |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| verbose | Use this when you want to log anything that can be used for debugging issues, while not being particularly interesting for normal usage. | `logger.verbose(...)`                                   |
| info    | Use this to log any information that is not related to a problem.                                                                        | `logger.info(...)` or `logger.log(...)`                 |
| warning | Use this to log anything related to a problem that is not critical.                                                                      | `logger.warning(...)`                                   |
| error   | Use this to log any critical issues. You may want to throw a [`ThrowableDiagnostic`](#ThrowableDiagnostic) instead to cause the build to fail.                                          | `logger.error(...)` or `throw ThrowableDiagnostic(...)` |

### How to log a message

Once you're familiar with the [`Diagnostic`](#Diagnostic) format, you can log anything you want, from verbose messages to errors with code frames and hints. This example shows how to log a warning, complete with a code frame, hints, and a documentation URL.

```js
import {Transformer} from '@parcel/plugin';

export default new Transformer({
  async transform({asset, logger}) {
    // ...

    logger.warn({
      message: 'This feature is deprecated.',
      codeFrames: [{
        filePath: asset.filePath,
        code: await asset.getCode(),
        codeHighlights: [{
          start: {
            line: 1,
            column: 5
          },
          end: {
            line: 1,
            column: 10
          }
        }]
      }],
      hints: ['Please use this other feature instead.'],
      documentationURL: 'http://example.com/'
    });
  },
});
```

## Automatically collected logs and errors

Parcel automatically collects any logs created with `console.log` and other `console` methods. Whenever `console.log` is called, Parcel catches this, converts it to a [`Diagnostic`](#Diagnostic) object, and sends it to [Reporter](/plugin-system/reporter/) plugins just like it does with messages sent to the `logger`. However, this is not recommended since Parcel does not have as much information as when calling the `logger` directly.

Parcel also handles any errors that are thrown within plugins. These are converted into a [`Diagnostic`](#Diagnostic), and information about about the plugin is added to it. Errors that are thrown are sent to [Reporter](/plugin-system/reporter/) plugins, and the build is halted.

### API

{% include "../../api/logger.html" %}
{% include "../../api/diagnostic.html" %}

license: MIT

repository: parcel-bundler/website

gha_language: HTML

gha_license_id: MIT

repo_name: parcel-bundler/website


text:
---
layout: post
title: How to download ebooks from Library Genesis (libgen) for free
date: 2018-07-30 11:28
author: venhow
comments: true
categories: [IT资讯]
---
As a follow-up to my prior guide on how to use Sci-hub to download academic papers for free, here’s a simple guide to use Library Gensis aka. Libgen.

Library Genesis is another guerilla open access project, also run by people from the Russia-sphere. It’s relatively easy to use.

1. Go to the Libgen website

There’s a few URLs, but I generally use this version:

gen.lib.rus.ec/

If it’s blocked, use one of the many open proxies. For instance, hide.me works for this (I used the USA exit). If the domain is taken down, find a new one via Wikipedia.

2. Search for some book you want

Enter the title (and maybe author name) of some book you want. Here we pretend we want to read Lee Jussim’s great book on social psychology:

Jussim, L. (2012). Social perception and social reality: Why accuracy dominates bias and self-fulfilling prophecy. OUP USA.

Enjoy!

FROM: http://emilkirkegaard.dk/en/?p=7172


text:
# pyhccb
Microsoft HCCB (High Capacity Color Barcodes) implementation by Python. NOT completed.
## Reference
Microsoft Search [High Capacity Color Barcodes (HCCB)](https://www.microsoft.com/en-us/research/project/high-capacity-color-barcodes-hccb/?from=http%3A%2F%2Fresearch.microsoft.com%2Fen-us%2Fprojects%2Fhccb%2F)

github [High Capacity Color Barcode (HCCB) Elm library](https://github.com/canadaduane/elm-hccb)

github [david-redick/lizzi](https://github.com/david-redick/lizzi)

[Specifications For Popular 2D Bar Codes](http://www.adams1.com/stack.html)

repository: sunnylgz/pyhccb

repo_name: sunnylgz/pyhccb


text:
# Jenkins image built with Source To Image

This readme will show how to build a Jenkins Controller from an openshift base image with source to image.

## Install source-to-image on MacOS

    brew install source-to-image

## Build a new image from local directory s2i

    cd s2i
    s2i build . openshift/jenkins-2-centos7 renezubcevic/jenkins-s2i
    docker run --name jenkins-s2i -d -e JENKINS_PASSWORD=password -p 8080:8081 -p 50000:50000 renezubcevic/jenkins-s2i

repository: zubcevic/jenkins-controller

branch_name: refs/heads/main

repo_name: zubcevic/jenkins-controller


text:
The two subdirectories `aarch64` and `x64` contain tiny makefile
include files (`*.mk`) which specify which drivers should be linked
and enabled into kernel.

The `base.mk` is the file included last by the main makefile and is
intended to disable all drivers unless enabled specifically in a
given profile file. For example, each driver configuration variable
like `conf_drivers_virtio_fs` is disabled in a line in the `base.mk` like this:
```make
export conf_drivers_virtio_fs?=0
```
but would be enabled by this line in the `virtio-pci.mk`:
```make
conf_drivers_virtio_fs?=1
```
if the profile `virtio-pci` is selected when building the kernel like so:
```bash
./scripts/build fs=rofs conf_hide_symbols=1 image=native-example drivers_profile=virtio-pci
```
The `base.mk` also enforces some dependencies between given driver and other kernel
components. For example this line:
```make
ifeq ($(conf_drivers_hpet),1)
export conf_drivers_acpi?=1
endif
```
enables ACPI support if the hpet driver is selected. There is also another rule that
enables PCI support if ACPI is selected. And so on.

The individual files under given architecture directory other than `base.mk` enable
list of drivers for each profile that typically corresponds to a hypervisor like `vbox.mk`
for Virtual Box or a type of hypervisor like `microvm.mk`. One exception is the `all.mk`
file which enables all drivers and is a default profile.

Please note that one can build custom kernel with specific list of drivers by passing
corresponding `conf_drivers_*` parameters to the build script like so:
```bash
./scripts/build fs=rofs conf_hide_symbols=1 image=native-example drivers_profile=base \
  conf_drivers_acpi=1 conf_drivers_virtio_fs=1 conf_drivers_virtio_net=1 conf_drivers_pvpanic=1
```
The kernel built using the command line above comes with enough drivers to mount virtio-FS filesystem and support networking over virtio-net device.

Lastly if you want to verify which exact drivers were enabled, you can examine content of the generated `drivers-config.h` header:
```c
cat build/release/gen/include/osv/drivers_config.h
/* This file is generated automatically. */
#ifndef OSV_DRIVERS_CONFIG_H
#define OSV_DRIVERS_CONFIG_H

#define CONF_drivers_acpi 1
#define CONF_drivers_ahci 0
#define CONF_drivers_hpet 0
#define CONF_drivers_hyperv 0
#define CONF_drivers_ide 0
#define CONF_drivers_mmio 0
#define CONF_drivers_pci 1
#define CONF_drivers_pvpanic 1
#define CONF_drivers_pvscsi 0
#define CONF_drivers_scsi 0
#define CONF_drivers_vga 0
#define CONF_drivers_virtio 1
#define CONF_drivers_virtio_blk 0
#define CONF_drivers_virtio_fs 1
#define CONF_drivers_virtio_net 1
#define CONF_drivers_virtio_rng 0
#define CONF_drivers_virtio_scsi 0
#define CONF_drivers_vmxnet3 0
#define CONF_drivers_xen 0

#endif
```

repository: dk-dev/osv

gha_language: C

gha_license_id: NOASSERTION

repo_name: dk-dev/osv


text:
# Entity validation for Spring/Spring Boot

[![CircleCI](https://img.shields.io/circleci/build/gh/refactorzone/spring-boot-validators)](https://circleci.com/gh/refactorzone/spring-boot-validators)
[![Maven Central](https://img.shields.io/maven-central/v/zone.refactor.spring/validation)](https://search.maven.org/search?q=g:zone.refactor.spring%20AND%20a:validation)
[![Code Quality](https://img.shields.io/lgtm/grade/java/g/refactorzone/spring-boot-validators.svg)](https://lgtm.com/projects/g/refactorzone/spring-boot-validators/)
[![Codecov](https://img.shields.io/codecov/c/gh/refactorzone/spring-boot-validators)](https://codecov.io/gh/refactorzone/spring-boot-validators)
[![GitHub last commit](https://img.shields.io/github/last-commit/refactorzone/spring-boot-validators)](https://github.com/refactorzone/spring-boot-validators)
[![GitHub top language](https://img.shields.io/github/languages/top/refactorzone/spring-boot-validators.svg)](https://github.com/refactorzone/spring-boot-validators)
[![GitHub repo size](https://img.shields.io/github/repo-size/refactorzone/spring-boot-validators.svg)](https://github.com/refactorzone/spring-boot-validators)
[![GitHub issues](https://img.shields.io/github/issues/refactorzone/spring-boot-validators.svg)](https://github.com/refactorzone/spring-boot-validators/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/refactorzone/spring-boot-validators.svg)](https://github.com/refactorzone/spring-boot-validators/pulls)
[![GitHub](https://img.shields.io/github/license/refactorzone/spring-boot-validators)](https://github.com/refactorzone/spring-boot-validators/blob/master/LICENSE.md)

> **Warning!** This repository is in early development! Some parts of the API may change until the 1.0 version.
> If you decide to use it, make sure you key your dependency to a specific version in Maven/Gradle!

This package provides validation for Spring and Spring Boot by collecting all fields from the input and then
validating them all at once. The returned object can be used to display all errors on a form.

For example, you could create a controller like this:

```java
public class HelloController {
    @RequestMapping("/hello")
    public String hello(
        @RequestParam
        @ApiParam(allowableValues="range(1,infinity)")
        String name
    ) {
        return "Hello, " + name;
    }
}
```

In this case the `@ApiParam` annotation, which normally serves Swagger documentation, will be used for validation
purposes. This library supports Swagger and Java validation constraints.

## Installation

This package can be installed from Maven Central:

```xml
<dependency>
    <groupId>zone.refactor.spring</groupId>
    <artifactId>validation</artifactId>
</dependency>
```

## Usage with Spring Boot

The library includes bindings for Spring Boot to automatically parse various annotations and use them as validators,
such as:

- Swagger annotations (e.g. `@ApiOperation`)
- Java constraints (e.g. `@Max`)

However, in order to use the automatic validation, you will need to provide a factory to throw exceptions.

```java
import zone.refactor.spring.validation.chain.ExceptionFactory;

@Service
class ValidationExceptionFactory extends ExceptionFactory<MyValidationException> {
    @Override
    void create(Map<String, Collection<String>> errors) throws MyValidationException {
        throw new MyValidationException();
    }
}
```

The `errors` parameter will contain a key-value set where the keys are the request field names and the value is a
collection of errors.

Once you have set this up you can add annotations to your controllers. For examples see [the test controller](https://github.com/refactorzone/spring-boot-validators/blob/master/src/test/java/zone/refactor/spring/validation/annotation/TestController.java).

## Independent usage

If you wish to use the validation without the annotation processing you can do so using the `ValidatorChain` class:

```java
ValidatorChain<String> validatorChain = new ValidatorChain<>(
    exceptionFactory
);

validatorChain.addValidator(
    "my-required-field",
    new RequiredValidator<String>()
);

Map<String, String> data = new HashMap<>();
data.put("my-required-field", "my-value");

//Throws exception if validation fails.
validatorChain.validate(data);
```

As before, the ValidatorChain requires an `ExceptionFactory` implementation. This factory is responsible
for creating a validation factory is the validation fails. This is done such that the actual exception type is flexible.

## Writing validators

If you wish to implement a custom validator, you may do so by implementing the `Validator` interface:

```java
public interface Validator {
    String getErrorKey();
    boolean isValid(@Nullable Object value);
}
```

The `getErrorKey` function is supposed to return a unique error key to identify the error.

The `isValid` method should return true if the passed value is valid. Special attention should be paid that the
value may be a type you don't expect.

repository: janosdebugs/spring-boot-validators

repo_name: janosdebugs/spring-boot-validators


text:
# Munchy MCLeaks Detector
A bot that detects MCLeaks accounts and has it's own commands.

## Usage
Used on munchymc.com, was accessible by either doing /msg <bot name> .<command> or typing in chat .<command>
![Example Image](http://image.prntscr.com/image/953d24d155d54ef290bd1fdd67f7b65a.png)

When an MCLeaks account joined, the bot would message all online players who weren't unsubscribed a warning.

#### This is a Forge mod and is intended for Minecraft version `1.8.9`
![Forge image from MinecraftAscending](http://www.minecraftascending.com/images/projects/downloads/large/minecraft_forge_download.png)

The mod is `discontinued` and will no longer be worked on.

repository: TheMrGong/MunchyMCLeaksDetector

repo_name: TheMrGong/MunchyMCLeaksDetector


text:
---
layout: post
title: Service Container
subtitle:
description: is the object that lets all service providers register themselves and their dependencies
image: /assets/img/unsplash/service_container.jpg
category: laravel
tags:
  - class
  - container
author: pforret
---

## Definition
> The Laravel service container is a powerful tool for managing class dependencies and performing dependency injection • [laravel.com](https://laravel.com/docs/8.x/container)

All [service providers](/service-provider) register themselves in the service container.

## Usage

## Examples

## References

* [Laravel Docs: Container](https://laravel.com/docs/8.x/container)
* [Laravel Service Container for dummies](https://medium.com/@barfiagyenim/laravel-service-containers-for-dummies-c29ab315683b)
* [PHP FIG: PSR-11 Container interface](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md)
* [Laracasts: Service Container](https://laracasts.com/series/laravel-6-from-scratch/episodes/38)

repository: pforret/laravel-lexicon-docsy

repo_name: pforret/laravel-lexicon-docsy


text:
# Blog - OMS to Slack
Support for the blog posts at [tjaddison.com](http://tjaddison.com)

Contains various implementations of Azure functions (as scripts or class libraries) that allow an OMS alert to send a Slack notification.

Post Index:
- [Building better OMS alerts with function apps](http://tjaddison.com/2017/08/06/Building-better-OMS-alerts-with-function-apps.html)
- [Monitoring Disk, CPU, and memory with OMS](http://tjaddison.com/2017/08/21/Monitoring-disk-cpu-and-memory-with-OMS.html)
- [Migrating function app scripts with a class library](http://tjaddison.com/2017/08/21/Monitoring-disk-cpu-and-memory-with-OMS.html)
- [Building an OMS metric alert to Slack bridge with Azure functions](http://tjaddison.com/2017/08/29/Building-an-OMS-metric-alert-to-Slack-bridge-with-Azure-functions)

repository: taddison/blog-oms-to-slack

repo_name: taddison/blog-oms-to-slack


text:
# okta_policy_password_default

[back](../okta.md)

### Index

- [Example Usage](#example-usage)
- [Variables](#variables)
- [Resource](#resource)
- [Outputs](#outputs)

### Terraform

```terraform
terraform {
  required_providers {
    okta = ">= 3.11.0"
  }
}
```

[top](#index)

### Example Usage

```terraform
module "okta_policy_password_default" {
  source = "./modules/okta/r/okta_policy_password_default"

  # call_recovery - (optional) is a type of string
  call_recovery = null
  # email_recovery - (optional) is a type of string
  email_recovery = null
  # password_auto_unlock_minutes - (optional) is a type of number
  password_auto_unlock_minutes = null
  # password_dictionary_lookup - (optional) is a type of bool
  password_dictionary_lookup = null
  # password_exclude_first_name - (optional) is a type of bool
  password_exclude_first_name = null
  # password_exclude_last_name - (optional) is a type of bool
  password_exclude_last_name = null
  # password_exclude_username - (optional) is a type of bool
  password_exclude_username = null
  # password_expire_warn_days - (optional) is a type of number
  password_expire_warn_days = null
  # password_history_count - (optional) is a type of number
  password_history_count = null
  # password_lockout_notification_channels - (optional) is a type of set of string
  password_lockout_notification_channels = []
  # password_max_age_days - (optional) is a type of number
  password_max_age_days = null
  # password_max_lockout_attempts - (optional) is a type of number
  password_max_lockout_attempts = null
  # password_min_age_minutes - (optional) is a type of number
  password_min_age_minutes = null
  # password_min_length - (optional) is a type of number
  password_min_length = null
  # password_min_lowercase - (optional) is a type of number
  password_min_lowercase = null
  # password_min_number - (optional) is a type of number
  password_min_number = null
  # password_min_symbol - (optional) is a type of number
  password_min_symbol = null
  # password_min_uppercase - (optional) is a type of number
  password_min_uppercase = null
  # password_show_lockout_failures - (optional) is a type of bool
  password_show_lockout_failures = null
  # question_min_length - (optional) is a type of number
  question_min_length = null
  # question_recovery - (optional) is a type of string
  question_recovery = null
  # recovery_email_token - (optional) is a type of number
  recovery_email_token = null
  # skip_unlock - (optional) is a type of bool
  skip_unlock = null
  # sms_recovery - (optional) is a type of string
  sms_recovery = null
}
```

[top](#index)

### Variables

```terraform
variable "call_recovery" {
  description = "(optional) - Enable or disable voice call recovery: ACTIVE or INACTIVE."
  type        = string
  default     = null
}

variable "email_recovery" {
  description = "(optional) - Enable or disable email password recovery: ACTIVE or INACTIVE."
  type        = string
  default     = null
}

variable "password_auto_unlock_minutes" {
  description = "(optional) - Number of minutes before a locked account is unlocked: 0 = no limit."
  type        = number
  default     = null
}

variable "password_dictionary_lookup" {
  description = "(optional) - Check Passwords Against Common Password Dictionary."
  type        = bool
  default     = null
}

variable "password_exclude_first_name" {
  description = "(optional) - User firstName attribute must be excluded from the password"
  type        = bool
  default     = null
}

variable "password_exclude_last_name" {
  description = "(optional) - User lastName attribute must be excluded from the password"
  type        = bool
  default     = null
}

variable "password_exclude_username" {
  description = "(optional) - If the user name must be excluded from the password."
  type        = bool
  default     = null
}

variable "password_expire_warn_days" {
  description = "(optional) - Length in days a user will be warned before password expiry: 0 = no warning."
  type        = number
  default     = null
}

variable "password_history_count" {
  description = "(optional) - Number of distinct passwords that must be created before they can be reused: 0 = none."
  type        = number
  default     = null
}

variable "password_lockout_notification_channels" {
  description = "(optional) - Notification channels to use to notify a user when their account has been locked."
  type        = set(string)
  default     = null
}

variable "password_max_age_days" {
  description = "(optional) - Length in days a password is valid before expiry: 0 = no limit."
  type        = number
  default     = null
}

variable "password_max_lockout_attempts" {
  description = "(optional) - Number of unsuccessful login attempts allowed before lockout: 0 = no limit."
  type        = number
  default     = null
}

variable "password_min_age_minutes" {
  description = "(optional) - Minimum time interval in minutes between password changes: 0 = no limit."
  type        = number
  default     = null
}

variable "password_min_length" {
  description = "(optional) - Minimum password length."
  type        = number
  default     = null
}

variable "password_min_lowercase" {
  description = "(optional) - If a password must contain at least one lower case letter: 0 = no, 1 = yes. Default = 1"
  type        = number
  default     = null
}

variable "password_min_number" {
  description = "(optional) - If a password must contain at least one number: 0 = no, 1 = yes. Default = 1"
  type        = number
  default     = null
}

variable "password_min_symbol" {
  description = "(optional) - If a password must contain at least one symbol (!@#$%^&*): 0 = no, 1 = yes. Default = 1"
  type        = number
  default     = null
}

variable "password_min_uppercase" {
  description = "(optional) - If a password must contain at least one upper case letter: 0 = no, 1 = yes. Default = 1"
  type        = number
  default     = null
}

variable "password_show_lockout_failures" {
  description = "(optional) - If a user should be informed when their account is locked."
  type        = bool
  default     = null
}

variable "question_min_length" {
  description = "(optional) - Min length of the password recovery question answer."
  type        = number
  default     = null
}

variable "question_recovery" {
  description = "(optional) - Enable or disable security question password recovery: ACTIVE or INACTIVE."
  type        = string
  default     = null
}

variable "recovery_email_token" {
  description = "(optional) - Lifetime in minutes of the recovery email token."
  type        = number
  default     = null
}

variable "skip_unlock" {
  description = "(optional) - When an Active Directory user is locked out of Okta, the Okta unlock operation should also attempt to unlock the user's Windows account."
  type        = bool
  default     = null
}

variable "sms_recovery" {
  description = "(optional) - Enable or disable SMS password recovery: ACTIVE or INACTIVE."
  type        = string
  default     = null
}
```

[top](#index)

### Resource

```terraform
resource "okta_policy_password_default" "this" {
  # call_recovery - (optional) is a type of string
  call_recovery = var.call_recovery
  # email_recovery - (optional) is a type of string
  email_recovery = var.email_recovery
  # password_auto_unlock_minutes - (optional) is a type of number
  password_auto_unlock_minutes = var.password_auto_unlock_minutes
  # password_dictionary_lookup - (optional) is a type of bool
  password_dictionary_lookup = var.password_dictionary_lookup
  # password_exclude_first_name - (optional) is a type of bool
  password_exclude_first_name = var.password_exclude_first_name
  # password_exclude_last_name - (optional) is a type of bool
  password_exclude_last_name = var.password_exclude_last_name
  # password_exclude_username - (optional) is a type of bool
  password_exclude_username = var.password_exclude_username
  # password_expire_warn_days - (optional) is a type of number
  password_expire_warn_days = var.password_expire_warn_days
  # password_history_count - (optional) is a type of number
  password_history_count = var.password_history_count
  # password_lockout_notification_channels - (optional) is a type of set of string
  password_lockout_notification_channels = var.password_lockout_notification_channels
  # password_max_age_days - (optional) is a type of number
  password_max_age_days = var.password_max_age_days
  # password_max_lockout_attempts - (optional) is a type of number
  password_max_lockout_attempts = var.password_max_lockout_attempts
  # password_min_age_minutes - (optional) is a type of number
  password_min_age_minutes = var.password_min_age_minutes
  # password_min_length - (optional) is a type of number
  password_min_length = var.password_min_length
  # password_min_lowercase - (optional) is a type of number
  password_min_lowercase = var.password_min_lowercase
  # password_min_number - (optional) is a type of number
  password_min_number = var.password_min_number
  # password_min_symbol - (optional) is a type of number
  password_min_symbol = var.password_min_symbol
  # password_min_uppercase - (optional) is a type of number
  password_min_uppercase = var.password_min_uppercase
  # password_show_lockout_failures - (optional) is a type of bool
  password_show_lockout_failures = var.password_show_lockout_failures
  # question_min_length - (optional) is a type of number
  question_min_length = var.question_min_length
  # question_recovery - (optional) is a type of string
  question_recovery = var.question_recovery
  # recovery_email_token - (optional) is a type of number
  recovery_email_token = var.recovery_email_token
  # skip_unlock - (optional) is a type of bool
  skip_unlock = var.skip_unlock
  # sms_recovery - (optional) is a type of string
  sms_recovery = var.sms_recovery
}
```

[top](#index)

### Outputs

```terraform
output "default_auth_provider" {
  description = "returns a string"
  value       = okta_policy_password_default.this.default_auth_provider
}

output "default_included_group_id" {
  description = "returns a string"
  value       = okta_policy_password_default.this.default_included_group_id
}

output "description" {
  description = "returns a string"
  value       = okta_policy_password_default.this.description
}

output "id" {
  description = "returns a string"
  value       = okta_policy_password_default.this.id
}

output "name" {
  description = "returns a string"
  value       = okta_policy_password_default.this.name
}

output "priority" {
  description = "returns a number"
  value       = okta_policy_password_default.this.priority
}

output "status" {
  description = "returns a string"
  value       = okta_policy_password_default.this.status
}

output "this" {
  value = okta_policy_password_default.this
}
```

[top](#index)

repository: chadwickalex/tfwriter

repo_name: chadwickalex/tfwriter


text:
---

copyright:
  years: 2016

---

{:shortdesc: .shortdesc}
{:new_window: target="_blank"}

Last Updated: 06 September 2016
{: .last-updated}

# Monitoring and Logging Cloud Foundry apps
{: #monitoring_logging_cloud_foundry_apps}

{{site.data.keyword.Bluemix_notm}} has a built-in logging mechanism to produce log files for your apps as they are running. In the logs, you can view the errors, warnings, and informational messages that are produced for your app. In addition, you can also configure your app to write log messages to the log file. For more information about log formats and how to view logs, see [Logging for apps running on Cloud Foundry](../monitor_log/monitoringandlogging.html#logging_for_bluemix_apps).

Monitoring your app enables you to see and control your app deployment. With monitoring, you can accomplish the following tasks:

* Collect and monitor performance information for app instances, and check whether they are functional.
* Gain insight on application operations, for example, detect the potential bottlenecks or when upgrades are required.
* Estimate resource usage and charges.

For stable operations of your deployments on {{site.data.keyword.Bluemix_notm}} platform, you want to detect problems promptly and determine causes efficiently. To accomplish this objective, keep troubleshooting in mind when you design your apps, and use services or tools for monitoring and logging when your app is deployed to {{site.data.keyword.Bluemix_notm}}.

For more information on Monitoring and Logging Cloud Foundry Applications, see [Monitoring and Logging](../monitor_log/monitoringandlogging.html).

repository: kKronstainBrown/docs

repo_name: kKronstainBrown/docs


text:
# Advanced-Building-Blocks---Enumerable

Implementation of the following enumerable methods present in Ruby:

-   #each
-   #each_with_index
-   #select
-   #all?
-   #any?
-   #none?
-   #count
-   #map
-   #inject

# Live Version

Check it on [Repl.it](https://repl.it/@TEMITAYOADELEKE/advanced-building-blocks-enumerables)

👤 **Temitayo Adeleke**

-   Github: [@lekegitrepo](https://github.com/lekegitrepo)
-   Twitter: [@leketemi](https://twitter.com/leketemi)
-   Linkedin: [linkedin](https://www.linkedin.com/in/temitayo-adeleke/)

repository: lekegitrepo/readme-files

repo_name: lekegitrepo/readme-files


text:
# react-native-step-counter

Simple step counter for react native apps

## Installation

```sh
npm install react-native-step-counter
```

## Usage

```js
import StepCounter, { useStepListener } from 'react-native-step-counter';

// call start to start listening to values from accelerometer
StepCounter.start();

// create a listener that receives a callback when accelerometer returns new values, the return value of this hook is a cleanup function
// note that you have to have called start() before starting the listener, otherwise it wont work
const removeListener = useStepListener(callback);

// somwhere later you can stop listening to values
removeListener();
StepCounter.stop();
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

repository: jnurkka/react-native-step-counter

repo_name: jnurkka/react-native-step-counter


text:
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.0.1 (2020-10-31)

### Features

- Initial implements ([68f46a2](https://github.com/acot-a11y/acot/commit/68f46a250de7793795678ece40d23d927ddd075c))

repository: Quramy/acot

repo_name: Quramy/acot


text:
---
home: true
heroImage: /hero.png
actionText: Get Started →
actionLink: /guide/
features:
- title: Simplicity First
  details: Absolutely no setup; directly runs in browser without any configuration.
- title: Vue-Powered
  details: Enjoy the complete dev experience of Vue; write with component, use webpack or CLI plugins.
- title: Shareable
  details: Keynote generates a static HTML page, and runs as an SPA once a page is loaded.
footer: MIT Licensed | Copyright © 2018 Rahul Kadyan
---

### No setup, no installation

```html
<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/vue-keynote"></script>
...
<div id="app">
  <Keynote>
    ...
  </Keynote>
</div>
<script>
  new Vue({ el: '#app' })
</script>
```

repository: znck/vue-slides

repo_name: znck/vue-slides


text:
# NTUOSS AngularJS Workshop

*by Suyash Lakhotia for NTU Open Source Society*

***Disclaimer*** *- This document is only meant to serve as a reference for the attendees of the workshop. It does not cover all the concepts or implementation details discussed during the actual workshop.*

### Workshop Details:
**When?** Friday, 26 August 2016. 6:30 PM - 8:30 PM.

**Where?** Theatre@TheNest, Innovation Centre, Nanyang Technological University

**Who?** NTU Open Source Society

### Questions?
Raise your hand at any time during the workshop or post your question on the [#tgifhacks](https://ntuoss.slack.com/messages/tgifhacks/) channel on Slack. You can also shoot me an<EMAIL_ADDRESS>later.

### Errors?
If you find any mistake (typo or anything else), please make a pull request or [post an issue](https://github.com/SuyashLakhotia/NTUOSS-AngularJSWorkshop/issues/new)! Thanks!

## What is AngularJS?
AngularJS is a powerful JavaScript framework built for dynamic web applications. It does this by extending the HTML DOM with additional attributes that make it more responsive to user actions. It also provides developers an easy way to write client-side applications in a clean MVC pattern. AngularJS is completely open source, free and used by thousands of developers around the world. It is currently licensed under the Apache license and maintained by Google.

## Prerequisites
This workshop assumes you have a basic understanding of JavaScript and other common web technologies like the Document Object Model (DOM), HTML, CSS, AJAX etc.

- Download & install a text editor of your choice ([Sublime Text](https://www.sublimetext.com/3), for example).
- Clone this repo on your local system or download the .zip [here](https://github.com/SuyashLakhotia/NTUOSS-AngularJSWorkshop/archive/master.zip) and open it up on your text editor.

## Overview of AngularJS Concepts
Because AngularJS brings with it a lot of new terminology & concepts, it is important that we have a preliminary understanding of a few basic terms listed [here](https://docs.angularjs.org/guide/concepts). Don't worry if you don't understand all of them now as you will encounter these terms in practice as we proceed with the workshop tasks.

## Task 1 - Data Binding
Data binding in AngularJS is the automatic two-way synchronization of data between the model and view components. The way that Angular implements data binding lets you treat the model as the *single-source-of-truth* in your application i.e. the view is a projection of the model at all times. When the model changes, the view reflects the change **and vice-versa**.

Let's create a simple example to demonstrate this. Open up `Task1.html` in your text editor.

**Task1.html**

```html
<!DOCTYPE html>
<html>

    <head>
        <title>Data Binding</title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
    </head>

    <body>
        <div ng-app>
            <h1>Data Binding in AngularJS</h1>
        </div>
    </body>

</html>
```

> Throughout this workshop, we'll be using a CDN to include AngularJS in our HTML files like we've done above inside the `<script>` tag. However, you can alternatively [download the source files](https://angularjs.org) or use a package manager like [Bower](https://bower.io/).

The `ng-app` directive defines where an Angular application is running on our page. In order to bind data to our view, we have to first set up a model for Angular to read data from.

Create a text box inside `<div ng-app>`.

```html
<div ng-app>
    <h1>Data Binding in AngularJS</h1>
    <input type="text" ng-model="message">
</div>
```

The `ng-model` directive tells Angular to bind the value of the input field to a property in the scope object — `$scope`.

### Binding Using `{{}}`
Now that we have a variable set up, we can bind `message` to our view using the double curly bracket syntax i.e. `{{}}`. Let's bind it to a `<p>` to display it.

```html
<div ng-app>
    <h1>Data Binding in AngularJS</h1>
    <input type="text" ng-model="message">
    <p>{{ message }}</p>
</div>
```

Now, if we start typing into the text field, we can see the text in the `<p>` tag automatically update. What is inside `{{}}` is called an Angular expression, which Angular evaluates and replaces with the result(s). Below are examples of a few more expressions you can plug into a view:

```html
<p>{{ message + message }}</p>
<p>{{ message === 'Hamilton' }}</p>
<p>{{ 2 + 3 }}</p>
```

### Binding Using `ng-bind`
As applications get bigger, it's possible that we see `{{ expression }}` being rendered on the browser for a fraction of a second while Angular is still compiling the template(s). In order to avoid this, an alternative to the `{{}}` syntax is using the `ng-bind` directive.

```html
<div ng-app>
    <h1>Data Binding in AngularJS</h1>
    <input type="text" ng-model="message">
    <p ng-bind="message"></p>
    <p ng-bind="message + message"></p>
    <p ng-bind="message === 'Hamilton'"></p>
    <p ng-bind="2 + 3"></p>
</div>
```

However, a downside to using `ng-bind` is that it replaces the entire inner text of the HTML element. For example, the following two lines serve the same purpose:

```html
<p>You typed: {{ message }}</p>
<p ng-bind="'You typed: ' + message"></p>
```

### One-Time Binding
Even though one of the main benefits of AngularJS is its continuous synchronization of data, this can end up being pretty resource intensive. Thus, one-time binding is useful when displaying data that is static or only needs to be read once from the source. This is achieved by prefixing the variable with `::`.

```html
<div ng-app>
    <h1>Data Binding in AngularJS</h1>
    <input type="text" ng-model="message" ng-init="message = 'Default'">
    <p>{{ message }}</p>
    <p>{{ ::message }}</p>
</div>
```

Here, we have also used the `ng-init` directive to initialize `message` with the value `Default`. `ng-init` is a directive that evaluates the given expression once the DOM element is initialized. However, note that `ng-init` should not be used regularly as scope variables should be initialized in your controller.

## Task 2 - Controllers
In Angular, a controller is defined by a JavaScript constructor function that is used to augment the Angular scope. When a controller is attached to the DOM via the `ng-controller` directive, Angular will instantiate a new controller object using the specified controller's constructor function. A new child scope will be created and made available as an injectable parameter to the controller's constructor function as `$scope`.

The role of controllers in Angular is to expose data to our view via `$scope` (i.e. the view model) & add functions to `$scope` that contain business logic to enhance view behavior. Presentation logic should remain within views and directives.

Open up `Task2.html` & `Task2.js` in your text editor.

**Task2.html**

```html
<!DOCTYPE html>
<html>

    <head>
        <title>Controllers</title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
        <script type="text/javascript" src="Task2.js"></script>
    </head>

    <body>
        <div ng-app="app">
            <h1>Controllers in AngularJS</h1>
        </div>
    </body>

</html>
```

Like we did in [Task 1](#task-1---data-binding), we create a simple Angular application using `ng-app`. However, we give the attribute a value this time to tell Angular which module to look for when the application *boots up*. In this case, our module's name is `app`.

Let's go ahead and create the module in `Task2.js`.

**Task2.js**

```js
var app = angular.module('app', []);
```

The first parameter in `angular.module()` defines the name of the module while the second parameter is an array of dependencies.

Now, let's create a controller by registering the controller's constructor function to the module.

**Task2.js**

```js
var app = angular.module('app', []);

app.controller('mainCtrl', function($scope) {

});
```

The `module.controller()` function accepts the name of the controller as the first parameter and the controller's constructor function as the second. Angular will pass the child scope as an object i.e. `$scope` to the controller's constructor.

Let's add some data to the `$scope` object which we can then display in our view.

**Task2.js**

```js
var app = angular.module('app', []);

app.controller('mainCtrl', function($scope) {
    $scope.message = 'Hello, NTUOSS!';
});
```

**Task2.html**

```html
<div ng-app="app">
    <h1>Controllers in AngularJS</h1>
    <div ng-controller="mainCtrl">
        <p>{{ message }}</p>
    </div>
</div>
```

In our view, we simply need to attach the controller to the DOM using the `ng-controller` directive and we can subsequently access any property stored in `$scope`.

We can also manipulate the properties stored in `$scope` using custom functions in our controller.

**Task2.js**

```js
var app = angular.module('app', []);

app.controller('mainCtrl', function($scope) {
    $scope.message = 'Hello, NTUOSS';

    $scope.updateMessage = function(newMessage) {
        $scope.message = newMessage;
    };
});
```

**Task2.html**

```html
<div ng-app="app">
    <h1>Controllers in AngularJS</h1>
    <div ng-controller="mainCtrl">
        <p>{{ message }}</p>
        <form ng-submit="updateMessage(newMessage)">
            <input type="text" ng-model="newMessage">
            <button type="submit">Update Message</button>
        </form>
    </div>
</div>
```

The `ng-submit` directive contains an Angular expression that is fired whenever the form is submitted. Now, whenever the user submits the form, the `updateMessage()` function will be called which will update the value of `$scope.message`.

### Controller As Syntax
While everything we've created so far works perfectly, things can get messy when you start nesting controllers, and thus, create nested scopes. This can make it difficult for child scopes to explicitly refer to variables in the parent scope since there is no namespacing.

```html
<div ng-controller="parentCtrl">
    <p>{{ message }}</p>
    <div ng-controller="childCtrl">
        <p>{{ message }}</p>
    </div>
</div>
```

Assuming both `parentCtrl` & `childCtrl` have variables in their scopes named `message`, the inner `<p>` can only refer to `message` in `childCtrl`'s scope.

The solution to this problem is the "controller as" syntax where the controller constructors are coded like we would code a class in JavaScript.

**Task2.js**

```js
var app = angular.module('app', []);

app.controller('mainCtrl', function() {
    var self = this;

    self.message = 'Hello, NTUOSS';

    self.updateMessage = function(newMessage) {
        self.message = newMessage;
    };
});
```

**Task2.html**

```html
<div ng-app="app">
    <h1>Controllers in AngularJS</h1>
    <div ng-controller="mainCtrl as main">
        <p>{{ main.message }}</p>
        <form ng-submit="main.updateMessage(main.newMessage)">
            <input type="text" ng-model="main.newMessage">
            <button type="submit">Update Message</button>
        </form>
    </div>
</div>
```

Using this syntax, we can explicitly refer to a particular controller when we have multiple nested controllers.

## Task 3 - Services
Angular services are substitutable objects that are wired together using dependency injection. They can be used to easily share data & functionality across the app. They are:

- **Lazily Instantiated -** Angular only instantiates a service when an application component depends on it.
- **Singletons -** Each component dependent on a service gets a reference to the single instance generated by the service factory.

Angular offers several useful services (like `$http`), but for most applications you'll also want to create your own.

Let's start with the following code:

**Task3.html**

```html
<!DOCTYPE html>
<html>

  <head>
      <title>Services</title>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
      <script type="text/javascript" src="Task3.js"></script>
  </head>

  <body>
      <div ng-app="app">
          <h1>Services in AngularJS</h1>
      </div>
  </body>

</html>
```

Let's go ahead and create a service to store messages.

**Task3.js**

```js
var app = angular.module('app', []);

app.factory('messages', function() {

});
```

We use the module factory API — `module.factory()` — to register a service.

Let's start by returning an empty object from the service. This will be the object that components which depend on this service will receive.

**Task3.js**

```js
var app = angular.module('app', []);

app.factory('messages', function() {
    var messages = {};

    return messages;
});
```

Let's add a couple properties to this object to store the messages & add new messages.

**Task3.js**

```js
var app = angular.module('app', []);

app.factory('messages', function() {
    var messages = {};

    messages.list = [];

    messages.add = function(message) {
        messages.list.push({id: messages.list.length, text: message});
    };

    return messages;
});
```

Now that our service is ready, let's add a couple controllers to our module to make use of it.

**Task3.js**

```js
app.controller('listCtrl', ['messages', function(messages) {
    var self = this;

    self.messages = messages.list;
}]);
```

**Task3.html**

```html
<div ng-app="app">
    <h1>Services in AngularJS</h1>
    <div ng-controller="listCtrl as list">
        <p ng-repeat="message in list.messages">{{ message.id }}: {{ message.text }}</p>
    </div>
</div>
```

The `ng-repeat` directive iterates over collections in a view, repeating the contents of the element where `ng-repeat` is used.

Let's create another controller & add a form below our list to dynamically add messages to our list.

**Task3.js**

```js
app.controller('addCtrl', ['messages', function(messages) {
    var self = this;

    self.addMessage = function(message) {
        messages.add(message);
    };
}]);
```

**Task3.html**

```html
<div ng-controller="addCtrl as add">
    <form ng-submit="add.addMessage(add.newMessage)">
        <input type="text" ng-model="add.newMessage">
        <button type="submit">Add Message</button>
    </form>
</div>
```

We can also set a default message in the `<input>` and clear the `<input>` when the form is submitted.

**Task3.js**

```js
app.controller('addCtrl', ['messages', function(messages) {
    var self = this;

    self.newMessage = 'Hello, NTUOSS!';

    self.addMessage = function(message) {
        messages.add(message);
        self.newMessage = '';
    };
}]);
```

## Task 4 - Filters
Filters are a simple but powerful tool in Angular. They're primarily used to filter through collections or format values returned by Angular expressions.

Let's start by listing a few names & countries in a simple view using concepts we've just learned.

**Task4.html**

```html
<!DOCTYPE html>
<html>

    <head>
        <title>Filters</title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
        <script type="text/javascript" src="Task4.js"></script>
    </head>

    <body>
        <div ng-app="app">
            <h1>Filters in AngularJS</h1>
            <div ng-controller="mainCtrl as main">
                <p ng-repeat="person in main.people">
                    {{ person.name }}, {{ person.country }}
                </p>
            </div>
        </div>
    </body>

</html>
```

**Task4.js**

```js
function mainCtrl() {
    var self = this;
    self.people = [{
        name: "Eric Simons",
        country: "USA"
    }, {
        name: "Albert Pai",
        country: "Singapore"
    }, {
        name: "Matthew Greenster",
        country: "Sweden"
    }, {
        name: "Tim Brown",
        country: "USA"
    }, {
        name: "Jake Trump",
        country: "Canada"
    }, {
        name: "Albert Potter",
        country: "Canada"
    }, {
        name: "Bob Dylan",
        country: "USA"
    }, {
        name: "Bernie Sanders",
        country: "Singapore"
    }, {
        name: "Dwayne Johnson",
        country: "USA"
    }, {
        name: "Albert Colbert",
        country: "Germany"
    }];
}

angular.module('app', [])
    .controller('mainCtrl', mainCtrl);
```

### Built-in Filters
Let's start by playing around with a couple built-in Angular filters to filter through our collection — `people`.

#### `orderBy`
The `orderBy` filter sorts the items in a collection using a particular field.

**Task4.html**

```html
<p ng-repeat="person in main.people | orderBy:'name'">
    {{ person.name }}, {{ person.country }}
</p>
```

The code above will sort the array elements using `name` in ascending order. Using `-name` will sort it in the opposite order.

#### `limitTo`
The `limitTo` filter returns the first `n` results. Using `-n` returns the last `n` results.

**Task4.html**

```html
<p ng-repeat="person in main.people | limitTo:4">
    {{ person.name }}, {{ person.country }}
</p>
```

#### `filter`
`filter` allows for filtering a collection based on a search string.

**Task4.html**

```html
<input type="text" ng-model="search"/>
<p ng-repeat="person in main.people | filter:search">
    {{ person.name }}, {{ person.country }}
</p>
```

By default, this will search all the fields in the `person` object (i.e. `name` & `country`). In order to force it to only search for the string in a particular field, the field name has to be specified in the model like so:

```html
<input type="text" ng-model="search.country"/>
```

### Chaining Filters
Angular filters can be chained together using the same pipe operator — `|`. The filters are applied sequentially on the results of the previous collection filter.

**Task4.html**

```html
<input type="text" ng-model="search"/>
<p ng-repeat="person in main.people | filter:search | limitTo:2">
    {{ person.name }}
</p>
```

### Custom Filters
You can also define your own custom filters in AngularJS. Let's define one to convert each person's name to uppercase.

**Task4.js**

```js
function mainCtrl() { ... }

function makeUpperCase() {
    return function(item) {
        return item.toUpperCase();
    };
}

angular.module('app', [])
    .filter('makeUpperCase', makeUpperCase)
    .controller('mainCtrl', mainCtrl);
```

**Task4.html**

```html
<p ng-repeat="person in main.people">
    {{ person.name | makeUpperCase}}, {{ person.country }}
</p>
```

We define the filter in `Task4.js` by creating its factory function and registering it to the module using `module.filter()`. It can then be applied to any Angular expression that returns a string like `{{ person.name }}`.

## Task ∞ - Going Forward
In closing, I would just like to say that this workshop definitely does not cover everything that AngularJS has to offer. To learn more about AngularJS, you can check out the links below:

- [http://docs.angularjs.org/](http://docs.angularjs.org/)
- [https://www.coursera.org/learn/angular-js/](https://www.coursera.org/learn/angular-js/)
- [http://ruoyusun.com/2013/05/25/things-i-wish-i-were-told-about-angular-js.html](http://ruoyusun.com/2013/05/25/things-i-wish-i-were-told-about-angular-js.html)
- [http://www.tutorialspoint.com/angularjs/angularjs_overview.htm](http://www.tutorialspoint.com/angularjs/angularjs_overview.htm)
- [https://www.codeschool.com/courses/shaping-up-with-angular-js](https://www.codeschool.com/courses/shaping-up-with-angular-js)
- [https://thinkster.io/a-better-way-to-learn-angularjs](https://thinkster.io/a-better-way-to-learn-angularjs)
- [http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651](http://code.tutsplus.com/tutorials/5-awesome-angularjs-features--net-25651)

*P.S. There is a [new version of Angular](https://angular.io/) built for mobile & desktop that got out of beta very recently.*

repository: SuyashLakhotia/NTUOSS-AngularJSWorkshop

repo_name: SuyashLakhotia/NTUOSS-AngularJSWorkshop


text:
 Championship

  Demo   |
  Project   |
  Technologies   |
  Backend   |
  Frontend

## 👹 Demo

![Championship- Animated gif demo](demo/championship-dash.gif)

## 💻 Project

This is a football game scoring project.
It was created to train the use of reactjs libraries and record scores of FIFA games.

## 👾 Technologies

This project is being developed with the following technologies:

- [Node.js][nodejs]
- [ReactJS][reactjs]
- [Framer-Motion][framermotion]
- [Material-UI][materialui]
- [Styled-Components][styled]
- [Integration Uniform with Material-ui][integration]

## 🌚 Backend

First you should have cloned this repository:
`git clone https://github.com/edumoritz/championship.git`

```
cd backend
npm install

Yo should create .env and ormconfig.json at the root of the project based on the examples
npm start
```

## 🌕 Frontend

First you should have cloned this repository:
`git clone https://github.com/edumoritz/championship.git`

```
cd frontend
npm install
npm start
```

Made with by Eduardo Moritz :wave: [Get in touch!](https://www.linkedin.com/in/eduardo-moritz-5298a0118/)

[nodejs]: https://nodejs.org/
[reactjs]: https://reactjs.org/
[framermotion]: https://www.framer.com/motion/
[materialui]: https://material-ui.com/pt/
[styled]: https://styled-components.com/
[integration]: https://www.npmjs.com/package/unform-material-ui

repository: edumoritz/championship

gha_language: TypeScript

repo_name: edumoritz/championship


text:
# rcrun

Launch scripts after RackConnect v2 automation is complete on a Linux cloud server.

## Installation

Currently only Red Hat 6, CentOS 6, and Ubuntu are supported.  There is also experimental support for systemd.

stable

```
pip install https://github.com/rackerlabs/rcrun/archive/2.0.tar.gz
```

development

```
pip install https://github.com/rackerlabs/rcrun/archive/master.tar.gz
```

## Configuration

Define your tasks as shell scripts under `/etc/rcrun.d`.
Once RackConnect automation is complete, rcrun will run all executable task scripts.
Any task script that is not marked as executable will be skipped.
All events are logged in syslog.

repository: rackerlabs/rcrun

repo_name: rackerlabs/rcrun


text:
![GitHub](https://img.shields.io/github/license/a-mccaffrey/say-my-name-say-my-name)

# say-my-name-say-my-name

## Description

A React component (with bootstrap and fontawesome icons) that allows you to add a pronunciation guide to your developer profile. This is especially useful for job-seeking since there is bias against people with non-English names (apparently recruiters can be hesitant to call people if they can't figure out their name pronunciation). This is why I wanted to share this with others.

This component is complete with tooltips to allow users to easily understand the intention of the feature, and with accessibility in mind (using audible and written pronunciations).

## Table of Contents

* [Installation](#installation)
* [License](#license)
* [Contributing](#contributing)
* [Questions](#questions)

## Installation

- All the `code` required to get started

### Clone

- Clone this repo to your local machine using `https://github.com/a-mccaffrey/say-my-name-say-my-name.git`

### Setup

1. Place the SayMyName folder (inside Components Folder) into your React project's Components folder.

2. Place the Audio folder into your Assets folder (or create an Assets folder).

3. Add your own audio recording of your name to the Audio folder. You may delete the copy of my recording (it's there for your testing ease of use to make sure it's set up properly). **Use an MP3 format.**

4. In the SayMyName.js file, replace the relative path on line 3 to your own MP3 file. Then, replace the const string on line 17 with a URL to a page with your name pronunciation (I recommend using babynames.com).

5. In the SayMyName.css file, replace the colours how you see fit. Change the styling if you'd like, too. The way it's set up is pretty tight, however. I recommend it.

6. Use the SayMyName component as a requirement anywhere else in your app and have fun. Now recruiters won't be scared to call you and pronounce your name incorrectly (we hope).

### What it should look like

![Screenshot](./Screenshot.png)

## License

This project is under the MIT license. For full license information, please [click here](https://choosealicense.com/licenses/MIT/).

## Contributing

> To get started...

### Step 1

- **Option 1**
    - 🍴 Fork this repo!

- **Option 2**
    - 👯 Clone this repo to your local machine using `https://github.com/a-mccaffrey/say-my-name-say-my-name.git`

### Step 2

- **HACK AWAY!** 🔨🔨🔨

### Step 3

- 🔃 Create a new pull request using <a href="https://github.com/a-mccaffrey/say-my-name-say-my-name.git/compare/" target="_blank">`hhttps://github.com/a-mccaffrey/say-my-name-say-my-name.git/compare/`</a>.

## Questions

Want to know more? Look me up on GitHub. My username is a-mccaffrey and my profile is [here](https://www.github.com/a-mccaffrey)

Alternatively, get in touch by emailing me at [aisling.s.mccaffrey@gmail.com](mailto:aisling.s.mccaffrey@gmail.com).


text:
# node-compat-require

> Easily allow your Node program to run in a target node version range to maximize compatibility.

[![NPM](https://img.shields.io/npm/v/node-compat-require.svg)](https://www.npmjs.com/package/node-compat-require) [![Build Status](https://travis-ci.com/transitive-bullshit/node-compat-require.svg?branch=master)](https://travis-ci.com/transitive-bullshit/node-compat-require) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

- If unsupported node version, installs the right version with **npx** and continues.
- **Targeted at CLIs** that want to maximize compatibility without sacrificing JS features.
- Use **async / await** in older versions of node.
- Optionally pin your node program to a **specific version** of node for extreme reproducibility.

## Why

A lot of Node.js CLI programs need to support older versions of Node, and in order to do so, they either:

- Resort to using deprecated ES5 syntax and carefully make sure all dependencies follow suit.
- Require the CLI to be run via Docker which is clumsy to execute (eg. no `npm install -g`).
- Rely on a complicated transpilation step in order to achieve backwards compatibility.

While transpilation is great for larger projects, it's a bit of a headache, when all you really want to do is ensure your program works for end users.

> `node-compat-require` is the simplest way of ensuring a compatible node version without sacrificing the latest & greatest node features.

## Install

This module requires `node >= 4`.

```bash
npm install --save node-compat-require
```

## Usage

```js
const compatRequire = require('node-compat-require')

compatRequire('.', { node: '>= 8' })
```

In this example, './index.js' would be required only once the Node process is `>= 8`.

See the [example folder](https://github.com/transitive-bullshit/node-compat-require/tree/master/example) for a complete example of a node program which can be run with `node >= 4` but will enforce `node >= 8` at runtime in order to support newer JS features like async / await and object destructuring.

## API

### compatRequire(path, opts)

If the current node process satisfies the given requirements, returns `require(path)`.

If the current node process does not satisfy the requirements, installs the correct version of node, re-invokes the current node program as a subprocess, and exits once the child process exits.

#### path

Type: `String`
**Required**

Path of file to require if node process satisfies constraints. This may be a relative file just like a normal node `require` statement.

#### opts

Type: `Object`
**Required**

##### opts.node

Type: `String`
**Required**

Required semver [range](https://www.npmjs.com/package/semver#ranges) for the node `process.version`.

Examples:

```js
compat('.', { node: '>= 8' })
compat('./bin', { node: '^6' })
compat('./lib/cmd', { node: '9' })
compat('./example/cli', { node: '7.10.0' })
compat('.', { node: '4 || >=9 || 6.0.0 - 7.0.0' })
```

##### opts.quiet

Type: `Boolean`
Default: `false`

Use this to optionally silence the `npx` output.

## How it works

You require `node-compat-require` and pass a desired node semver [range](https://www.npmjs.com/package/semver#ranges) (like `'>= 8'` or `'^6.0.0'`).

If the current process's node version satisfies that range, then `node-compat-require` requires the target module and returns.

If the current process does not satisfy that range, then `npx` is used to temporarily install the appropriate matching version of [node](https://www.npmjs.com/package/node) from npm and re-run the current process as a subprocess using the temporary node executable. In this case, all commandline flags, environment variables, and stdio will be inherited from the current process. The child process will again run into `node-compat-require`, only this time it will require your target module normally because the version check is satisfied. Once the child process terminates, either due to successful completion or an error, `node-compat-require` will exit the parent process with the same exit code.

**Note**: it is recommended but not required for you to invoke `node-compat-require` at the very beginning of your program.
**Note**: `node-compat-require` needs an active internet connection for `npx` to install the correct version of node.

## Related

- [npx](https://github.com/zkat/npx) - Used under the hood to execute specific versions of node from npm.
- [node](https://www.npmjs.com/package/node) - NPM package bundling different versions of node for different platforms.
- [node language features](https://node.green/) - Breakdown of supported features across different versions of node.

## License

MIT © [Travis Fischer](https://github.com/transitive-bullshit)

Support my OSS work by following me on twitter

repository: transitive-bullshit/node-compat-require

repo_name: transitive-bullshit/node-compat-require


text:
# (C++) Cracking the Coding Interview - 6th Edition
Interview Preparation

All questions were completed in under ~00:45:00 - 01:00:00 time limit

*Recommend learning more on www.geeksforgeeks.org/ for tries, heaps, etc. which are not covered enough in CTCI*

Helpful test case definitions that you can apply to testing your algorithms:
Testing Your Code

# How I Approached these Problems

1. Read the problem carefully and think about what it's asking for
2.  Draw a diagram and write down pseudo-code
4. Go through multiple examples and test your pseudo-code with those examples
5. Translate your pseudo-code to actual code
6. Always test code for edge, boundary, corner, and base cases
7. If stuck on a solution for more than one hour, do not read the code, but read the hints/approaches
8. From reading those hints/approaches, try to translate them to pseudo-code then to actual code

# Table of Contents
[Chapter 1 | Array and Strings](#chapter-1-array-and-strings)

[Chapter 2 | Linked Lists](#chapter-2-linked-lists)

[Chapter 3 | Stacks and Queues](#chapter-3-stacks-and-queues)

[Chapter 4 | Trees and Graphs](#chapter-4-trees-and-graphs)

[Chapter 5 | Bit Manipulation](#chapter-5-bit-manipulation)

[Chapter 7 | Object Oriented Design](#chapter-7-object-oriented-design)

[Chapter 8 | Recursion and Dynamic Programming](#chapter-8-recursion-and-dynamic-programming)

[Chapter 9 | System Design and Scalability](#chapter-9-system-design-and-scalability)

[Chapter 10 | Sorting and Searching](#chapter-10-sorting-and-searching)

## Chapter 1 Array and Strings
Chapter 1 | Questions & Answers

- 1.1: Is Unique

Optimized question requires doing some look-ups on the bitset documentation.

- 1.2: Check Permutation

Optimized question requires understanding word frequency and using a simple array structure.

- 1.3: URLify

Optimized question asked by Microsoft. Modifying a string from the end is useful here.

- 1.4: Permutation of Palindrome

Optimized solution requires understanding the relationship between palindromes and permutations.

- 1.5: One Away

Optimized question is tricky. Only one if-statement is needed for the equal length special case.

- 1.6: String Compression

Optimized question asked by Amazon in a Software Engineer Interview. If done without "string",
it would require multiple tedious implementations of concatenation from digits to char. Highly
recommend this question; requires some understanding of "string" library and conversions.

- 1.7: Rotate Matrix

Optimized question requires some knowledge of matrix algebra. The rest of the algorithm can be derived with a reverse strategy. C++ can pass 2-D arrays by doing "T (&array)[][]".

- 1.8: Zero Matrix

Optimized question that's a bit tricky. Biggest trick is to use row #0 and col #0 as "auxiliary" arrays to get to O(1) space complexity. Amazon supposedly asked this sort of similar question.

- 1.9: String Rotation

Optimized question requires some basic knowledge of C++ "string" library. Biggest idea is that you can double the first array, and then call the substring() function once.

## Chapter 2 Linked Lists

- 2.1: Remove Dups

Optimized question requires using mergesort or using unordered set to store the duplicates.

- 2.2: Return Kth to Last

Optimized question requires some basic knowledge of back-tracking during recursion.

- 2.3: Delete Middle Node

Optimized question requires some basic knowledge of back-tracking during recursion.

- 2.4: Partition

Optimized question (to be updated)

## Chapter 3 Stacks and Queues

## Chapter 4 Trees and Graphs

## Chapter 5 Bit Manipulation

## Chapter 7 Object Oriented Design

## Chapter 8 Recursion and Dynamic Programming

## Chapter 9 System Design and Scalability

## Chapter 10 Sorting and Searching

repository: curiousTauseef/ctci

repo_name: curiousTauseef/ctci


text:
send_riemann
============

Simple utility to send custom events to Riemann from command line.

Installation
------------

```
go get github.com/falzm/send_riemann
$GOPATH/bin/send_riemann -h
```

Usage
-----

```
send_riemann [options] <JSON-formatted Riemann event>
```

Options:

```
    -server="localhost:5555": Riemann server (host:port)
```

Riemann event JSON spec:

```javascript
 {
   "host": "hostname (default: local hostname)",
   "service": "service",
   "time": <UNIX epoch timestamp (default: now)>,
   "metric": <numeric value>,
   "state": "state (ok, warning, critical)",
   "ttl": <numeric value (seconds, default 10)>,
   "description": "some event description...",
   "tags": [ "tag1", "tag2", "tagN" ],
   "attributes": { "key1": "val1", "key2": "val2" }
 }
```

Example
-------

```
marc@cobalt:~% send_riemann -server=my.riemann.server:5555 '{"service": "blah", "metric": 42}'
```

Result in the Riemann console:

```
#riemann.codec.Event{:host "cobalt", :service "blah", :state "", :description "", :metric 42.0, :tags nil, :time<PHONE_NUMBER>, :ttl 10.0}
```

License / Copyright
-------------------

This software is released under the MIT License.

Copyright (c) 2014 Marc Falzon

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:
## SSH

secure shell protocol

## SSH command

> ssh {user}@{host}

client tools

window system: **putty** **gitbash** **cmder** ; most important thing is that **have ssh command**

下一章节 5. Saving The Day Through SSH

repository: caucoder/WebDeveloperRoadmap

repo_name: caucoder/WebDeveloperRoadmap


text:
# mathy.state

## MathyAgentState
```python
MathyAgentState(
    self,
    moves_remaining,
    problem,
    problem_type,
    reward = 0.0,
    history = None,
)
```
The state related to an agent for a given environment state
## MathyEnvState
```python
MathyEnvState(
    self,
    state: Optional[MathyEnvState] = None,
    problem: str = None,
    max_moves: int = 10,
    num_rules: int = 0,
    problem_type: str = 'mathy.unknown',
)
```
Class for holding environment state and extracting features
to be passed to the policy/value neural network.

Mutating operations all return a copy of the environment adapter
with its own state.

This allocation strategy requires more memory but removes a class
of potential issues around unintentional sharing of data and mutation
by two different sources.

### from_np
```python
MathyEnvState.from_np(input_bytes:numpy.ndarray) -> 'MathyEnvState'
```
Convert a numpy object into a state object
### from_string
```python
MathyEnvState.from_string(input_string:str) -> 'MathyEnvState'
```
Convert a string representation of state into a state object
### get_out_state
```python
MathyEnvState.get_out_state(
    self,
    problem: str,
    focus: int,
    action: int,
    moves_remaining: int,
) -> 'MathyEnvState'
```
Get the next environment state based on the current one with updated
history and agent information based on an action being taken.
### get_problem_hash
```python
MathyEnvState.get_problem_hash(self) -> List[int]
```
Return a two element array with hashed values for the current environment
namespace string.

__Example__

- `mycorp.envs.solve_impossible_problems` -> `[12375561, -2838517]`

### to_np
```python
MathyEnvState.to_np(self) -> numpy.ndarray
```
Convert a state object into a numpy representation
### to_observation
```python
MathyEnvState.to_observation(
    self,
    move_mask: Optional[List[int]] = None,
    hash_type: Optional[List[int]] = None,
    parser: Optional[mathy_core.parser.ExpressionParser] = None,
) -> mathy.state.MathyObservation
```
Convert a state into an observation
### to_start_observation
```python
MathyEnvState.to_start_observation(self) -> mathy.state.MathyObservation
```
Generate an episode start MathyObservation
### to_string
```python
MathyEnvState.to_string(self) -> str
```
Convert a state object into a string representation
## MathyEnvStateStep
```python
MathyEnvStateStep(self, /, *args, **kwargs)
```
Capture summarized environment state for a previous timestep so the
agent can use context from its history when making new predictions.
### action
the action taken
### focus
the index of the node that is acted on
### raw
the input text at the timestep
## MathyObservation
```python
MathyObservation(self, /, *args, **kwargs)
```
A featurized observation from an environment state.
### mask
0/1 mask where 0 indicates an invalid action shape=[n,]
### nodes
tree node types in the current environment state shape=[n,]
### time
float value between 0.0 and 1.0 indicating the time elapsed shape=[1,]
### type
two column hash of problem environment type shape=[2,]
### values
tree node value sequences, with non number indices set to 0.0 shape=[n,]
## MathyWindowObservation
```python
MathyWindowObservation(self, /, *args, **kwargs)
```
A featurized observation from an n-step sequence of environment states.
### mask
n-step list of node sequence masks `shape=[n, max(len(s))]`
### nodes
n-step list of node sequences `shape=[n, max(len(s))]`
### time
n-step problem time values `shape=[n, 2]`
### type
n-step problem type hash `shape=[n, 2]`
### values
n-step list of value sequences, with non number indices set to 0.0 `shape=[n, max(len(s))]`
## ObservationFeatureIndices
```python
ObservationFeatureIndices(self, /, *args, **kwargs)
```
An enumeration.
### mask
An enumeration.
### nodes
An enumeration.
### time
An enumeration.
### type
An enumeration.
### values
An enumeration.
## observations_to_window
```python
observations_to_window(
    observations: List[mathy.state.MathyObservation],
    total_length: int = None,
) -> mathy.state.MathyWindowObservation
```
Combine a sequence of observations into an observation window


text:
# Hash function Types
* Conventional (collision resistant)
* Crypto
* Locality sensitive (cluster similar items)
* Perfect
* Universal

# Conventional

### Fine tuned for
* Integers
* Strings

### Construction primitives
* Division
* Byte shift using middle square
* Multiplicative
* Additive

### Statistical tests
* Avalanche diagram
* Chi-square test
* Bit and bucket histogram

### Examples
* Jenkins
* City
* Murmur
* Bernstein
* FNV

# Crypto

### Construction primitives

* Merkle-Damgard construction

# Locality sensitive

### Examples

* Nilsimsa (locality sensitive)
* Simhash
* Minhash (set similarity)

# Perfect

# Universal

### Construction primitives
* Matrix method
* Multiplicative
* Tabulation hashing

### Examples

* Zobrist Hash (gaming - generate unique game position)

#	Fuzzy hash

### Examples
* Context triggered piecewise hash
* Semantic hash (map docs to a code)
* Geometric hash (detect image transformation)
* PhotoDNA

# gradations of hashing

https://github.com/facebook/ThreatExchange/blob/master/hashing/hashing.pdf

* Exact hash : MD5, Sha-256
* Syntactic : PhotoDNA, dHash, aHash, pHash, PDQ
* Deeper Syntactic : GIST, SIFT
* Semantic : ML algo

# Semantic Hashing

Using Autoencoders (Goodfellow, Deep Learning Chap 14, Salakhutdinov and Hinton , 2007b , 2009b )

for textual input (Salakhutdinov and Hinton , 2007b , 2009b )

for images (Torralba et al., 2008 ; Weiss et al., 2008 ; Krizhevsky and Hinton , 2011 ).

# Misc

* Rolling hash

repository: sanjosh/csdocs

repo_name: sanjosh/csdocs


text:
# Swift-File-Upload-URLSession
Image File upload with URLSession and SwiftUI image picker

### Preview Screenshot:

![system schema](https://raw.githubusercontent.com/TouhidApps/Swift-File-Upload-URLSession/main/screenshot/preview.gif)