text:
# WAAVI Sanitizer

[![Latest Version on Packagist](https://img.shields.io/packagist/v/waavi/sanitizer.svg?style=flat-square)](https://packagist.org/packages/waavi/sanitizer)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/waavi/sanitizer/master.svg?style=flat-square)](https://travis-ci.org/waavi/sanitizer)
[![Total Downloads](https://img.shields.io/packagist/dt/waavi/sanitizer.svg?style=flat-square)](https://packagist.org/packages/waavi/sanitizer)

## About WAAVI

WAAVI is a Spanish web development and product consulting agency, working with Startups and other online businesses since 2013. Need to get work done in Laravel or PHP? Contact us through [waavi.com](http://waavi.com/en/contactanos).

## Introduction

WAAVI Sanitizer provides an easy way to format user input, both through the provided filters or through custom ones that can easily be added to the sanitizer library.

Although not limited to Laravel 5 users, there are some extensions provided for this framework, like a way to easily Sanitize user input through a custom FormRequest and easier extensibility.

## Example

Given a data array with the following format:

```php
    $data = [
        'first_name'    =>  'john',
        'last_name'     =>  '<strong>DOE</strong>',
        'email'         =>  '<EMAIL_ADDRESS>        'birthdate'     =>  '06/25/1980',
        'jsonVar'       =>  '{"name":"value"}',
        'description'   =>  '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>',
        'phone'         =>  '+08(096)90-123-45q',
        'country'       =>  'GB',
        'postcode'      =>  'ab12 3de',
    ];
```
We can easily format it using our Sanitizer and the some of Sanitizer's default filters:
```php
    use \Waavi\Sanitizer\Sanitizer;

    $filters = [
        'first_name'    =>  'trim|escape|capitalize',
        'last_name'     =>  'trim|escape|capitalize',
        'email'         =>  'trim|escape|lowercase',
        'birthdate'     =>  'trim|format_date:m/d/Y, Y-m-d',
        'jsonVar'       =>  'cast:array',
        'description'   =>  'strip_tags',
        'phone'         =>  'digit',
        'country'       =>  'trim|escape|capitalize',
        'postcode'      =>  'trim|escape|uppercase|filter_if:country,GB',
    ];

    $sanitizer  = new Sanitizer($data, $filters);
    var_dump($sanitizer->sanitize());
```

Which will yield:
```php
    [
        'first_name'    =>  'John',
        'last_name'     =>  'Doe',
        'email'         =><EMAIL_ADDRESS>        'birthdate'     =>  '1980-06-25',
        'jsonVar'       =>  '["name" => "value"]',
        'description'   =>  'Test paragraph. Other text',
        'phone'         =>  '080969012345',
        'country'       =>  'GB',
        'postcode'      =>  'AB12 3DE',
    ];
```
It's usage is very similar to Laravel's Validator module, for those who are already familiar with it, although Laravel is not required to use this library.

Filters are applied in the same order they're defined in the $filters array. For each attribute, filters are separered by | and options are specified by suffixing a comma separated list of arguments (see format_date).

## Available filters

The following filters are available out of the box:

 Filter  | Description
:---------|:----------
 **trim**   | Trims a string
 **escape**    | Escapes HTML and special chars using php's filter_var
 **lowercase**    | Converts the given string to all lowercase
 **uppercase**    | Converts the given string to all uppercase
 **capitalize**    | Capitalize a string
 **cast**           | Casts a variable into the given type. Options are: integer, float, string, boolean, object, array and Laravel Collection.
 **format_date**    | Always takes two arguments, the date's given format and the target format, following DateTime notation.
 **strip_tags**    | Strip HTML and PHP tags using php's strip_tags
 **digit**    | Get only digit characters from the string
 **filter_if** | Applies filters if an attribute exactly matches value

## Adding custom filters

You can add your own filters by passing a custom filter array to the Sanitize constructor as the third parameter. For each filter name, either a closure or a full classpath to a Class implementing the Waavi\Sanitizer\Contracts\Filter interface must be provided. Closures must always accept two parameters: $value and an $options array:
```php
    class RemoveStringsFilter implements Waavi\Sanitizer\Contracts\Filter
    {
        public function apply($value, $options = [])
        {
            return str_replace($options, '', $value);
        }
    }

    $customFilters = [
        'hash'   =>  function($value, $options = []) {
                return sha1($value);
            },
        'remove_strings' => RemoveStringsFilter::class,
    ];

    $filters = [
        'secret'    =>  'hash',
        'text'      =>  'remove_strings:Curse,Words,Galore',
    ];

    $sanitize = new Sanitize($data, $filters, $customFilters);
```

## Install

To install, just run:

    composer require waavi/sanitizer ~1.0

And you're done! If you're using Laravel, in order to be able to access some extra functionality you must register both the Service provider in the providers array in config/app.php, as well as the Sanitizer Facade:

```php
    'providers' => [
        ...
        Waavi\Sanitizer\Laravel\SanitizerServiceProvider::class,
    ];

    'aliases' => [
        ...
        'Sanitizer' => Waavi\Sanitizer\Laravel\Facade::class,
    ];
```

## Laravel goodies

If you are using Laravel, you can use the Sanitizer through the Facade:
```php
    $newData = \Sanitizer::make($data, $filters)->sanitize();
```

You can also easily extend the Sanitizer library by adding your own custom filters, just like you would the Validator library in Laravel, by calling extend from a ServiceProvider like so:

```php
    \Sanitizer::extend($filterName, $closureOrClassPath);
```

You may also Sanitize input in your own FormRequests by using the SanitizesInput trait, and adding a *filters* method that returns the filters that you want applied to the input.

```php
    namespace App\Http\Requests;

    use App\Http\Requests\Request;
    use Waavi\Sanitizer\Laravel\SanitizesInput;

    class SanitizedRequest extends Request
    {
        use SanitizesInput;

        public function filters()
        {
            return [
                'name'  => 'trim|capitalize',
                'email' => 'trim',
            ];
        }

        /* ... */
```

To generate a Sanitized Request just execute the included Artisan command:

    php artisan make:sanitized-request TestSanitizedRequest

The only difference with a Laravel FormRequest is that now you'll have an extra 'fields' method in which to enter the input filters you wish to apply, and that input will be sanitized before being validated.

### License

WAAVI Sanitizer is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

repository: jehkinen/Sanitizer

repo_name: jehkinen/Sanitizer


text:
### Use input to prompt the user for a number,
### store the number entered as a float in a variable named num,
### and then print the contents of num.

```python

>>> num = float(input('Enter variable num: '))
Enter variable num: 3.4
>>> print (num)
3.4
>>>

```

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# Casper-spywen

[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)

The default theme for [Ghost](http://github.com/tryghost/ghost/) and **some personnal improvements** :

- On home page : image added between title and read-more part of each articles (link to the article added on related image)
- On defaults.hbs stucture : [prism.js](http://prismjs.com/) added
- On posts.hbs : Disqus comments module added

repository: spywen/casper-spywen

repo_name: spywen/casper-spywen


text:
# Orleans Hello World with ASP.NET Core and Redis Storage

**This sample requires redis**. Make sure to run FLUSHALL in redis-cli between samples.

This sample shows how to use Orleans with ASP.NET Core. In this case we are using Redis Storage. This means that all the messages persist beyond restart.

- Make sure you have redis installed and running.
- Run the app using `dotnet run`.
- Open `localhost:5000`
- Keep refeshing the browser. You will see the messages will continue to grow.
- Close the app. Repeat the steps. You will see that the messages persists between restarts.

We are using C# records in this sample. It works fine.

repository: dodyg/practical-aspnetcore

gha_language: C#

gha_license_id: MIT

repo_name: dodyg/practical-aspnetcore


text:
# Snapshot report for `es/parsePackResponse.test.js`

The actual snapshot is saved in `parsePackResponse.test.js.snap`.

Generated by [AVA](https://ava.li).

## parse side-band-64

> Snapshot 1

    `Counting objects: 45, done.␊
    Compressing objects:  11% (1/9)   ␍
    Compressing objects:  22% (2/9)   ␍
    Compressing objects:  33% (3/9)   ␍
    Compressing objects:  44% (4/9)   ␍
    Compressing objects:  55% (5/9)   ␍
    Compressing objects:  66% (6/9)   ␍
    Compressing objects:  77% (7/9)   ␍
    Compressing objects:  88% (8/9)   ␍
    Compressing objects: 100% (9/9)   ␍
    Compressing objects: 100% (9/9), done.␊
    Total 45 (delta 2), reused 7 (delta 0), pack-reused 36␊
    `

repository: Jet-Set-Willy/es-git

repo_name: Jet-Set-Willy/es-git


text:
# Design System Playground

#### Build and experiment with front end design systems by setting layout, typography and color controls

--

The basic idea:

1. Take a JSON theme file with design settings
2. Smash that into some components
3. Use React to change the theme state and update the components

--

A fun experiment built with [Rebass](http://jxnblk.com/rebass/) and [Styled Components](https://www.styled-components.com/).

repository: gregcorby/design-system-playground

repo_name: gregcorby/design-system-playground


text:
myRtspClient
================================================================================

This package contains a RTSP Client libraries which is based on JRTPLIB.
Under the license of Apache License V2.0.

Linux/Unix installation
--------------------------------------------------------------------------------
Now, myRtspClient installation is not supported. You can only compile the library
./myRtspClient/libmyRtspClient.a. And the headers is in ./myRtspClient/include.

Compiling based on different os-platform, you NEED to configure the
config.<os-platform> file.
For example:
Compiling based on x86, which configure use file 'config.linux':

 	$ ./genMakefiles linux

 	$ make

(Configure your cross compile tool in 'config.armlinux' first)
Compiling based on armlinux, which configure use file 'config.armlinux':

	$ ./genMakefiles armlinux

	$ make

Features
--------------------------------------------------------------------------------
Video Codec Supported:

	H264
	H265

Audio Codec Supported:

	MPA

Cast Method Supported:
	Unicast

Info
--------------------------------------------------------------------------------
Ansersion<EMAIL_ADDRESS>

repository: Wellsen/myRtspClient

repo_name: Wellsen/myRtspClient


text:
# Bazaarvoice Hosted UI Implementation Resources

This project contains information and resources to help you implement the
Bazaarvoice Hosted UI solution.

If you have any questions or encounter issues with the code in this project,
contact your Bazaarvoice Implementation or Support Engineer.

## [Cloud SEO SDKs](http://knowledge.bazaarvoice.com/wp-content/conversations/en_US/KB/Default.htm#SEO/SEO_About.htm)

All of our SEO documentation, including [SDKs](http://knowledge.bazaarvoice.com/wp-content/conversations/en_US/KB/Default.htm#SEO/Developer/SEO_Developer_Overview.htm%3FTocPath%3DImplementation%7CServer-side%2520SEO%7CImplementing%2520BVSEO%7C_____0), have moved to our public facing [Knowledgebase](http://knowledge.bazaarvoice.com/wp-content/conversations/en_US/KB/Default.htm#SEO/SEO_About.htm). Please reference those resources for the most updated information.

## [Local Provider Feed](https://github.com/bazaarvoice/HostedUIResources/tree/master/LocalProviderFeed)

Example of a local provider feed for Bazaarvoice Local, in [XML](https://github.com/bazaarvoice/HostedUIResources/tree/master/LocalProviderFeed/ExampleLocalProviderFeed.xml) format, including elements needed for the Local Brand Management features.

## [Native Import](https://github.com/bazaarvoice/HostedUIResources/tree/master/NativeImport)

Example feed for import of native content to Bazaarvoice, in [XML](https://github.com/bazaarvoice/HostedUIResources/blob/master/NativeImport/ExampleNativeImportFeed.xml) format (uses StandardClientFeed schema).

## [PIE Feed](https://github.com/bazaarvoice/HostedUIResources/tree/master/PIEFeed)

Example post-interaction (transaction) feeds, in [TXT](https://github.com/bazaarvoice/HostedUIResources/blob/master/PIEFeed/ExamplePIEFeed.txt) and [XML](https://github.com/bazaarvoice/HostedUIResources/blob/master/PIEFeed/ExamplePIEFeed.xml) formats.

## [Product Feed](https://github.com/bazaarvoice/HostedUIResources/tree/master/ProductFeed)

Example product feed, in [XML](https://github.com/bazaarvoice/HostedUIResources/blob/master/ProductFeed/ExampleProductFeed.xml) format, that includes examples for locale-specific product attributes and information for specifying product families.

## [User Authentication](https://github.com/bazaarvoice/HostedUIResources/tree/master/UserAuthentication)

Contains code in [C++](https://github.com/bazaarvoice/HostedUIResources/tree/master/UserAuthentication/cpp), [ASP.NET (C#)](https://github.com/bazaarvoice/HostedUIResources/blob/master/UserAuthentication/BazaarvoiceUtils.cs), [ASP](https://github.com/bazaarvoice/HostedUIResources/blob/master/UserAuthentication/BazaarvoiceUtils.asp), and [Java](https://github.com/bazaarvoice/HostedUIResources/blob/master/UserAuthentication/BazaarvoiceUtils.java) used to encode user authentication strings required for authenticated Bazaarvoice submissions.

---

_Copyright 2015 Bazaarvoice, Inc._

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

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

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

repository: bazaarvoice/HostedUIResources

extension: markdown

gha_language: Python

repo_name: bazaarvoice/HostedUIResources


text:
The following instructions will provide you with:

- A fresh Git repository
- Blank MySQL Database
- Fresh install of wordpress (with core files in their own subdirectory)
- Blank theme
- Set up to compile Sass via Compass
- Easy system for changing config settings outside of the repo, via local config override (`wp-config-local.php`)

You may wish to tailor this README to be specific to the site you are developing.

#Setup#

1. Clone this repo directly into the live web directory (public_html, httpdocs, etc.) of your environment:

        git clone https://github.com/mike-source/wordpress-starter.git .

    You most likely will want to remove the /.git/ directory and initiate a new git repository:

        rm -rf .git
        git init

2. Download the latest copy (or any copy you wish) of wordpress and extract it to the `/wordpress/` directory.

	Linux/Unix:

        wget http://wordpress.org/latest.tar.gz
        tar -xzvf latest.tar.gz

	OSX:

        curl -O https://wordpress.org/latest.tar.gz
        tar -xvzf latest.tar.gz

    You should probably remove the archive file too:

    	rm latest.tar.gz

     Note: The `/wordpress` directory can just take any version of wordpress, dumped into that folder. This is also excluded from the git repo, so it is very easy to swap out different versions of wordpress for testing.

3. Create databases for live, staging, development as required.

   From a linux command line this is:

        mysql -u root -p

        (enter mysql root password)

        > CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'passw0rd!';
        > CREATE DATABASE dbname;
        > GRANT ALL PRIVILEGES ON dbname.* TO dbuser@localhost;
        > exit

4. Edit `wp-config.php` adding the database details for the LIVE (production) environment, and generating the 'Authentication Unique Keys and Salts', as with a normal Wordpress install.

5. (Optional) Create a wp-config-local.php to override the database details locally.

	** For developing in multiple databases/locations it is extremely useful to be able to override certain settings in wp-config.php without committing them to the repository. This is done using an if statement in wp-config.php: **

		// If 'wp-config-local.php' exists, use those settings
		if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) {
			include( dirname( __FILE__ ) . '/wp-config-local.php' );

		// Otherwise use the below settings (live server)
		} else {

     - `wp-config.php` - contains the above if statement, along with LIVE database details which act as a fallback if no override is found.

     - `wp-config-local.php` - contains the code below, which override settings for the local database, you can also alter paths to your HOME and CONTENT directories if your site isn't in the live web directory of your vhost.

    Copy and paste the following into a new file and save as 'wp-config-local.php':

        <?php
		// Local server settings

		define('WP_ENV', 'development');

		// Local Database
		define('DB_NAME', 'starter');
		define('DB_USER', 'dbuser');
		define('DB_PASSWORD', 'dbpass');
		define('DB_HOST', 'localhost');

		// Turn on debug for local environment
		define('WP_DEBUG', true);

		define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
		define('WP_HOME',    'http://' . $_SERVER['HTTP_HOST']);
		define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');
		define('WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content');

    Update this file with your local database details, '`wp-config-local.php`' can not be included in the repository as it would override the live wp-config.php if deployed, it is excluded in .gitignore so needs to be re-added for each install.

5. Navigate to the web root in a browser and run Wordpress setup.

6. Rename theme folder and give theme a name in style.css.

7. Now you're probably seeing a blank page when navigating to the web root in browser! That's because Wordpress is looking for "twentyfifteen" (or whatever is currently the default theme) and it's been removed. Fix this by logging into the admin and selecting your theme in Appearance > Themes.

8. Now would be a good time to make an initial git commit:

        git add .
        git commit -m "Initial Commit"

#SASS via Compass#

There is nothing to stop you from simply editing the theme's main.css file (`/wp-content/themes/assets/css/main.css`), you could happily work this way and simply delete the `/assets/sass/` directory and config.rb. Some people like to stick to what they know... (even though the switch takes minutes!)

The much much much better way to work would be to use SASS (specifically SCSS). If you're in any doubt as to why you should, a quick google on the advantages should convince you, e.g. read: http://alistapart.com/article/why-sass

The time you spend learning the basics of SASS (10-20 minutes) vs. the time you'll save using SASS makes it almost a no brainer.

The main obstacle for most people will be the set up, you need a way of compiling your .scss files into a nice concatenated .css file. There are various ways to do this, this project comes with a pre-configured Compass config (/assets/config.rb).

Steps to set up:

1. Make sure Compass is installed on your dev machine: http://compass-style.org/install/

2. Navigate to `/wp-content/themes/assets/` in a terminal.

3. Run compass:

        compass watch

4. Edit a file in the /sass folder, compass will now watch for any changes to these files and recompile css/main.css whenever it detects a change. Compass will actually make a `.css` file in `/css` for every `.scss` file it finds in `/sass`, so `sass/main.scss` compiles to `css/main.css`. Compass will ignore files that begin with an underscore (files it refers to as 'partials'). If you open up `sass/main.scss`, you'll see it includes all of the partials. It should be self explanatory how this works.

5. One of the first things you'll want to take advantage of is setting variables for fonts and colours in `/assets/sass/config/_variables.scss`.

6. There is a pre-included set of css reset rules based on normalize.css in `/assets/sass/config/_reset.scss`.

Its up to you to consider how necessary all of the above is on a per project basis, files can easily be removed, this should form a good basis

repository: mike-source/wordpress-quickstarter

repo_name: mike-source/wordpress-quickstarter


text:
---
metaTitle: "PHP - Executing Upon an Array"
description: "Applying a function to each element of an array, Split array into chunks, Imploding an array into string, array_reduce, Destructuring arrays using list(), Push a Value on an Array"
---

# Executing Upon an Array

## Applying a function to each element of an array

To apply a function to every item in an array, use `array_map()`.  This will return a new array.

```php
$array = array(1,2,3,4,5);
//each array item is iterated over and gets stored in the function parameter.
$newArray = array_map(function($item) {
    return $item + 1;
}, $array);

```

`$newArray` now is `array(2,3,4,5,6);`.

Instead of using an [anonymous function](http://stackoverflow.com/documentation/php/205/anonymous-functions-closures#t=201607212047461984706), you could use a named function. The above could be written like:

```php
function addOne($item) {
    return $item + 1;
}

$array = array(1, 2, 3, 4, 5);
$newArray = array_map('addOne', $array);

```

If the named function is a class method the call of the function has to include a reference to a class object the method belongs to:

```php
class Example {
    public function addOne($item) {
        return $item + 1;
    }

    public function doCalculation() {
        $array = array(1, 2, 3, 4, 5);
        $newArray = array_map(array($this, 'addOne'), $array);
    }
}

```

Another way to apply a function to every item in an array is `array_walk()` and `array_walk_recursive()`.  The callback passed into these functions take both the key/index and value of each array item.  These functions will not return a new array, instead a boolean for success.  For example, to print every element in a simple array:

```php
$array = array(1, 2, 3, 4, 5);
array_walk($array, function($value, $key) {
    echo $value . ' ';
});
// prints "1 2 3 4 5"

```

The value parameter of the callback may be passed by reference, allowing you to change the value directly in the original array:

```php
$array = array(1, 2, 3, 4, 5);
array_walk($array, function(&$value, $key) {
    $value++;
});

```

`$array` now is `array(2,3,4,5,6);`

For nested arrays, `array_walk_recursive()` will go deeper into each sub-array:

```php
$array = array(1, array(2, 3, array(4, 5), 6);
array_walk_recursive($array, function($value, $key) {
    echo $value . ' ';
});
// prints "1 2 3 4 5 6"

```

**Note**: `array_walk` and `array_walk_recursive` let you change the value of array items, but not the keys.  Passing the keys by reference into the callback is valid but has no effect.

## Split array into chunks

[array_chunk()](http://php.net/manual/en/function.array-chunk.php) splits an array into chunks

Let's say we've following single dimensional array,

```php
$input_array = array('a', 'b', 'c', 'd', 'e');

```

Now using **array_chunk()** on above PHP array,

```php
$output_array = array_chunk($input_array, 2);

```

Above code will make chunks of 2 array elements and create a multidimensional array as follow.

```php
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => c
            [1] => d
        )

    [2] => Array
        (
            [0] => e
        )

)

```

If all the elements of the array is not evenly divided by the chunk size, last element of the output array will be remaining elements.

If we pass second argument as less then 1 then **E_WARNING** will be thrown and output array will be **NULL**.

|Parameter|Details
|---|---|---|---|---|---|---|---|---|---
|$array (array)|Input array, the array to work on
|$size (int)|Size of each chunk ( Integer value)
|$preserve_keys (boolean) (optional)|If you want output array to preserve the keys set it to **TRUE** otherwise **FALSE**.

## Imploding an array into string

`implode()` combines all the array values but looses all the key info:

```php
$arr = ['a' => "AA", 'b' => "BB", 'c' => "CC"];

echo implode(" ", $arr); // AA BB CC

```

Imploding keys can be done using `array_keys()` call:

```php
$arr = ['a' => "AA", 'b' => "BB", 'c' => "CC"];

echo implode(" ", array_keys($arr)); // a b c

```

Imploding keys with values is more complex but can be done using functional style:

```php
$arr = ['a' => "AA", 'b' => "BB", 'c' => "CC"];

echo implode(" ", array_map(function($key, $val) {
    return "$key:$val"; // function that glues key to the value
}, array_keys($arr), $arr));

// Output: a:AA b:BB c:CC

```

## array_reduce

`array_reduce` reduces array into a single value. Basically, The `array_reduce` will go through every item with the result from last iteration and produce new value to the next iteration.

Usage:
`array_reduce ($array, function($carry, $item){...}, $defaul_value_of_first_carry)`

- $carry is the result from the last round of iteration.
- $item is the value of current position in the array.

**Sum of array**

```php
$result = array_reduce([1, 2, 3, 4, 5], function($carry, $item){
    return $carry + $item;
});

```

result:`15`

**The largest number in array**

```php
$result = array_reduce([10, 23, 211, 34, 25], function($carry, $item){
        return $item > $carry ? $item : $carry;
});

```

result:`211`

**Is all item more than 100**

```php
$result = array_reduce([101, 230, 210, 341, 251], function($carry, $item){
        return $carry && $item > 100;
}, true); //default value must set true

```

result:`true`

**Is any item less than 100**

```php
$result = array_reduce([101, 230, 21, 341, 251], function($carry, $item){
        return $carry || $item < 100;
}, false);//default value must set false

```

result:`true`

**Like implode($array, $piece)**

```php
$result = array_reduce(["hello", "world", "PHP", "language"], function($carry, $item){
        return !$carry ? $item : $carry . "-" . $item ;
});

```

result:`"hello-world-PHP-language"`

if make a implode method, the source code will be :

```php
function implode_method($array, $piece){
    return array_reduce($array, function($carry, $item) use ($piece) {
            return !$carry ? $item : ($carry . $piece . $item);
    });
}

$result = implode_method(["hello", "world", "PHP", "language"], "-");

```

result:`"hello-world-PHP-language"`

## "Destructuring" arrays using list()

Use [list()](http://php.net/manual/en/function.list.php) to quick assign a list of variable values into an array. See also [compact()](http://stackoverflow.com/documentation/php/204/arrays/15737/creating-an-array-of-variables)

```php
// Assigns to $a, $b and $c the values of their respective array elements in           $array with keys numbered from zero
list($a, $b, $c) = $array;

```

With PHP 7.1 (currently in beta) you will be able to use [short list syntax](https://wiki.php.net/rfc/short_list_syntax):

```php
// Assigns to $a, $b and $c the values of their respective array elements in $array with keys numbered from zero
[$a, $b, $c] = $array;

// Assigns to $a, $b and $c the values of the array elements in $array with the keys "a", "b" and "c", respectively
["a" => $a, "b" => $b, "c" => $c] = $array;

```

## Push a Value on an Array

There are two ways to push an element to an array: `array_push` and `$array[] =`

The [array_push](http://php.net/manual/fr/function.array-push.php) is used like this:

```php
$array = [1,2,3];
$newArraySize = array_push($array, 5, 6); // The method returns the new size of the array
print_r($array); // Array is passed by reference, therefore the original array is modified to contain the new elements

```

This code will print:

```php
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 5
    [4] => 6
)

```

`$array[] =` is used like this:

```php
$array = [1,2,3];
$array[] = 5;
$array[] = 6;
print_r($array);

```

This code will print:

```php
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 5
    [4] => 6
)

```

repository: haifenghuang/generate

repo_name: haifenghuang/generate


text:
# Helm Chart for setting up auto-scaling Dask cluster on Kubernetes

Currently, under active development. **Not suitable for production use!**

## Description

The Helm chart for simple and fast setup of auto-scaling [Dask](https://github.com/dask/distributed) cluster on Kubernetes.

This project is created with help of:

- [Dask](https://dask.pydata.org/en/latest/) and [Dask distributed](https://distributed.readthedocs.io/en/latest/index.html)
- [Dask Kubernetes](https://github.com/dask/dask-kubernetes) repo
- [Dask Helm Chart](https://github.com/dask/helm-chart/tree/master/dask)

## How it works

The chart will set up a Kubernetes deployment with a single pod called *scheduler*
with permissions to create other pods in the **default** namespace.
The chart is using docker images from [this](https://github.com/VMois/dask-k8s-docker/tree/master/) repo.
The scheduler will have two ports exposed:

- **8786** for client connections
- **8787** for web dashboard

By default, the scheduler pod will launch 1 *worker* pod.
A worker will automatically connects to the scheduler.

To check external IP address of the scheduler in Kubernetes use:

```bash
$ kubectl get services
```

Now, you can use this address and connect to the scheduler.
After that you can refer to Dask Distributed [docs](https://distributed.readthedocs.io/en/latest/client.html) to perform computations.
The scheduler will automatically scale worker pods according to CPU and memory usage.

## Use cases

Later...

## How to setup

1. Install Helm on your Kubernetes cluster

2. Clone the repo:

```bash
git clone https://github.com/VMois/dask-k8s-chart.git
```

3. Install chart:

```bash
helm install dask-k8s-chart/ --name RELEASE_NAME
```

## How to customize

Later...

## Contributions

Any fixes, suggestions and improvements are welcome.
Don't hesitate to open an issue, your help is very important)

Possible ideas for contributions:

- write detailed configuration tutorial
- test cluster stability

Thank you!


text:
---
title:  Quasiconformal maps and open Riemann surfaces (continued)
speaker: Hiroshige Shiga (Tokyo Tech, Japan)
date: 25 Jan, 2019
time: 3 pm
venue: LH-1, Mathematics Department
---

In the theory of Teichmüller space of Riemann surfaces, we consider the set of Riemann surfaces which are quasiconformally equivalent. For topologically finite Riemann surfaces, it is quite easy to examine if they are quasiconformally equivalent or not. On the other hand, for Riemann surfaces of topologically infinite type, the situation is rather complicated.  In the first part of my talk, we discuss the quasiconformal equivalence for general open Riemann surfaces and give some geometric conditions for Riemann surfaces to be quasiconformally equivalent. In the second part, we consider the quasiconformal equivalence of Riemann surfaces which are the complements of Cantor sets.

repository: siddhartha-gadgil/DeptWeb

gha_language: HTML

repo_name: siddhartha-gadgil/DeptWeb


text:
---
description: You might have a defined contribution pension
tags:
  - appointments
---

# Find out your pension type

## You might have a defined contribution pension

These are sometimes known as ‘money purchase’ pensions. The amount you get depends on how much was paid in and how well the investments have done.

There are different ways you can take your defined contribution pension pot. You can book a free [Pension Wise appointment](/appointments) to find out more.

^If you have more than one pension, you may also have a defined contribution pension – [check another pension](/pension-type-tool).^

{::feedback_form /}

gha_language: Ruby


text:
# docs.clearelection.org

This repo contains the static site generator for docs.clearelection.org

It's a [Middleman 3.x](http://middlemanapp.com/) project using [Compass](http://compass-style.org)/[SASS](http://sass-lang.com/), [HAML](http://haml-lang.com/), [Coffeescript](http://coffeescript.org), [bower](http://Bower.io), and [Foundation](http://foundation.zurb.com), among other things.

Important commands:

* `bundle update`
* `bower update`
* `middleman server` - test on `http://localhost:4567`
* `rake release` - push to live site.  Requires a local file `keys/aws.yml` (.gitignore'd) with the appropriate AWS authorization data.


text:
# Others

ISO 3103 - How to brew tea?

Pairwise distinct - All elements are unique

## Indirection

In [computer programming](https://en.wikipedia.org/wiki/Computer_programming), **indirection** (also called **dereferencing**) is the ability to reference something using a name, reference, or container instead of the value itself. The most common form of indirection is the act of manipulating a value through its [memory address](https://en.wikipedia.org/wiki/Memory_address). For example, accessing a [variable](https://en.wikipedia.org/wiki/Variable_(programming)) through the use of a [pointer](https://en.wikipedia.org/wiki/Pointer_(computer_programming)). A stored pointer that exists to provide a reference to an object by double indirection is called an *indirection node*. In some older computer architectures, indirect words supported a variety of more-or-less complicated [addressing modes](https://en.wikipedia.org/wiki/Addressing_mode).

<https://en.wikipedia.org/wiki/Indirection>

## Frequency Cap

It is a counter for unique users on a website based on session data (like cookies). There might be millions or tens of millions of users visiting a website. Frequency capping means you only show each user your ad once per day.

Redis has a [HyperLogLog data type](https://redis.io/commands/pfcount) that is perfect for a frequency cap. It approximates set membership with a very small error rate, in exchange for O(1) time and a very small memory footprint. PFADD adds an element to a HyperLogLog set. It returns 1 if your element is not in the set already, and 0 if it is in the set.

## Variadic

In [mathematics](https://en.wikipedia.org/wiki/Mathematics) and in [computer programming](https://en.wikipedia.org/wiki/Computer_programming), a **variadic function** is a [function](https://en.wikipedia.org/wiki/Function_(programming)) of indefinite [arity](https://en.wikipedia.org/wiki/Arity), i.e., one which accepts a variable number of [arguments](https://en.wikipedia.org/wiki/Argument_(computer_science)). Support for variadic functions differs widely among [programming languages](https://en.wikipedia.org/wiki/Programming_language).

<https://en.wikipedia.org/wiki/Variadic_function>

## Internationalization ("i18n")

Internationalization ("i18n") is the process of adapting app code to other languages. For example, an app might need to display data in a different format, prices, or numbers with the correct decimal or thousands separators, or even handling whether text is written right-to-left or left-to-right. It also requires taking into account the user's timezone.

## Localization ("l10n")

Localization ("l10n"), is the process of preparing the content of the app to be available in different languages. This includes translating most of the app's resources, like texts, images, and sounds. Resources for different languages are usually kept in different files or directories, and the OS chooses the right one based on user settings.
Translation (T9N)

## Globalization (G11N) -> T9N + L10N + I18N

## Time in human terms (Real cost)

| **Access type**                | **Actual time** | **Approximated time** |
|--------------------------------|-----------------|-----------------------|
| 1 CPU cycle                    | 0.3 ns          | 1 s                   |
| Level 1 cache access           | 0.9 ns          | 3 s                   |
| Level 2 cache access           | 2.8 ns          | 9 s                   |
| Level 3 cache access           | 12.9 ns         | 43 s                  |
| Main memory access             | 120 ns          | 6 min                 |
| Solid-state disk I/O           | 50-150 μs       | 2-6 days              |
| Rotational disk I/O            | 1-10 ms         | 1-12 months           |
| Internet: SF to NYC            | 40 ms           | 4 years               |
| Internet: SF to UK             | 81 ms           | 8 years               |
| Internet: SF to Australia      | 183 ms          | 19 years              |
| OS virtualization reboot       | 4 s             | 423 years             |
| SCSI command time-out          | 30 s            | 3000 years            |
| Hardware virtualization reboot | 40 s            | 4000 years            |
| Physical system reboot         | 5 m             | 32 millenia           |

<https://blog.codinghorror.com/the-infinite-space-between-words>

### Responsiveness matters

- Walmart has found a sharp decline in conversion rates as latency climbs from 1s to 4s.
- Amazon found that every 100ms of latency cost them 1% in sales.
- Estimates from Akamai show that a 1s delay in page response can result in a 7% reduction in conversions.

![image](../../media/Others-image2-general.jpg)

RAIL Model - <https://web.dev/rail>

## Linear-feedback shift register (LSFR)

In [computing](https://en.wikipedia.org/wiki/Computing), alinear-feedback shift register(LFSR) is a [shift register](https://en.wikipedia.org/wiki/Shift_register) whose input bit is a [linear function](https://en.wikipedia.org/wiki/Linear#Boolean_functions) of its previous state.

The most commonly used linear function of single bits is [exclusive-or](https://en.wikipedia.org/wiki/Exclusive-or)(XOR). Thus, an LFSR is most often a shift register whose input bit is driven by the XOR of some bits of the overall shift register value.

The initial value of the LFSR is called the seed, and because the operation of the register is deterministic, the stream of values produced by the register is completely determined by its current (or previous) state. Likewise, because the register has a finite number of possible states, it must eventually enter a repeating cycle. However, an LFSR with a [well-chosen feedback function](https://en.wikipedia.org/wiki/Primitive_polynomial_(field_theory)) can produce a sequence of bits that appears random and has a [very long cycle](https://en.wikipedia.org/wiki/Maximal_length_sequence).

Applications of LFSRs include generating [pseudo-random numbers](https://en.wikipedia.org/wiki/Pseudorandomness), [pseudo-noise sequences](https://en.wikipedia.org/wiki/Pseudorandom_noise), fast digital counters, and [whitening sequences](https://en.wikipedia.org/wiki/Whitening_sequences). Both hardware and software implementations of LFSRs are common.

The mathematics of a [cyclic redundancy check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check), used to provide a quick check against transmission errors, are closely related to those of an LFSR.In general, the arithmetics behind LFSRs makes them very elegant as an object to study and implement. One can produce relatively complex logics with simple building blocks. However, other methods, that are less elegant but perform better, should be considered as well.

<https://en.wikipedia.org/wiki/Linear-feedback_shift_register>

gha_language: JavaScript


text:
## Handling alerts for Subscribers
**OBJECTIVE**

The Audience for this troubleshooting document would be internal Engineering
and Operations personnel who might or might not have enough background on the
component. Please provide instructions detailed enough with links as appropriate
to ensure that a novice batman can diagnose production issues and provide
emergency on call support for the component at hand without the need for
searching other documents.

## REFERENCES

#### TERMINOLOGY

Detail component specific terminology (if applicable)

#### DEPLOYMENT ARCHITECTURE

        Alert
        Source
        Severity
        Diagnostic Steps
        Recovery Instructions

            Core Dump Check
            nagios
            severity

Steps for assessing the symptoms, gathering data points and diagnosing the
potential causes for the Alert.

Command line

More text.

            Recovery Steps

license: Unlicense


text:
# CrashOps iOS SDK
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![](https://img.shields.io/cocoapods/p/CrashOps.svg?style=flat)](https://cocoapods.org/pods/CrashOps)

CrashOps lets you monitor your app's stability and vulnerability by giving you error and crash reports, supported by CrashOps servers.

## Installation
### 🔌 & ▶
### Install via CocoaPods
[![](https://img.shields.io/cocoapods/v/CrashOps.svg?style=flat)](https://cocoapods.org/pods/CrashOps)

You want to add `pod 'CrashOps'` similar to the following to your Podfile:
```
target 'MyApp' do
  pod 'CrashOps', '0.3.16'
end
```
Then run a `pod install` in your terminal, or from CocoaPods app.

## Usage

### Set Application Key

To recognize your app in CrashOps servers you need an application key, you can set it via code (programmatically) either via config file.

#### Set an application key via code
```Swift
import CrashOps

// Swift
CrashOps.shared().appKey = "app's-key-received-from-CrashOps-support"
```

```Objective-C
#import <CrashOps/CrashOps.h>

// Objective-C
[CrashOps shared].appKey = @"app's-key-received-from-CrashOps-support";
```

#### Set an application key via config file

Use the [CrashOpsConfig-info.plist file](https://github.com/CrashOps/iOS-SDK/blob/v0.1.0-going-live/CrashOps/SupportingFiles/example-for-optional-info-plist/CrashOpsConfig-info.plist#L11) and place it in your project.

### How do I turn CrashOps off / on?
By default, CrashOps is enabled and it runs automatically as your app runs  (plug n' play) but you always can control and enable / disable its behavior with two approaches: dynamically or statically.

**Dynamically:** Programmatically change the value (using code) of the variable `isEnabled` as demonstrated here:
```Swift
import CrashOps

// Swift
CrashOps.shared().isEnabled = false // The default value is 'true'
```

```Objective-C
#import <CrashOps/CrashOps.h>

// Objective-C
[CrashOps shared].isEnabled = NO; // The default value is 'YES'
```

**Statically:** Add a [CrashOpsConfig-info.plist file](https://github.com/CrashOps/iOS-SDK/blob/v0.1.0-going-live/CrashOps/SupportingFiles/example-for-optional-info-plist/CrashOpsConfig-info.plist#L11) to your project and CrashOps will read it in every app launch (using this method can still be overridden by the dynamic approach).

## Acknowledgments

CrashOps iOS library produces advanced error crash reports by using [KZCrash](https://github.com/perrzick/KZCrash) which originally forked from the awesome [KSCrash](https://github.com/kstenerud/KSCrash) library.

Enjoy!

repository: CrashOps/iOS-SDK

gha_language: C

repo_name: CrashOps/iOS-SDK


text:
# PERMANOVA
# Language: Python
# Input file: TXT file (of filenames used)
# Output file: None
# Tested with: PluMA 1.1, Python 3.6
# Dependency: numpy==1.16.0, skbio==0.5.5, csv==1.0.0

PluMA plugins that calculates a PERMANOVA test for two or more groups of samples based on a categorical factor.

The plugin takes into input a txt file listing the filenames to be used, including a dissimilarity matrix in CSV format and a
listing of samples into their respective groups in CSV format. The plugin outputs the results of the test to the screen, including the p-value and test-statistic.

repository: verociraptor/PERMANOVA

repo_name: verociraptor/PERMANOVA


text:
# GhostNet

---

model-name: GhostNet

backbone-name: GhostNet

module-type: cv-classification

fine-tunable: True

input-shape: [224, 224, 3]

model-version: 1.0

train-dataset: Oxford-IIIT Pet

accuracy: 0.824

author: Noah CVLab

update-time: 2020-09-08

repo-link: https://gitee.com/mindspore/mindspore/tree/master/model_zoo/research/cv/ghostnet

user-id: noah-cvlab

used-for: inference

train-backend: gpu

infer-backend: gpu

mindspore-version: 1.0

asset:
  -
    file-format: ckpt
    asset-link: https://download.mindspore.cn/model_zoo/research/cv/ghostnet/ghostnet_1x_pets.ckpt
    asset-sha256: 722e13be6cd6186dddcd68d5c0a50776d9a8ad8e79db3870556f68d4d2f179e4

license: Apache2.0

summary: AlexNet used to classify 37 classes of Oxford-IIIT Pet

---

## Introduction

This MindSpore Hub model uses the implementation of
GhostNet from the MindSpore model zoo on Gitee at
model_zoo/official/cv/ghostnet. The GhostNet architecture is based on
Ghost module structure which generate more features from cheap operations.
Base on a set of intrinsic features. Experiments conducted on benchmarks
demonstrate the superiority of GhostNet in terms of speed and accuracy

### Performance

#### GhostNet on ImageNet2012
| Parameters                 |                                        |   |
| -------------------------- | -------------------------------------- |---------------------------------- |
| Model Version              | GhostNet                                             |GhostNet-600|
| uploaded Date              | 09/08/2020 (month/day/year)  ；                        | 09/08/2020 (month/day/year) |
| Dataset                    | ImageNet2012                                                    | ImageNet2012|
| Parameters (M)             | 5.2                                                   | 11.9 |
| FLOPs (M) | 142 | 591 |
| Accuracy (Top1) | 73.9 |80.2   |
![flops_latency](../../static/images/ghostnet_static_img.png)
#### GhostNet on Oxford-IIIT Pet

| Parameters                 |                                        |   |
| -------------------------- | -------------------------------------- |---------------------------------- |
| Model Version              | GhostNet                                             |GhostNet-600|
| uploaded Date              | 09/08/2020 (month/day/year)  ；                        | 09/08/2020 (month/day/year) |
| Dataset                    | Oxford-IIIT Pet                                                   | Oxford-IIIT Pet|
| Parameters (M)             | 3.9                                                    | 10.6 |
| FLOPs (M) | 140 | 590 |
| Accuracy (Top1) |            82.4              |86.9   |

#### Comparison with other methods on Oxford-IIIT Pet

| Model           | FLOPs (M) | Latency (ms)* | Accuracy (Top1) |
| --------------- | --------- | ------------- | --------------- |
| MobileNetV2-1x  | 300       | 28.2          | 78.5            |
| Ghost-1x w\o SE | 138       | 19.1          | 81.1            |
| Ghost-1x        | 140       | 25.3          | 82.4            |
| Ghost-600       | 590       | -             | 86.9            |

*The latency is measured on Huawei Kirin 990 chip under single-threaded mode with batch size 1.

## Usage

```python
import mindspore_hub as mshub

from mindspore import context

context.set_context(mode=context.GRAPH_MODE,
                    device_target="GPU",
                    device_id=0)

model = "noah-cvlab/gpu/1.0/ghostnet_v1.0_oxford_pets"
network = mshub.load(model, num_classes=37)

network.set_train(False)
```

## Citation

1. Kai Han, Yunhe Wang, Qi Tian, Jianyuan Guo, Chunjing Xu, Chang Xu; Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020, pp. 1580-1589


text:
-------

![demo gif](.github/bame-demo.gif)

## Bame ?

The word **bame** come frome the portmenteau between *batch* and *rename*. **Bame** is a simple cross-plateform cli that'll help you rename several files at once.

## Usage
### Installation
**bame** can be installed using yarn or npm. It works for node version >= 8.

```shell
npm install -g bame
# or
yarn global add bame
```

### CLI

Simply run `bame` in the directory where the files you want to rename are located. Specify a regular expression with capturing groups (with parentesis) for the parts you want to keep while renaming. Then specify a string with the index of the capturing group you want to insert between braquets.

For example:

```shell
bame 'SerieName Episode (.*) Season (.*).mp4' 'SerieName - S{1}E{2}.mp4'
# SerieName Episode 1 Season 1.mp4     -->     SerieName - S1E1.mp4
# SerieName Episode 2 Season 1.mp4     -->     SerieName - S1E2.mp4
# SerieName Episode 3 Season 1.mp4     -->     SerieName - S1E3.mp4
# SerieName Episode 4 Season 1.mp4     -->     SerieName - S1E4.mp4
```

Details and optional parameters:

```shell
Usage: bame <inReg> <outReg>

Options:
  -d, --no-dir   Should not rename directories                         [boolean]
  -q, --quiet    Rename silently                                       [boolean]
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

Examples:
  bame "GoT Episode (.*) Season (.*)" "GOT.E{1}.S{2}"
```

### API
You can also integarte **bame** in som code:

```javascript
import { bame } from 'bame';

bame({
    inReg: 'GoT Episode (.*) Season (.*)',
    outReg: 'GOT.E{1}.S{2}',
    cwd: process.cwd(),
    options:{
        renameDir: true,
        verbose: true
    }
});
```

## Contribute
**Pull requests are welcome !** Feel free to contribute.

## Credits
Coded with ❤ by [Corentin Thomasset](//corentin-thomasset.fr).

The demonstartion gif has been generated using [Terminalizer](https://github.com/faressoft/terminalizer)

## License
This project is under the [MIT license](./LICENSE).

repository: CorentinTh/bame

gha_language: TypeScript

repo_name: CorentinTh/bame


text:
# Mockinizer Contributing Guidelines

some simple rules to make contributing as efficient as possible:

1. Before creating a Pull Request it is recommended to add an issue first that describes the improvement idea or bugfix.
This is a gread way to get feedback before starting to develop something.

1. When you create a Pull Request please add a link to the issue that you want to fix and include the issue number in the
branch name of your fork. Example name: `issue/11`

1. Make sure all the unit tests passing. And adding new unit tests is a good idea.

repository: donfuxx/Mockinizer

gha_language: Kotlin

repo_name: donfuxx/Mockinizer


text:
---
title: Building a high-performance platform on AWS to support real-time gaming services using Presto and Alluxio
author: Teng Wang
authorURL: https://www.linkedin.com/in/teng-wang-9b8732194/
---

**Authors:** Teng Wang, Du Li, Yu Jin and Sundeep Narravula

Electronic Arts (EA) is a leading company in the gaming industry, providing dozens of games to serve billions of users worldwide each year.
Making near real-time decisions for EA’s online services is critical for our business.
This blog describes a data platform on AWS based on Presto and Alluxio to support online services with instantaneous response within the gaming industry.

<!--truncate-->

![](/img/blog/2020-08-06-presto-in-ea/EAGames.png)

The EA Data & AI Department builds hundreds of platforms to manage petabytes of data generated by games and users everyday. These platforms consist of a wide range of data analytics, from real-time data ingestion to ETL pipelines. Formatted data produced by our department is widely adopted by executives, producers, product managers, game engineers, and designers for marketing and monetization, game design, customer engagement, player retention, and end-user experience.

## Use Cases

Near real-time information for EA’s online services is critical for making business decisions, such as campaigns and troubleshooting. These services include, but are not limited to, real-time data visualization, dashboarding, and conversational analytics. Our team is actively seeking a framework that can support these use cases.

At EA, we have adopted numerous data visualization tools, such as Tableau and Dundas, to support data insight analytics. These tools are usually connected with multiple data sources, such as MySQL DB, AWS S3, or HDFS. Users can load data from multiple endpoints simultaneously to run computationally heavy algorithms. One severe performance bottleneck is loading data as it is I/O heavy. This could be exacerbated more if the same data needs to be loaded multiple times. Thus we need a solution to reduce this data retrieving overhead by caching the data locally.

Dashboarding is another common use case, used to keep tracking user engagements, customer satisfaction, or system status in real-time. In these cases, the data volume is usually on the order of gigabytes, but frequent refreshes require instantaneous processing. Currently, we use commercial databases such as Redshift to serve time-sensitive data, and we are seeking an alternative to slash costs without losing performance.

We recently developed a reporting chatbot to provide immediate game related insights, such as live user satisfaction and real-time profit analysis. The backend of this system runs Presto with petabytes of data stored on S3. This chatbot converts user's questions into ANSI SQL and runs these queries on a Presto cluster. The queries usually conduct complex computations, such as prediction and merging after searching across datasets. We are eager to find a solution that compliments our S3 based datasets to improve the performance without introducing extra cost.

## Architecture

To serve these different use cases with near-realtime requirements, we built and evaluated Presto as our data query platform with data in S3, and the working set cached in Alluxio.
In this blog we compare a mock of the aforementioned production setup of Presto on S3 against a similar stack with Alluxio. The architecture is shown below:

![](/img/blog/2020-08-06-presto-in-ea/architecture.png)

Here are some more details about our setup:

- Each instance launched Presto and Alluxio, co-locating the two services.
- For hardware, we used three h1.8xlarge AWS instances, each with 8TB ephemeral disks mounted for use by Alluxio to cache data local to Presto.
- S3 was mounted to Alluxio as the underlying persisting file system.
- Two catalogs were configured for Presto; one connected to our existing Hive metastore, referencing the benchmark datasets externally stored on S3, and the other connected to a separate - Hive metastore with the benchmark tables created in Alluxio.
- We used the same datasets on S3 for performance comparison and pre-loaded the data into Alluxio with `alluxio fs distributedLoad /testDB`
- To optimize the query performance when  processing large amounts of small files, we enabled metadata caching in `alluxio-site.properties` to tune the performance

```
alluxio.user.metadata.cache.enabled=true
alluxio.user.metadata.cache.max.size=100000
alluxio.user.metadata.cache.expiration.time=10min
```

## Benchmark Result

Four independent benchmarks representing a wide range of different workloads were selected.
The baseline is the performance when Presto was querying S3 directly.

**Benchmark 1** is our internal synthesis snapshots of player in-game events, representing **I/O heavy use cases**.
Three datasets were tested with a total size of 1GB, 10GB, and 100GB and files in ORC format.
Each dataset is created with the same DDL, containing 49 cols, 40 varchar, 5 booleans, and 4 maps.
The benchmark queries select all columns with one varchar field filter condition.

**Result**: With caching data in Alluxio, Presto performs 2x to 7x faster compared to the baseline when querying S3 directly.

**Benchmark 2** simulates data visualization with game metadata and user engagement records.
which is a typical query that **stresses both CPU and I/O**.
With two commonly used datasets and queries frequently used in Tableau and Dundas respectively,
the queries select all columns with a date filtering condition, followed by `GROUP BY` and `ORDER BY` of the date.
In this test, we intentionally disabled Alluxio metadata caching which already shows significant improvement, to understand how data caching helps here.

**Result**: Without metadata caching, Presto with Alluxio is 2.75x faster than S3 with the Dundas dataset and 5.1x faster with the Tableau dataset.

**Benchmark 3** simulates our dashboarding use case using a dataset with **a large number of small files**. The datasets are batches of 2MB files, totalling to 50, 500, and 5000 files. The query used is a select query aggregating the number of entries for each date.

**Result**: Alluxio with metadata caching is 1.2x to 5.9x faster than S3. Without metadata caching, Alluxio is only 1x to 1.35x faster. Enabling metadata caching significantly reduces the execution time by memorizing metadata, recognizing hot data and increasing replicas.

**Benchmark 4** simulates the conversational bot. The dataset used was a snapshot of daily game performance.
The query contains **multiple stages of calculation to simulate a CPU intensive query**.
It converts an integer field into HyperLogLog, merges it, and selects the cardinality.
The results are filtered by an integer and varchar field.

**Result**: Alluxio without metadata caching shortens the timespan from 85.2 seconds to 3 seconds, which improves the performance as much as 27x.

## Conclusion

This blog explores an innovative platform with Presto as the computing engine and Alluxio as a data orchestration layer between Presto and S3 storage, to support online services with instantaneous response within the gaming industry. We evaluated this platform with real industrial examples of data visualization, dashboarding, and a conversational chatbot. Our preliminary results show that Presto with Alluxio outperforms S3 significantly in all cases. In particular, Alluxio with metadata caching shows up to 5.9x performance gain when handling large numbers of small files. Alluxio enables the separation of storage and compute by managing the allocated ephemeral disks to cache data from S3 local to Presto. Advanced cache management with an asymmetric number of replicas for hot vs. cold data accounts for performance gains in each scenario we tested.

branch_name: refs/heads/source


text:
# employee_tracker /n

 <img width="1440" alt="employee_tracker screen shot" src="https://user-images.githubusercontent.com/81401217/125211797-ccc17b00-e25d-11eb-90ea-1e918722476d.png">

 https://drive.google.com/file/d/1kbfNokqvJVbwIM0Dj43qcUa9F3FiPO4L/view

  ## Description
 This is the 12th challenege in the UCLA coding bootcamp. It is a CLI based Content Management System that allows user to manage their employees based on role and department within the company. It allows user to create, read, update and delete employees, roles and departments.
  ## Table of Contents
* [Installation](#Installation)
* [Usage](#Usage)
* [License](#License)
* [Contributing](#Contributing)
* [Badges](#Badges)
* [Tests](#Tests)
* [Questions](#Questions)
  ## Installation
* Install npm packages (run npm install)
* create database in mysql and seed information
  ## Usage
 open a terminal and run the applicaiton using node index.js command. This will promt user with 11 options (View All Employees, View All Roles, View All Departments, Add Employee, Remove Employee, Add Role, Remove Role, Add Department, Update Department, Update Employee Role, and Exit). All the 'view' options will display a table using console.table of information current in table. All the 'add' options will allow user to add information to the table based on their selection based on a series of questions about their selection. All the 'remove; options will allow users to remove information form the tables based on their selection. The 'Update Employee role' option will allow changes in employee information on the table. The Exit option will close the application connection.
  ## License
 MIT licenses

  ## Badges
 ![languages badge](https://img.shields.io/github/languages/top/Jerry4905/employee_tracker)
  ## Tests
 no test for applciaiotn added
  ## Questions
 For any questions, contact me at [Jerry4905@yahoo.com](mailto:Jerry4905@yahoo.com).

branch_name: refs/heads/main


text:
## Image Update

After making changes to files in the directory, you must run the following
commands to update the image Kokoro uses:

```shell
gcloud config set project gvisor-kokoro-testing
third_party/gvisor/kokoro/ubuntu1604/build.sh
third_party/gvisor/kokoro/ubuntu1804/build.sh
```

Note: the command above will change your default project for `gcloud`. Run
`gcloud config set project` again to revert back to your default project.

Note: Files in `third_party/gvisor/kokoro/ubuntu1804/` as symlinks to
`ubuntu1604`, therefore both images must be updated.

After the script finishes, the last few lines of the output will container the
image name. If the output was lost, you can run `build.sh` again to print the
image name.

```
NAME                    PROJECT                FAMILY  DEPRECATED  STATUS
image-6777fa4666a968c8  gvisor-kokoro-testing                      READY
+ cleanup
+ gcloud compute instances delete --quiet build-tlfrdv
Deleted [https://www.googleapis.com/compute/v1/projects/gvisor-kokoro-testing/zones/us-central1-f/instances/build-tlfrdv].
```

To setup Kokoro to use the new image, copy the image names to their
corresponding file below:

*   //devtools/kokoro/config/gcp/gvisor/ubuntu1604.gcl
*   //devtools/kokoro/config/gcp/gvisor/ubuntu1804.gcl

repository: majek/gvisor

repo_name: majek/gvisor


text:
# generator-hedley [![Build Status](https://travis-ci.org/Gizra/generator-hedley.svg?branch=master)](https://travis-ci.org/Gizra/generator-hedley)

> Scaffold a headless Drupal backend, Angular app client, and Behat tests

Hedley is a [yeoman generator](http://yeoman.io/) that scaffolds a headless Drupal backend, Angular app client, and Behat tests. Its a great starting point for learning and developing fully decoupled websites, that follow _best practices_, and includes automatic testing using Behat.

## Getting Started

### Prerequisites

* Yo (``npm install -g yo``)
* [Drush](https://github.com/drush-ops/drush)
* [Composer](https://getcomposer.org/doc/00-intro.md#globally) installed globally, for Behat dependencies to be setup

### Installation

To install generator-hedley from npm, run:

```bash
npm install -g generator-hedley
```

Finally, initiate the generator:

```bash
yo hedley
```

## CLI

You can scaffold a new app with no user interaction, for example:
```
yo hedley --skip-install --project-name=skeleton --github-repo=https://github.com/Foo/skeleton --db=skeleton --db-user=root --db-pass=root --drupal-url=http://localhost/skeleton/www
```

## Contribute

In order to develop ``generator-hedley`` and provide pull requests the following steps should be taken:

1. Git clone your fork locally.
2. ``npm install`` inside the new directory
3. ``npm link`` - This makes your local system sync with the changes you make
4. ``mkdir skeleton``
5. Inside the new directory, initiate ``yo hedley``, and make sure to keep the default project name to ``skeleton``
6. ``cp sync_hedley.example.sh sync_hedley.sh``
7. Edit ``sync_hedley.sh`` and point the the ``GENERATOR_FOLDER`` variable to the place where ``generator-hedley`` is located
8. From now on, you may easily sync back your changes back to the forked ``generator-hedley`` by executing ``./sync_hedley.sh``

## Credits

[Gizra](https://gizra.com)

## License

MIT

repository: ordavidil/generator-hedley

repo_name: ordavidil/generator-hedley


text:
---
title: Upgrade Azure Storage Persistence to Version 3
summary: Instructions on how to migrate from Azure Storage Persistence version 2 to version 3
reviewed: 2020-11-06
component: ASP
related:
 - persistence/azure-storage
redirects:
isUpgradeGuide: true
upgradeGuideCoreVersions:
 - 8
---

## Timeout storage

The [timeout manager has been removed from core](/nservicebus/upgrades/7to8/#timeout-manager-removed) which makes timeout storage obsolete.

- Any configuration APIs can safely be removed.
- Database tables must be manually removed from storage.

NOTE: There is no automatic migration of timeout data. See [Timeout manager removed - Data migration](/nservicebus/upgrades/7to8/#timeout-manager-removed-data-migration).


text:
# Exchanger

## Description

Performs all the heavy lifting internally of `exchange` and `settle` functionality.

**Source:** [contracts/Exchanger.sol](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol)

## Architecture

### Related Contracts

<centered-image>
    ![Exchanger architture graph](/img/graphs/Exchanger-architecture.svg)
</centered-image>

## Structs

### `ExchangeEntrySettlement`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L67)

| Field                    | Type      | Description |
| ------------------------ | --------- | ----------- |
| `src`                    | `bytes32` | TBA         |
| `amount`                 | `uint256` | TBA         |
| `dest`                   | `bytes32` | TBA         |
| `reclaim`                | `uint256` | TBA         |
| `rebate`                 | `uint256` | TBA         |
| `srcRoundIdAtPeriodEnd`  | `uint256` | TBA         |
| `destRoundIdAtPeriodEnd` | `uint256` | TBA         |
| `timestamp`              | `uint256` | TBA         |

## Variables

### `CIRCUIT_BREAKER_SUSPENSION_REASON`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L83)

**Type:** `uint256`

### `CONTRACT_NAME`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L78)

**Type:** `bytes32`

### `lastExchangeRate`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L85)

**Type:** `mapping(bytes32 => uint256)`

## Constructor

### `constructor`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L99)

??? example "Details"

    **Signature**

    `constructor(address _owner, address _resolver)`

    **Visibility**

    `public`

    **State Mutability**

    ``

## Views

### `calculateAmountAfterSettlement`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L290)

??? example "Details"

    **Signature**

    `calculateAmountAfterSettlement(address from, bytes32 currencyKey, uint256 amount, uint256 refunded) view returns (uint256 amountAfterSettlement)`

    **Visibility**

    `public`

    **State Mutability**

    `view`

### `feeRateForExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L718)

Determine the effective fee rate for the exchange, taking into considering swing trading.

??? example "Details"

    **Signature**

    `feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) view returns (uint256 exchangeFeeRate)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `getAmountsForExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L750)

??? example "Details"

    **Signature**

    `getAmountsForExchange(uint256 sourceAmount, bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) view returns (uint256 amountReceived, uint256 fee, uint256 exchangeFeeRate)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `hasWaitingPeriodOrSettlementOwing`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L278)

??? example "Details"

    **Signature**

    `hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) view returns (bool)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `isSynthRateInvalid`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L312)

??? example "Details"

    **Signature**

    `isSynthRateInvalid(bytes32 currencyKey) view returns (bool)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `maxSecsLeftInWaitingPeriod`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L154)

Returns the maximum number of seconds remaining in the waiting period for all exchanges into the given synth (`currencyKey`) by the account.

This number must be `0` in order for [`settle()`](#settle) to succeed.

??? example "Details"

    **Signature**

    `maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) view returns (uint256)`

    **Visibility**

    `public`

    **State Mutability**

    `view`

### `priceDeviationThresholdFactor`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L166)

**Type:** `uint256`

??? example "Details"

    **Signature**

    `priceDeviationThresholdFactor() view returns (uint256)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `resolverAddressesRequired`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L103)

??? example "Details"

    **Signature**

    `resolverAddressesRequired() view returns (bytes32[] addresses)`

    **Visibility**

    `public`

    **State Mutability**

    `view`

### `settlementOwing`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L170)

Returns the total amount to be reclaimed or rebated for the given account and synth (`currencyKey`). Note: this function can be called at any time, even while the waiting period has not expired.

??? example "Details"

    **Signature**

    `settlementOwing(address account, bytes32 currencyKey) view returns (uint256 reclaimAmount, uint256 rebateAmount, uint256 numEntries)`

    **Visibility**

    `public`

    **State Mutability**

    `view`

### `tradingRewardsEnabled`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L162)

??? example "Details"

    **Signature**

    `tradingRewardsEnabled() view returns (bool)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

### `waitingPeriodSecs`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L158)

**Type:** `uint256`

??? example "Details"

    **Signature**

    `waitingPeriodSecs() view returns (uint256)`

    **Visibility**

    `external`

    **State Mutability**

    `view`

## Restricted Functions

### `exchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L317)

??? example "Details"

    **Signature**

    `exchange(address exchangeForAddress, address from, bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bool virtualSynth, address rewardAddress, bytes32 trackingCode) returns (uint256 amountReceived, contract IVirtualSynth vSynth)`

    **Visibility**

    `external`

    **State Mutability**

    ``

    **Modifiers**

    * [onlySynthetixorSynth](#onlysynthetixorsynth)

### `resetLastExchangeRate`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L569)

??? example "Details"

    **Signature**

    `resetLastExchangeRate(bytes32[] currencyKeys)`

    **Visibility**

    `external`

    **State Mutability**

    ``

    **Requires**

    * [require(..., "Rates for given synths not valid")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L572)

    **Modifiers**

    * [onlyOwner](#onlyowner)

### `setLastExchangeRateForSynth`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L563)

??? example "Details"

    **Signature**

    `setLastExchangeRateForSynth(bytes32 currencyKey, uint256 rate)`

    **Visibility**

    `external`

    **State Mutability**

    ``

    **Requires**

    * [require(..., "Rate must be above 0")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L564)

    **Modifiers**

    * [onlyExchangeRates](#onlyexchangerates)

## Internal Functions

### `_convert`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L509)

??? example "Details"

    **Signature**

    `_convert(bytes32 sourceCurrencyKey, address from, uint256 sourceAmountAfterSettlement, bytes32 destinationCurrencyKey, uint256 amountReceived, address recipient, bool virtualSynth) returns (contract IVirtualSynth vSynth)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `_createVirtualSynth`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L533)

??? example "Details"

    **Signature**

    `_createVirtualSynth(contract IERC20, address, uint256, bytes32) returns (contract IVirtualSynth)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `_ensureCanExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L581)

??? example "Details"

    **Signature**

    `_ensureCanExchange(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey) view`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

    **Requires**

    * [require(..., "Can't be same synth")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L586)

    * [require(..., "Zero amount")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L587)

    * [require(..., "Src/dest rate invalid or not found")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L592)

### `_exchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L403)

??? example "Details"

    **Signature**

    `_exchange(address from, bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, address destinationAddress, bool virtualSynth) returns (uint256 amountReceived, uint256 fee, contract IVirtualSynth vSynth)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `_feeRateForExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L726)

??? example "Details"

    **Signature**

    `_feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) view returns (uint256 exchangeFeeRate)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_getAmountReceivedForExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L796)

??? example "Details"

    **Signature**

    `_getAmountReceivedForExchange(uint256 destinationAmount, uint256 exchangeFeeRate) pure returns (uint256 amountReceived)`

    **Visibility**

    `internal`

    **State Mutability**

    `pure`

### `_getAmountsForExchangeMinusFees`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L770)

??? example "Details"

    **Signature**

    `_getAmountsForExchangeMinusFees(uint256 sourceAmount, bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) view returns (uint256 amountReceived, uint256 fee, uint256 exchangeFeeRate, uint256 sourceRate, uint256 destinationRate)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_getExchangeEntry`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L249)

??? example "Details"

    **Signature**

    `_getExchangeEntry(address account, bytes32 currencyKey, uint256 index) view returns (struct IExchangeState.ExchangeEntry)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_internalSettle`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L635)

??? example "Details"

    **Signature**

    `_internalSettle(address from, bytes32 currencyKey, bool updateCache) returns (uint256 reclaimed, uint256 refunded, uint256 numEntriesSettled)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

    **Requires**

    * [require(..., "Cannot settle during waiting period")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L647)

### `_isDeviationAboveThreshold`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L620)

??? example "Details"

    **Signature**

    `_isDeviationAboveThreshold(uint256 base, uint256 comparison) view returns (bool)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_isSynthRateInvalid`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L595)

??? example "Details"

    **Signature**

    `_isSynthRateInvalid(bytes32 currencyKey, uint256 currentRate) view returns (bool)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_settleAndCalcSourceAmountRemaining`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L387)

??? example "Details"

    **Signature**

    `_settleAndCalcSourceAmountRemaining(uint256 sourceAmount, address from, bytes32 sourceCurrencyKey) returns (uint256 sourceAmountAfterSettlement)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `_settlementOwing`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L183)

??? example "Details"

    **Signature**

    `_settlementOwing(address account, bytes32 currencyKey) view returns (uint256 reclaimAmount, uint256 rebateAmount, uint256 numEntries, struct Exchanger.ExchangeEntrySettlement[])`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `_suspendIfRateInvalid`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L356)

??? example "Details"

    **Signature**

    `_suspendIfRateInvalid(bytes32 currencyKey, uint256 rate) returns (bool circuitBroken)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `_updateSNXIssuedDebtOnExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L365)

??? example "Details"

    **Signature**

    `_updateSNXIssuedDebtOnExchange(bytes32[2] currencyKeys, uint256[2] currencyRates)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `appendExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L804)

??? example "Details"

    **Signature**

    `appendExchange(address account, bytes32 src, uint256 amount, bytes32 dest, uint256 amountReceived, uint256 exchangeFeeRate)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

    **Emits**

    * [ExchangeEntryAppended](#exchangeentryappended)

### `debtCache`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L150)

??? example "Details"

    **Signature**

    `debtCache() view returns (contract IExchangerInternalDebtCache)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `delegateApprovals`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L142)

??? example "Details"

    **Signature**

    `delegateApprovals() view returns (contract IDelegateApprovals)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `exchangeRates`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L126)

??? example "Details"

    **Signature**

    `exchangeRates() view returns (contract IExchangeRates)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `exchangeState`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L122)

??? example "Details"

    **Signature**

    `exchangeState() view returns (contract IExchangeState)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `feePool`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L134)

??? example "Details"

    **Signature**

    `feePool() view returns (contract IFeePool)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `getRoundIdsAtPeriodEnd`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L839)

??? example "Details"

    **Signature**

    `getRoundIdsAtPeriodEnd(struct IExchangeState.ExchangeEntry exchangeEntry) view returns (uint256 srcRoundIdAtPeriodEnd, uint256 destRoundIdAtPeriodEnd)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `issuer`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L146)

??? example "Details"

    **Signature**

    `issuer() view returns (contract IIssuer)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `reclaim`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L689)

??? example "Details"

    **Signature**

    `reclaim(address from, bytes32 currencyKey, uint256 amount)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `refund`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L699)

??? example "Details"

    **Signature**

    `refund(address from, bytes32 currencyKey, uint256 amount)`

    **Visibility**

    `internal`

    **State Mutability**

    ``

### `secsLeftInWaitingPeriodForExchange`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L709)

??? example "Details"

    **Signature**

    `secsLeftInWaitingPeriodForExchange(uint256 timestamp) view returns (uint256)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `synthetix`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L130)

??? example "Details"

    **Signature**

    `synthetix() view returns (contract ISynthetix)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `systemStatus`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L118)

??? example "Details"

    **Signature**

    `systemStatus() view returns (contract ISystemStatus)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

### `tradingRewards`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L138)

??? example "Details"

    **Signature**

    `tradingRewards() view returns (contract ITradingRewards)`

    **Visibility**

    `internal`

    **State Mutability**

    `view`

## External Functions

### `settle`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L543)

Settle processes all exchanges into the given synth, calculating any `reclaimed` or `refunded` amounts via [`settlementOwing`](#settlementowing) and burning any reclaim and issuing any refund. This function may be called by anyone - the `msg.sender` is irrelevant.

??? example "Details"

    **Signature**

    `settle(address from, bytes32 currencyKey) returns (uint256 reclaimed, uint256 refunded, uint256 numEntriesSettled)`

    **Visibility**

    `external`

    **State Mutability**

    ``

### `suspendSynthWithInvalidRate`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L555)

??? example "Details"

    **Signature**

    `suspendSynthWithInvalidRate(bytes32 currencyKey)`

    **Visibility**

    `external`

    **State Mutability**

    ``

    **Requires**

    * [require(..., "No such synth")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L557)

    * [require(..., "Synth price is valid")](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L558)

## Modifiers

### `onlyExchangeRates`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L872)

### `onlySynthetixorSynth`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L863)

## Events

### `ExchangeEntryAppended`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L879)

**Signature**: `ExchangeEntryAppended(address account, bytes32 src, uint256 amount, bytes32 dest, uint256 amountReceived, uint256 exchangeFeeRate, uint256 roundIdForSrc, uint256 roundIdForDest)`

### `ExchangeEntrySettled`

[Source](https://github.com/Synthetixio/synthetix/tree/v2.52.1-ovm/contracts/Exchanger.sol#L890)

**Signature**: `ExchangeEntrySettled(address from, bytes32 src, uint256 amount, bytes32 dest, uint256 reclaim, uint256 rebate, uint256 srcRoundIdAtPeriodEnd, uint256 destRoundIdAtPeriodEnd, uint256 exchangeTimestamp)`

repository: demaa-team/synthetix-docs

repo_name: demaa-team/synthetix-docs


text:
# Week 8

1. Native app design and build assessment:
```
firefox /home/share/assessments/android/android.pdf
```

2. Creating an Android emulator on Ygritte:
```
cd
cp -r /home/studio/Android .
cd Android/Sdk/tools
./android list target
./android create avd -n yourname -t 1 --abi "default/armeabi-v7a"
./emulator -avd yourname
```

3. Installing an apk on your emulator:
```
adb -s "emulator-5554" install HelloApp-release.apk
```
## Exercise

Follow this [Tutorial](https://developer.android.com/training/basics/firstapp/index.html) to create a basic Android app.

# Week 7

1. Android SDK command line:
```
export PATH=$PATH:/home/studio/Android/Sdk/tools
android -h
```

2. Create a directory for your example android project:
```
mkdir androidstuff
cd androidstuff/
```

3 . Create an android project:
```
android create project --target 1 --name HelloApp --path ./helloapp --activity MainActivity --package com.example.helloapp
```

4 . Create a build file and build the app:
```
cd helloapp/
android update project --path .
ant release
```

5. The app will be created at bin/HelloApp-release-unsigned.apk.
```
ls bin
```

6. Only a signed app can be installed in an Android device. You can sign an apk with your own keystore.
```
keytool -genkey -v -keystore mykey.keystore -alias mykeyname -keyalg RSA -keysize 2048 -validity 365
```
Update ant.properties with your keystore info:
```
vim ant.properties

key.store=mykey.keystore
key.alias=mykeyname
key.store.password=password
key.alias.password=password
```

7. Build a signed app:
```
ant release
ls bin
```
Your app should appear as ```HelloApp-release.apk```.

8. Copy the apk file to your android device and install it.

9. [Basic Structure of an Android Project](https://www.codeproject.com/Articles/395614/Basic-structure-of-an-Android-project)

## Exercises

1. Change the name of your app.

2. Change the launcher icon for your app.

3. Add another TextView object to your main.xml layout file.

4. Add other objects to your layout file.

# Week 6

1 . [Google VR Example ](http://burgler-ferret-12012.netlify.com/vr2/googlevr.html)
```
mkdir vr
cd vr
cp -r /home/share/vr/* .
```

# Week 5

1 . [Introduction to Android](https://docs.google.com/presentation/d/1v3cFgXF55k_Pqv0fOaEDTcNAq9N5cAO2t5-bD7Ye3Bw/pub?start=false&loop=false&delayms=60000)

2 . [Android History](https://en.wikipedia.org/wiki/Android_version_history)

3 . [Android Market Share](https://qz.com/826672/android-goog-just-hit-a-record-88-market-share-of-all-smartphones/)

# Week 4
1 . Android report assessment:
```
firefox /home/share/assessments/android/mobile.pdf
```
# Week 2

1 . [Week 1 answer](https://gist.github.com/GedMullen/59e62a564e4aaf6acbca)

 2 . [Validating XML](http://www.w3schools.com/xml/xml_validator.asp)

 3 . [DTDs](http://www.w3schools.com/xml/xml_dtd.asp)

 4 . [DTD Tutorial](http://www.w3schools.com/xml/xml_dtd_intro.asp)

 5 . [Creating/Editing XML files in Eclipse](http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxedttag.html)

 6 . XML Assessment 2

 7 . [Using XSL With Eclipse ](http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.wst.xsl.doc%2Fhtml%2Flaunching%2Flaunching.html)

 8 . [XSLT Tutorial](https://www.w3schools.com/xml/xsl_intro.asp)
```
firefox /home/share/assessments/android/lo2xml.pdf
cp /home/share/assessments/android/ass2.xml .
firefox /home/share/assessments/android/lo3xml.pdf
cp /home/share/assessments/android/ass3.xml .
```

## Exercises

 1 . Add another 2 Invoice items to the invoice.xml file in the XMLExamples project in Eclipse. Change the date to a UK format. Make sure that the XML file still validates against the invoice.dtd file.

 2 . Modify the invoice.xml and invoice.dtd files in the XMLExamples project in eclipse so that a zip OR postcode can be specified. Modify the zip element in invoice.xml to test your DTD changes.

 3 . Change the name and phone attributes to elements. Test your modifications.

 4 . Add a delivery address element.

 5 . Modify the xml and dtd to allow for multiple invoices in the one XML file.

# Week 1

1 . Assessment Schedule:
```
vim /home/share/assessments/android/readme.txt
```

2 . [XML Unit Descriptor](http://www.sqa.org.uk/files/hn/FM9735.pdf)

3 . [XML Tutorial](http://www.w3schools.com/xml/)

4 . XML Assessment 1
```
firefox /home/share/assessments/android/lo1xml.pdf
```
## Exercise

1 . In groups create an XML document called "teams.xml" on Ygritte that represents the following [data](http://www.football-league.co.uk/sky-bet-championship/league-table/) (just create data for the first three teams as an example.) The XML document is to be regularly updated and provided to partner sites (such as the BBC) to display the latest league table.


text:
# Erasure Protocol

[![Build Status](https://travis-ci.com/erasureprotocol/erasure-protocol.svg?branch=master)](https://travis-ci.com/erasureprotocol/erasure-protocol)
[![Build Status](https://github.com/erasureprotocol/erasure-protocol/workflows/CI/badge.svg)](https://github.com/erasureprotocol/erasure-protocol/actions)

## Philosophy of Erasure

The Erasure Protocol builds on the three primitives of an economic relationship: Track-Record, Payment, and Recourse.

1. [Track-record through Posts and Feeds](#track-record-through-posts-and-feeds)
2. [Payments through any cryptocurrency](#payments-through-any-cryptocurrency)
3. [Recourse through Griefing](#recourse-through-griefing)

## Track-record through Posts and Feeds

`Erasure_Post` keeps track of the hash and timestamp of all the data submitted to the protocol. This serves as a proof of existence on which a track-record can be built. Creating a `Post` instance is as simple as submitting a [multihash](https://github.com/multiformats/multihash) of your data to the smart contract. At first the data is hidden, but it can be publicly revealed at a later point by uploading it to decentralized storage. A Post will be particularly useful for one-off predictions or submissions.

Extending the concept of a Post is a `Feed`. A Feed allows for a user to establish credibility through an ordered history of Post committed. Since these posts are in a single append only array, it is not possible to erase or reorder them once submitted. A Feed is designed for use-cases with continuous predictions.

The hash which is submitted to the Post contract is called a `proofHash`. A proofHash can be generated by prepending the submitted data with a user address and a user generated salt to avoid potential impersonation or snooping attacks.

```
proofHash = multihash(userAddress + salt + data)
```

## Payments through any cryptocurrency

Erasure is able to use any Ethereum-native cryptocurrencies such as ETH, WBTC and NMR within its programmable escrow smart contracts. These escrows are registered in the `Erasure_Escrow` registry which contributes to the single source of truth.

## Recourse through Griefing

Recourse is achieved when a party is punished for wrongdoing. In the world of Erasure, this translates directly to staking and burning. When two parties decide to engage, they begin by staking NMR and agreeing on a set of conditions for punishment. We call this combination of skin in the game and rules of engagement an Erasure_Agreement.

The first type of agreement used on Erasure is called `Griefing`. Griefing allows a party to come to a resolution without a third party arbitrator through punishing their counterparty at a cost. This follows research in neuroeconomics which observes that cooperation evolves in populations where altruistic punishment such as griefing is possible.

Creating a Griefing agreement is as simple as having both parties agree on their respective ratio and amount at stake. The ratio represents the cost in NMR to burn 1 NMR of the counterparty. When griefing occurs, both the cost and punishment are burned from the NMR supply forever.

Take for example an agreement between Alice and Bob. Alice is anonymous and has not built a track record. She stakes 500 NMR and selects a ratio of 0.5. Bob, however, has revealed his real-world identity and has an excellent track record. As such, he stakes 100 NMR and selects a ratio of 1.

```
Alice = { stake = 500, ratio = 0.5}
Bob = { stake = 100, ratio = 1}
Bob punishes Alice for 10 NMR => Cost is 5 NMR (10 * 0.5)
Alice punishes Bob for 10 NMR => Cost is 10 NMR (10 * 1)
new_Alice = { stake = 490, ratio = 0.5}
new_Bob = { stake = 90, ratio = 1}
```

Griefing avoids relying on a centralized oracle or a trusted third party to perform arbitration over the terms of the agreement and instead allows the parties to come to a resolution on their own. As new techniques for resolution like decentralized oracles are built on Ethereum, it will be possible to add them to the set of `Erasure_Agreement`.

---

## The Architecture

Every agreement, user, entry, whatever may have its own account, and those accounts (or the factories that deploy them) can report back to simple, shared registries that establish a single source of truth for a given protocol. This grants individual agents in the system the authority to opt-in to new changes, gives rise to a diversity of options for how to interact with the system, and makes the system more decentralized.

So far, the registries developed are:

- Erasure_Agreements
- Erasure_Posts
- Erasure_Users
- Erasure_Escrows

Using the Spawner library, every item on Erasure is created as a clone of a previously deployed template. We call these **Clone Factories**. Every clone is also registered in a registry which provides a single source of truth on the status of the protocol.

![Clone Factory](docs/clone-factory.png "Clone Factory")

---

## Deployed contracts

See [latest release](https://github.com/erasureprotocol/erasure-next-contracts/releases).

## Packages
- [Erasure Crypto + IPFS Helpers](https://github.com/erasureprotocol/erasure-protocol/tree/master/packages/crypto-ipfs)

repository: fulldecent/erasure-protocol

repo_name: fulldecent/erasure-protocol


text:
# match-env-and-run

A simple bash script that can be used in conjunction with typical symfony setups
to execute commands if the environment matches what is reported in the .env file.

Very handy if you want to chain various steps together or if you need to protected
a specific environment from harm.

## Example use

```sh
./match-env-and-run.sh dev "bin/console do:da:dr --force"
```

repository: NeilMasters/match-env-and-run

repo_name: NeilMasters/match-env-and-run


text:
[<<< Previous question <<<](0749.md)   Question ID#0750.md   [>>> Next question >>>](0751.md)
---

What happens if you use fwrite to write data to a readonly file?

- [ ] A) 0 is returned
- [ ] B) an exception is thrown
- [ ] C) a PHP fatal error occurs
- [ ] D) a PHP warning occurs

Answer

  Answer: A

repository: alceanicu/zce

repo_name: alceanicu/zce


text:
-------------------------------------------------------------------------------------------------

Test with binderHub:

https://mybinder.org/v2/gh/op07n/mygenericbinder2/master?urlpath=git-pull?repo=https://github.com/op07n/streamlit-launchpad

Open terminal and type:

```
cd launchpad

python streamlit-launchpad.py --port 8000 ./examples

```

For main access index page add /proxy/8080/  to url binderhub

Every option on main access index page show the port to use :

......................./proxy/8080/intro.py/

......................./proxy/8080/plot_example.py/

......................./proxy/8080/uber_nyc_data_explorer.py/

-------------------------------------------------------------------------------------------------

# Streamlit Launchpad

Web launchpad to browse a folder containing multiple Streamlit applications (py files), with a central launchpad listing available apps so you can run them (if not already running) and view each in its own tab.

This is a very basic alpha version.

## Install and Run

Install using pip.

```
pip install streamlit-launchpad
```

Serves *.py as separate Streamlit applications from the folder supplied on the command line:

```
streamlit-launchpad ./examples
```

Then go to http://localhost:8888/ in your browser:

![Launchpad screenshot](screenshots/Launchpad.png)

To run on a different port use:

```
streamlit-launchpad --port 8000 ./examples
```

## Development install

```
git clone https://github.com/ideonate/streamlit-launchpad.git
cd streamlit-launchpad

pip install -e .

streamlit-launchpad ./examples
```

To run directly in python: `python -m launchpad.main ./examples/`