text:
<repo_name>gdegirmenci/laravel-champions-league<file_sep>/resources/js/components/fixture/Fixture.vue
<template>

                Name: {{ club.name }}
                Played Games: {{ club.played_games }}
                Wins: {{ club.wins }}
                Loses: {{ club.loses }}
                Draws: {{ club.draws }}
                Points: {{ club.points }}
                GA: {{ club.ga }}
                GF: {{ club.gf }}
                GD: {{ club.gd }}

</template>

<file_sep>/app/Http/Controllers/HomeController.php
<?php

namespace App\Http\Controllers;

use App\Services\FixtureService;
use App\Services\GameService;
use App\Services\PredictService;

class HomeController extends Controller
{
    /**
     * @var FixtureService
     */
    private $fixtureService;

    /**
     * @var GameService
     */
    private $gameService;

    /**
     * @var PredictService
     */
    private $predictService;

    public function __construct(
        FixtureService $fixtureService,
        GameService $gameService,
        PredictService $predictService
    ) {
        $this->fixtureService = $fixtureService;
        $this->gameService = $gameService;
        $this->predictService = $predictService;
    }

    public function playWeek(int $id)
    {
        $this->gameService->startWeek($id);

        $fixtures = $this->fixtureService->displayFixture();

        return $fixtures;
    }

    public function createFixture()
    {
        return $this->fixtureService->createFixtures();
    }

    public function resetFixture()
    {
        return $this->fixtureService->resetFixtures();
    }

    public function predictWinner()
    {
        return $this->predictService->predictWinner();
    }
}
<file_sep>/app/Club.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Club extends Model
{
    public $timestamps = false;

    const HOME_POWER = 50;

    protected $fillable = [
        'name',
        'attack_power',
        'defense_power',
    ];

    public function homeGames()
    {
        return $this->hasMany('App\Game', 'home_club_id');
    }

    public function awayGames()
    {
        return $this->hasMany('App\Game', 'away_club_id');
    }

    public function attackPower(bool $isHome)
    {
        if($isHome)
            return $this->attack_power + self::HOME_POWER;

        return $this->attack_power;
    }

    public function defensePower(bool $isHome)
    {

        if($isHome)
            return $this->defense_power + self::HOME_POWER;

        return $this->defense_power;
    }

    public function countPlayed() {
        return $this->homeGames->where('is_played', true)->count()+$this->awayGames->where('is_played', true)->count();
    }

    public function countWins() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->home_club_goals>$game->away_club_goals)
                    $result++;
        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->away_club_goals>$game->home_club_goals)
                    $result++;
        }
        return $result;
    }

    public function countDraws() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->home_club_goals==$game->away_club_goals)
                    $result++;
        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->away_club_goals==$game->home_club_goals)
                    $result++;
        }

        return $result;
    }

    public function countLoses() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->home_club_goals<$game->away_club_goals)
                    $result++;
        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played)
                if($game->away_club_goals<$game->home_club_goals)
                    $result++;
        }

        return $result;
    }

    public function countGF() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played)
                $result+=$game->home_club_goals;
        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played)
                $result+=$game->away_club_goals;
        }

        return $result;
    }

    public function countGA() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played)
                $result+=$game->away_club_goals;
        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played)
                $result+=$game->home_club_goals;
        }

        return $result;
    }

    public function countGD() {
        return $this->countGF()-$this->countGA();
    }

    public function countPoints() {
        $result = 0;
        $games = $this->homeGames;
        foreach ($games as $game) {
            if($game->is_played) {
                if($game->home_club_goals>$game->away_club_goals)
                    $result+=3;
                else if($game->home_club_goals==$game->away_club_goals)
                    $result++;
            }

        }
        $games = $this->awayGames;
        foreach ($games as $game) {
            if($game->is_played) {
                if ($game->away_club_goals > $game->home_club_goals)
                    $result += 3;
                else if ($game->away_club_goals == $game->home_club_goals)
                    $result++;
            }
        }
        return $result;
    }
}
<file_sep>/readme.md
# About

This repository is created for the case study.

## Install
#### 1. Clone the repository

```bash
git clone https://github.com/gdegirmenci/laravel-champions-league.git
cd champ
```

#### 2. Set .env
```bash
cp .env.example .env
```

#### 3. Install requirements
```bash
composer install
npm install
```

#### 4. Build and run Docker
```bash
cd dock
docker-compose build
docker-compose up -d
```

#### 5. Set DB Host
After creating .env file, please run the command below and get your local IP for DB host

For MacOS and Linux
```
ifconfig
```

For Windows
```
ipconfig
```

Inside .env file, find the line 10
```dotenv
DB_HOST=192.168.x.x
```

#### 6. Database Migrations
```bash
php artisan migrate
```

## Usage
- Before usage, please run the command for serve front-end
```
npm run watch
```

- Create some entries inside clubs table like
```
#name           #attack_power   #defense_power
Galatasaray     70              80
Fenerbahçe      80              70
Beşiktaş        80              70
Trabzonspor     70              60
```

- Create the initial fixture
```
localhost:8180/api/create
```

- Go to application and start the league
```
localhost:8180
```
<file_sep>/app/Services/PredictService.php
<?php

namespace App\Services;

use App\Club;
use App\Game;

class PredictService
{
    public function predictWinner(): array
    {
        $clubs = Club::all();
        $totalClubs = $clubs->count();
        $result = [];

        for ($i = 0; $i < $totalClubs; $i++) {
            $homeGames = Game::where('home_club_id', $clubs[$i]['id'])
                ->where('is_played', 0)
                ->get()
            ;

            $awayGames = Game::where('away_club_id', $clubs[$i]['id'])
                ->where('is_played', 0)
                ->get()
            ;

            $totalGames = $homeGames->count() + $awayGames->count();
            $range = $clubs[$i]->countWins() * 100 / ($clubs[$i]->countPlayed());
            $possibilityRank = $range * $totalGames;

            array_push($result, [
                'team' => $clubs[$i]['name'],
                'rank' => $possibilityRank,
            ]);
        }

        return $result;
    }
}
<file_sep>/app/Game.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Game extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'home_club_id',
        'away_club_id',
        'week_id',
        'home_club_goals',
        'away_club_goals',
        'week',
        'is_played',
    ];

    public function homeClub()
    {
        return $this->home_club_id;
    }

    public function awayClub()
    {
        return $this->away_club_id;
    }
}
<file_sep>/resources/js/components/Home.vue
<template>

        <Fixture :fixture="getFixture"/>
        <button v-if="getWeek === 1" @click="playWeek(getWeek)">Start League</button>
        <button v-if="getWeek !==1 && getWeek < getTotalWeeks" @click="playWeek(getWeek)">Next Week</button>
        <button v-if="getWeek === getTotalWeeks" @click="restart">Restart</button>

</template>

<file_sep>/app/Services/GameService.php
<?php

namespace App\Services;

use App\Club;
use App\Game;

class GameService
{
    /**
     * @var Club
     */
    private $homeClub;

    /**
     * @var Club
     */
    private $awayClub;

    public function playGames(int $homeClub, int $awayClub)
    {
        $clubs = Club::all();

        $this->homeClub = $clubs->find($homeClub);
        $this->awayClub = $clubs->find($awayClub);

        $positions = $this->createPosition(
            $this->homeClub->attackPower(true),
            $this->awayClub->attackPower(false)
        );

        $homePositions = 0;
        $awayPositions = 0;
        $homeGoals = 0;
        $awayGoals = 0;

        for ($i = 0; $i < $positions; $i++) {
            $luck = rand(0, $positions * 10);

            if ($luck < $this->homeClub->attackPower(true)) {
                if ($this->createGoal())
                    $homeGoals++;
                $homePositions++;
            } else {
                if ($this->createGoal())
                    $awayGoals++;
                $awayPositions++;
            }
        }

        Game::where('home_club_id', $homeClub)
            ->where('away_club_id', $awayClub)
            ->where('is_played', 0)
            ->update([
                'home_club_goals' => $homeGoals,
                'away_club_goals' => $awayGoals,
                'is_played' => 1,
            ])
        ;

        $positionDef = "Home Positions: " . $homePositions . " - " . "Away Positions: " . $awayPositions;

        $goalDef = "Home Goals: " . $homeGoals . " - " . "Away Goals: " . $awayGoals;

        return $positionDef . $goalDef;
    }

    public function startWeek(int $weekNumber)
    {
        $games = Game::where('week', $weekNumber)->get()->toArray();

        for ($i = 0; $i < count($games); $i++) {
            $this->playGames($games[$i]['home_club_id'], $games[$i]['away_club_id']);
        }
    }

    public function createPosition(int $homeAttackPower, int $awayAttackPower)
    {
        $position = round(($homeAttackPower + $awayAttackPower) / 10);

        return $position;
    }

    public function createGoal()
    {
        $goal = false;

        $luck = rand(
            0,
            $this->homeClub->defensePower(true) + $this->awayClub->defensePower(true)
        );

        if ($luck < $this->homeClub->defensePower(true) && rand(0,1) == 1)
            $goal = true;

        return $goal;
    }
}
<file_sep>/app/Services/FixtureService.php
<?php

namespace App\Services;

use App\Game;
use App\Club;

class FixtureService
{
    public function createFixtures()
    {
        $clubs = Club::get(['id'])->toArray();
        $totalClubs = count($clubs);
        $fixedClub = array_shift($clubs);
        $matches = [];

        for($i = 1; $i < $totalClubs; $i++) {
            $this->createGames($fixedClub['id'], $clubs[0]['id'], $i);

            for($j = 1; $j < $totalClubs/2; $j++) {
                $this->createGames($clubs[$j]['id'], $clubs[$totalClubs-$j-1]['id'], $i);
            }

            $tmp = array_shift($clubs);
            array_push($clubs, $tmp);
        }

        for ($i = 1; $i < $totalClubs; $i++) {
            $this->createGames($clubs[0]['id'], $fixedClub['id'], $i+$totalClubs-1);

            for ($j = 1; $j < $totalClubs/2; $j++) {
                $this->createGames($clubs[$totalClubs-$j-1]['id'], $clubs[$j]['id'], $i+$totalClubs-1);
            }

            $tmp = array_shift($clubs);
            array_push($clubs, $tmp);
        }

        return $matches;
    }

    public function createGames(int $homeClub, int $awayClub, int $week): void
    {
        $game = new Game([
            'home_club_id' => $homeClub,
            'away_club_id' => $awayClub,
            'week' => $week,
            'home_club_goals' => 0,
            'away_club_goals' => 0,
            'is_played' => 0,
        ]);

        $game->save();
    }

    public function resetFixtures()
    {
        Game::where('is_played', 1)
            ->update([
                'home_club_goals' => 0,
                'away_club_goals' => 0,
                'is_played' => 0,
            ]);

        return "Done it";
    }

    public function displayFixture()
    {
        $clubs = Club::all();
        $result = [];

        for ($i = 0; $i < $clubs->count(); $i++) {
            $clubDetail = [
                'name' => $clubs[$i]['name'],
                'played_games' => $clubs[$i]->countPlayed(),
                'wins' => $clubs[$i]->countWins(),
                'loses' => $clubs[$i]->countLoses(),
                'draws' => $clubs[$i]->countDraws(),
                'ga' => $clubs[$i]->countGA(),
                'gf' => $clubs[$i]->countGF(),
                'gd' => $clubs[$i]->countGD(),
                'points' => $clubs[$i]->countPoints(),
            ];

            array_push($result, $clubDetail);
        }

        usort($result, function($a, $b){
            if($a['points']==$b['points'])
                return $a['gd']<$b['gd'];
            return $a['points']<$b['points'];
        });

        return json_encode($result);
    }
}

languages: Markdown Vue PHP

repo_name: gdegirmenci/laravel-champions-league


text:
<repo_name>biosilico/hello-world<file_sep>/README.md
# hello-world
This will be my first GitHub repository

Four-score and seven years ago, <NAME> had a little muffin.
And, when the muffin cried "Wolf!" ALL the pigs knew.

branch_name: refs/heads/master

repo_language: Markdown

repo_name: biosilico/hello-world


text:
<repo_name>Knjaz1989/Sql_lesson_4<file_sep>/Удаление таблиц.sql
DROP TABLE genresinger;
DROP TABLE singeralbum;
DROP TABLE collectiontrack;
DROP TABLE collections;
DROP TABLE tracks;
DROP TABLE albums;
DROP TABLE singers;
DROP TABLE genres;
<file_sep>/Очищение таблиц.sql
DELETE FROM genresinger;
DELETE FROM singeralbum;
DELETE FROM collectiontrack;
DELETE FROM tracks;
DELETE FROM albums;
DELETE FROM singers;
DELETE FROM genres;

repo_language: SQL


text:
<file_sep># DesignProject
 DesignProject
<file_sep><!DOCTYPE html>

    <title>FAQ</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="css/style.css" />

LOGO

Home

About

Contact

FAQ

Profile

            GeeksforGeeks

A computer science portal for geeks

It is a computer science portal where you can learn programming.

            GeeksforGeeks

A computer science portal for geeks

It is a computer science portal where you can learn programming.

            GeeksforGeeks

A computer science portal for geeks

It is a computer science portal where you can learn programming.

            GeeksforGeeks

A computer science portal for geeks

It is a computer science portal where you can learn programming.

            GeeksforGeeks

A computer science portal for geeks

It is a computer science portal where you can learn programming.

            this rights reserved by **** :2020

languages: Markdown HTML

repo_name: mernaHisham/DesignProject


text:
<file_sep># Bingo Card Generator
This is a script that generates Bingo Cards and exports the numbers to a csv file

## Use
To use run `npm i` the `npm start`

## Configure
```javascript
generateBingoData(
  cards = 1,        // Number of cards to generate
  numbers = 90,     // Number of Numbers i.e. 1-90
  limit = 90,       // Number limit, total numbers on card
  games = 6,        // Number of games per card
  gameRows = 3,     // Number of rows in the game
  gameColumns = 9,  // Number of columns in the game
  filename = 'bingo'// CSV filename
)
```

branch_name: refs/heads/main


text:
<repo_name>xenuver/QUIZ09092019<file_sep>/BagunRuang.cs
using System;

namespace QUIZ09092019
{
    class BagunRuang
    {
        public void volume_balok()
        {
            Console.WriteLine("-----------------------");
            Console.WriteLine("Menghitung Volume Balok");

            int panjang,lebar,tinggi,volume;

            Console.Write("Masukkan Nilai Panjang = ");
            panjang = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Nilai Lebar = ");
            lebar = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Nilai Tinggi = ");
            tinggi = Convert.ToInt32(Console.ReadLine());

            volume = panjang * lebar * tinggi;
            Console.WriteLine("Nilai Volume Adalah = "+volume);
            Console.WriteLine("----------------------");
        }

        public void volume_kubus()
        {
            Console.WriteLine("Menghitung Volume Kubus");

            int rusuk,volume2;

            Console.Write("Masukkan Nilai Rusuk = ");
            rusuk = Convert.ToInt32(Console.ReadLine());

            volume2 = rusuk * rusuk * rusuk;
            Console.WriteLine("Nilai Rusuk adalah = "+volume2);
            Console.WriteLine("---------------------");
        }
    }
}<file_sep>/Program.cs
using System;

namespace QUIZ09092019
{
    class Program
    {
        static void Main(string[] args)
        {
            BagunDatar kelas = new BagunDatar();

            kelas.Luas_Persegi();

            kelas.Luas_Segitiga();

            kelas.Luas_Lingkaran();

            BagunRuang lele = new BagunRuang();

            lele.volume_balok();

            lele.volume_kubus();

        }
    }
}

repo_language: C#


text:
<file_sep>module.exports = {
	dist: {
		options: {
			mode: 0700,
			create: ['dist']
		}
	}
};<file_sep>module.exports = {
	src: {
		files: {
			'dist/io.mapping.jslib.min.js' : ['src/**/*.js']
		}
	}
};<file_sep># io.mapping.jslib: A helpful JavaScript library for AngularJS applications [![Build Status](https://travis-ci.org/jprystowsky/io.mapping.jslib.png?branch=master)](https://travis-ci.org/jprystowsky/io.mapping.jslib)

Nota bene: This is heavily under development!

## Installation

```
// TODO :)
```

## Usage

```
// TODO!
```

* Something about bower
* Something about including the script

The library exposes a global variable named `iojs`, which is the entry point for all library features.

## Lambda (higher-order) functions

Lambda methods are accessed by initializing a new Lambda object using `Lambda()`:

```
var lambda = iojs.Lambda(input);
```

where `input` can be an array or any other valid input (primitives, objects, etc.). Internally, `input` is copied
(deeply) into an internal state before manipulation, so it is safe to pass data without worrying about it being
destroyed.

Every lambda method tries to return something useful, whether it be an aggregate value (e.g., in `fold` or `sum`) or
the object itself (in the case of `map`, among others), where further lambda operations may be desired). It's worth
noting that lambda methods are generally non-idempotent, as methods manipulate the internal state.

For the purposes of example, assume:

```
var items = [
	{
		id: 2319,
		name: "Widget A",
		manufacturer: "Acme, Inc.",
		price: 50
	},
	{
		id: 2712,
		name: "Widget B",
		manufacturer: "Acme, Inc.",
		price: 75
	},
	{
		id: 4309,
		name: "<NAME>",
		manufacturer: "Beta Co.",
		price: 20
	},
	{
		id: 4310,
		name: "<NAME>",
		manufacturer: "Beta Co..",
		price: 40
	},
	{
		id: 53,
		name: "Part 1",
		manufacturer: "PartSoft",
		price: 0.99
	}
];

var lmda = iojs.Lambda(items);
```

### Lambda(input)

Initialize a new `Lambda` whose state is copied from `input`. `input` is the preimage of `f`, where `f` is the
composition of the method calls to this `Lambda`. If `input` is a singleton (primitive value), then the input will
be cloned and wrapped by an array; otherwise, the input will be cloned.

Think of `Lambda` as C#'s `IEnumerable`.

### toArray()

Return \[the state of\] `lmda` under `f`, the composition of the calls to `lmda`.

```
// dupItems will be equal to items (but a deep copy of it)
var dupItems = lmda.toArray();
```

### map(callback\[, args\])

Perform a projection, `callback`, on `lmda`, optionally passing in an additional argument `args` to `callback` (which
will be `call`ed).

`callback` should resemble `function (object[, arg1, arg2, ..., argn])` where each `argi` is in `args`.
`object` will be the current fiber of `lmda` prior to the projection, i.e., an element of `lmda`. `callback` should
return the projection of `object`.

```
// justPrices will look like: [ 50, 75, 20, 40, 0.99 ]
var justPrices = lmda.map(function (product) {
	return product.price;
});
```

### foldl

### foldr

### fold

### filter(filterFunction\[, args\])

Filter `lmda` by removing elements that fail to return `true` when `filterFunction(element[, args])` is called for each
`element` in `lmda` (optionally passing along `args` additionally).

```
// justAcme will look like:
// [{
    	id: 2319,
    	name: "Widget A",
    	manufacturer: "Acme, Inc.",
    	price: 50
    },
    {
    	id: 2712,
    	name: "Widget B",
    	manufacturer: "Acme, Inc.",
    	price: 75
    }]
var justAcme  = lmda.filter(function (product) {
	return product.manufacturer == "Acme, Inc.";
});
```

### reverse()

Reverse the elements of `lmda`.

```
// reversed will look like:
// [
//	{
//		id: 53,
//		name: "Part 1",
//		manufacturer: "PartSoft",
//		price: 0.99
//	},
//	{
//		id: 4310,
//		name: "<NAME>",
//		manufacturer: "Beta Co..",
//		price: 40
//	},
//	{
//		id: 4309,
//		name: "<NAME>",
//		manufacturer: "Beta Co.",
//		price: 20
//	},
//	{
//		id: 2712,
//		name: "Widget B",
//		manufacturer: "Acme, Inc.",
//		price: 75
//	},
// 	{
// 		id: 2319,
// 		name: "Widget A",
//		manufacturer: "Acme, Inc.",
//		price: 50
//	}
//];
var reversed = lmda.reverse().toArray();
```

### sort(\[sortfunction\])

Sort the elements of `lmda` using the default sort (for default-sortable values), or optionally by using a custom
`function (a, b)` returning `1`, `0`, or `-1` (`a` greater than, equal to, or less than `b`, respectively).

```
// sorted will look like:
// [
//	{
//		id: 53,
//		name: "Part 1",
//		manufacturer: "PartSoft",
//		price: 0.99
//	},
// 	{
// 		id: 2319,
// 		name: "Widget A",
//		manufacturer: "Acme, Inc.",
//		price: 50
//	},
//	{
//		id: 2712,
//		name: "<NAME>",
//		manufacturer: "Acme, Inc.",
//		price: 75
//	},
//	{
//		id: 4309,
//		name: "<NAME>",
//		manufacturer: "Beta Co.",
//		price: 20
//	},
//	{
//		id: 4310,
//		name: "<NAME>",
//		manufacturer: "Beta Co..",
//		price: 40
//	}
//];
var sorted = lmda.sort(function (productA, productB) {
	return productA.id > productB.id ? 1 : productA.id == productB.id ? 0 : -1;
}).toArray();
```

### sum(\[projectionFunction\])

A convenience method written internally using `fold`, `sum()` will perform an arithmetic sum over `lmda`.
When provided `projectionFunction`, of signature `function (input)` returning a `+`-able value, that function will
be called to project values to be summed.

```
// sum will be 185.99
var sum = lmda.sum(function (val) {
	return val.price;
});
```

### average(\[projectionFunction\])

Average the values of `lmda`. Called as `average()`, perform an arithmetic average (written using `sum`). When called
with `projectionFunction`, `function (input)` returning a `+`-able value, that function will be called to project
values to be summed prior to being averaged.

## Contributing

I welcome contributions! Please ensure that any changes you submit are adequately covered by unit tests. See the
existing codebase for examples of how this should be done.<file_sep>module.exports = {
	karma: {
		files: [
			'src/**/*.js',
			'test/spec/**/*Spec.js'
		],
		tasks: [
			'karma:unit:run'
		]
	}
};<file_sep>var iojs = new function () {
	function MappingIoJsLib () {};

	MappingIoJsLib.prototype.Lambda = function (input) {
		function Lambda() {}

		// The internal state used by the lambda methods
		Lambda.prototype._state = null;

		// Used by average() and sum()
		Lambda.prototype._identityProjectionFunction = function (object) { return object; };

		/**
		 * Initialize the lambda object.
		 * @param input
		 * @returns {Lambda}
		 */
		Lambda.prototype.init = function (input) {
			if (angular.isArray(input)) {
				this._state = angular.copy(input);
			} else {
				this._state = [angular.copy(input)];
			}

			return this;
		};

		/**
		 * Return the state as an array.
		 * @returns {null|*}
		 */
		Lambda.prototype.toArray = function () {
			return this._state;
		};

		/**
		 * Map.
		 * @param callback
		 * @param args
		 * @returns {Lambda}
		 */
		Lambda.prototype.map = function (callback, args) {
			for (var i = 0; i < this._state.length; i++) {
				var obj = this._state[i];

				this._state[i] = callback.call(undefined, obj, args);
			}

			return this;
		};

		/**
		 * Internal fold method.
		 * @param accumulator
		 * @param direction
		 * @param callback
		 * @param args
		 * @returns {*}
		 * @private
		 */
		Lambda.prototype._fold = function (accumulator, direction, callback, args) {
			var currentValue = accumulator;

			if (direction < 0) {
				for (var i = 0; i < this._state.length; i++) {
					var obj = this._state[i];

					currentValue = callback.call(undefined, obj, currentValue, args);
				}
			} else {
				for (var i = this._state.length - 1; i >= 0; i--) {
					var obj = this._state[i];

					currentValue = callback.call(undefined, obj, currentValue, args);
				}
			}

			return currentValue;
		};

		/**
		 * Fold from the left.
		 * @param accumulator
		 * @param callback
		 * @param args
		 * @returns {*}
		 */
		Lambda.prototype.foldl = function (accumulator, callback, args) {
			return this._fold(accumulator, -1, callback, args);
		};

		/**
		 * Fold from the right.
		 * @param accumulator
		 * @param callback
		 * @param args
		 * @returns {*}
		 */
		Lambda.prototype.foldr = function (accumulator, callback, args) {
			return this._fold(accumulator, 1, callback, args);
		};

		/**
		 * Fold [from the left].
		 * @param accumulator
		 * @param callback
		 * @param args
		 * @returns {*}
		 */
		Lambda.prototype.fold = function (accumulator, callback, args) {
			return this.foldl(accumulator, callback, args);
		};

		Lambda.prototype.filter = function (filterFunction, args) {
			for (var i = 0; i < this._state.length; i++) {
				var obj = this._state[i];

				if (!filterFunction.call(undefined, obj, args)) {
					this._state.splice(i, 1);
					i--;
				}
			}

			return this;
		};

		Lambda.prototype.reverse = function () {
			this._state = this._state.reverse();

			return this;
		};

		Lambda.prototype.sort = function (sortFunction) {
			this._state = this._state.sort(sortFunction);

			return this;
		};

		Lambda.prototype.sum = function (projectionFunction) {
			if (!angular.isFunction(projectionFunction)) {
				projectionFunction = this._identityProjectionFunction;
			}

			return this.fold(0, function (obj, current) {
				return projectionFunction.call(undefined, obj) + current;
			});
		};

		/**
		 * Average -- convenience fold[l] operation.
		 * @param projectionFunction
		 * @returns {number}
		 */
		Lambda.prototype.average = function (projectionFunction) {
			if (!angular.isFunction(projectionFunction)) {
				projectionFunction = this._identityProjectionFunction;
			}

			var length = this._state.length;

			return this.sum(projectionFunction) / length;
		};

		/**
		 * Kick it back. Then kick back.
		 */
		return new Lambda().init(input);
	};

	return new MappingIoJsLib();
};

languages: Markdown JavaScript


text:
<repo_name>montesillo/Curso-de-jQuery-a-JavaScript<file_sep>/README.md
#Curso-de-jQuery-a-JavaScript

repo_name: montesillo/Curso-de-jQuery-a-JavaScript


text:
<file_sep># ChP_Algorithm1
Checkpoint Algorithms and its elements


text:
<file_sep>package cz.net21.ttulka.recexp;

/**
 * No rules defined exception.
 *
 * @author ttulka
 * @see Recexp
 */
public class RecexpEmptyRulesException extends RecexpException {

    protected RecexpEmptyRulesException() {
        super();
    }
}
<file_sep>package cz.net21.ttulka.recexp;

/**
 * Object representation of a recursive expression.
 *
 * @author ttulka
 * @see ExpressionTree
 */
class Expression {

    public static final char REFERENCE_PREFIX = '@';
    public static final String THIS_REFERENCE_NAME = "this";
    public static final String EPSILON_REFERENCE_NAME = "eps";

    public static final Expression EPSILON = new Expression("", null, false);

    private final String text;
    private final String quantifier;
    private final boolean reference;

    public Expression(String text, String quantifier, boolean reference) {
        this.text = text;
        this.quantifier = quantifier;
        this.reference = reference;
    }

    public String getText() {
        return text;
    }

    public String getQuantifier() {
        return quantifier;
    }

    public boolean isQuantified() {
        return quantifier != null && !quantifier.isEmpty();
    }

    public boolean isReference() {
        return reference;
    }

    public boolean isEpsilon() {
        return EPSILON.getText().equals(this.getText());
    }

    public String toWord() {
        if (isEpsilon()) {
            return "";
        }
        StringBuilder sb = new StringBuilder();

        if (!isReference() && isQuantified()) {
            sb.append("(");
        }

        if (isReference()) {
            sb.append(REFERENCE_PREFIX);
        }

        sb.append(getText());

        if (!isReference() && isQuantified()) {
            sb.append(")");
        }

        if (isQuantified()) {
            sb.append(getQuantifier());
        }
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Expression that = (Expression) o;

        if (reference != that.reference) {
            return false;
        }
        if (!text.equals(that.text)) {
            return false;
        }
        return quantifier != null ? quantifier.equals(that.quantifier) : that.quantifier == null;
    }

    @Override
    public int hashCode() {
        int result = text.hashCode();
        result = 31 * result + (quantifier != null ? quantifier.hashCode() : 0);
        result = 31 * result + (reference ? 1 : 0);
        return result;
    }

    @Override
    public String toString() {
        return toWord();
    }
}
<file_sep># Recursive Expressions

Java library for working with recursive expressions and context-free languages and grammars.

## Prerequisites

- Java 6

## Characteristics

- Not Thread-safe

## Usage

Copy the Maven dependency into your Maven project:

```
<dependency>
    <groupId>cz.net21.ttulka.recexp</groupId>
    <artifactId>recursive-expressions</artifactId>
    <version>1.0.0</version>
</dependency>
```

### Recursive Expressions as an Extension of Regular Expressions

Regular expression standard Java library does not use hierarchical grouping of a parsing result:
```
Matcher matcher = Pattern.compile("(a)((b))").matcher("ab");    // this is standard Java
matcher.groupCount();   // 3
matcher.group(1);       // a
matcher.group(2);       // b
matcher.group(3);       // b
```

With Recursive Expressions are groups created hierarchically:
```
RecexpMatcher matcher = Recexp.compile("(a)((b))").matcher("ab");

matcher.groupCount();       // 2

matcher.group(1).name();    // a
matcher.group(1).value();   // a

matcher.group(2).name();    // (b)
matcher.group(2).value();   // b

matcher.group(2).groupCount();      // 1
matcher.group(2).group(1).name();   // b
matcher.group(2).group(1).value();  // b
```

Hierarchical expression tree from the example above:
```
    (a)((b))
    /     \
   a      (b)
            \
             b
```

#### Match flags

Recursive Expressions are using the standard match flags from the `Pattern` class:
```
Recexp.compile("a", Pattern.CASE_INSENSITIVE)    // case-insetive
    .matches("A");  // true
```
The flags are applied to all the rules.

### Recursive Expressions as a Context-Free Grammar

A context-free grammar can be defined as a set of rules with a starting rule `S`. The rules are of the form `A → w`, where `A` is a name of the rule and `w` is a string which can contain characters and rule references.

```
Recexp grammar = Recexp.builder()
    .rule("S", "@A@B")
    .rule("A", "a")
    .rule("B", "b")
    .build();

RecexpMatcher matcher = grammar.matcher("S", "ab");
matcher.matches();  // true - the grammar accepts the input "ab"
```

The *matcher* contains a result of a derivation from the starting rule. If the starting rule is omitted, each rule is a starting rule.

When the rule name is omitted, the whole expression is used as a rule name and the rule cannot be referenced.

**Tip:** *Use the convenience shortcut `Recexp.compile(rule1, ..., ruleN)` for defining a grammar with multiple anonymous rules.*

#### Recursive rule references

Rule expression can reference another rule and/or itself.

References have syntax `@RefName` where `RefName` can contain only word characters (letters, digits and underscore `_`).

```
Recexp recexp = Recexp.builder()
    .rule("MyRef", "@A@MyRef?@B")
    .rule("A", "a")
    .rule("B", "b")
    .build();

RecexpMatcher matcher = recexp.matcher("aabb");

matcher.matches();              // true
matcher.groupCount();           // 3

matcher.group(1).name();        // @A
matcher.group(1).value();       // a

matcher.group(2).name();        // @MyRef?
matcher.group(2).value();       // ab

matcher.group(3).name();        // @B
matcher.group(3).value();       // b
```

#### Self-reference `@this`
```
Recexp recexp = Recexp.compile("a@this|b");

recexp.matches("b");     // true
recexp.matches("ab");    // true
recexp.matches("aab");   // true
recexp.matches("aaab");  // true

recexp.matcher("a").matches();     // false
```

#### Empty reference `@eps` (Epsilon)

*Epsilon* has syntax `@eps` and can be use as a rule defining an empty string:
```
Recexp recexp = Recexp.compile("a|@eps");

recexp.matches("");      // true
recexp.matches("a");     // true
```

Epsilon is a shortcut for an empty rule:
```
Recexp recexp = Recexp.builder()
    .rule("epsilon", "")
    ...
```

## Examples

### Palindromes
```
S → 0S0 | 1S1 | 0 | 1 | ε
```
```
Recexp recexp = Recexp.builder()
    .rule("S", "0")
    .rule("S", "1")
    .rule("S", "0(@S)0")
    .rule("S", "1(@S)1")
    .rule("S", "@eps")
    .build();

recexp.matches("");        // true
recexp.matches("0");       // true
recexp.matches("1");       // true
recexp.matches("11");      // true
recexp.matches("00");      // true
recexp.matches("010");     // true
recexp.matches("101");     // true
recexp.matches("000");     // true
recexp.matches("111");     // true
recexp.matches("0110");    // true
recexp.matches("1001");    // true
recexp.matches("10101");   // true
recexp.matches("10");      // false
recexp.matches("01");      // false
recexp.matches("1101");    // false
```
The same definition can be compactly created like:
```
Recexp recexp = Recexp.builder()
    .rule("S", "0(@S)0|1(@S)1|0|1|@eps")
    .build();
```
Or alternatively by using the `@this` self-reference:
```
Recexp recexp = Recexp.compile(
    "0(@this)0|1(@this)1|0|1|@eps");
```

### Strings with the same number of 0s and 1s
```
S → 0S1S | 1S0S | ε
```
```
Recexp recexp = Recexp.builder()
    .rule("S", "0(@S)1(@S)")
    .rule("S", "1(@S)0(@S)")
    .rule("S", "@eps")
    .build();

recexp.matches("");         // true
recexp.matches("0101");     // true
recexp.matches("1010");     // true
recexp.matches("1100");     // true
recexp.matches("110010");   // true
recexp.matches("110100");   // true
recexp.matches("11000101"); // true
recexp.matches("0");        // false
recexp.matches("1");        // false
recexp.matches("00");       // false
recexp.matches("11");       // false
recexp.matches("101");      // false
recexp.matches("010");      // false
```
The same definition can be compactly created like:
```
Recexp recexp = Recexp.builder()
    .rule("S", "0(@S)1(@S)|1(@S)0(@S)|@eps")
    .build();
```
Or alternatively by using the `@this` self-reference:
```
Recexp recexp = Recexp.compile(
    "0(@this)1(@this)|1(@this)0(@this)|@eps");
```

### Arithmetic expressions over variables X and Y
```
E → E±T | T           (expressions)
T → T×F | F           (terms)
F → (E) | X | Y       (factors)
```
```
Recexp recexp = Recexp.builder()
    .rule("E", "@E±@T|@T")
    .rule("T", "@T×@F|@F")
    .rule("F", "\\(@E\\)|X|Y")
    .build();

recexp.matches("X±Y");            // true
recexp.matches("X×Y");            // true
recexp.matches("(X±X)×Y");        // true
recexp.matches("(X±X)×(Y×X)");    // true

recexp.matches("(X×X)(Y×X)");     // false
```

### More examples

For more examples see [unit tests](http://github.com/ttulka/recursive-expressions/blob/master/src/test/java/cz/net21/ttulka/recexp/test/RecexpTest.java).

## Release Changes

### 1.0.0
Initial version.

## License

[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
<file_sep>package cz.net21.ttulka.recexp;

import java.util.regex.Pattern;

/**
 * Recursive rule.
 *

 * A rule is defined as a entry of name and {@link ExpressionTree expression}.
 *

 * A rule can contain a reference to itself declared as @this and/or a reference to another rule via name. A reference to another rule starts with
 * @ and continues with the name of the rule (case-sensitive).
 *
 * @author ttulka
 * @see Recexp
 * @see ExpressionTree
 */
class Rule {

    private final String name;
    private final ExpressionTree expression;

    public Rule(String expression) {
        this(expression, ExpressionTree.parseTree(expression));
    }

    public Rule(String name, String expression) {
        this(name, ExpressionTree.parseTree(expression));
    }

    protected Rule(String name, ExpressionTree expressionTree) {
        this.name = name;
        this.expression = expressionTree;
    }

    public String getName() {
        return name;
    }

    public ExpressionTree getExpression() {
        return expression;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Rule that = (Rule) o;

        if (!name.equals(that.name)) {
            return false;
        }
        return expression.getSentence().equals(that.expression.getSentence());
    }

    @Override
    public int hashCode() {
        return 31 * name.hashCode();
    }

    @Override
    public String toString() {
        return getName();
    }
}

/**
 * Named rule.
 *

 * The name can contain only word characters (a-z, A-Z, 0-9, _).
 *
 * @author ttulka
 */
class NamedRule extends Rule {

    public NamedRule(String name, String expression) {
        super(name, expression);

        if (!Pattern.matches("((\\w)+)", name)) {
            throw new IllegalArgumentException("Rule name can contain only word characters (letters, digits and underscore), but was: " + name);
        }

        if (name.equals(Expression.THIS_REFERENCE_NAME)) {
            throw new IllegalArgumentException("'" + Expression.THIS_REFERENCE_NAME + "' is a reserved rule name for a self-reference.");
        }

        if (name.equals(Expression.EPSILON_REFERENCE_NAME)) {
            throw new IllegalArgumentException("'" + Expression.EPSILON_REFERENCE_NAME + "' is a reserved rule name for the epsilon (empty rule).");
        }
    }

    protected NamedRule(String name, Expression expression) {
        super(name, new ExpressionTree(new ExpressionTree.Node(expression)));
    }

    @Override
    public String toString() {
        return Expression.REFERENCE_PREFIX + super.getName();
    }
}

/**
 * Implicit defined rule.
 *
 * @author ttulka
 */
class ImplicitRule extends NamedRule {

    public static final ImplicitRule EPSILON_RULE = new ImplicitRule(Expression.EPSILON_REFERENCE_NAME, Expression.EPSILON);

    @SuppressWarnings("SameParameterValue")
    private ImplicitRule(@SuppressWarnings("SameParameterValue") String name, Expression expression) {
        super(name, expression);
    }
}<file_sep>package cz.net21.ttulka.recexp;

/**
 * Syntax error in a recursive expression exception.
 *
 * @author ttulka
 * @see Recexp
 */
public class RecexpSyntaxException extends RecexpException {

    protected RecexpSyntaxException(String description) {
        super(description);
    }
}
<file_sep>package cz.net21.ttulka.recexp;

/**
 * Cyclic rule definition exception.
 *
 * @author ttulka
 * @see Recexp
 */
public class RecexpCyclicRuleException extends RecexpException {

    /**
     * @param name the rule name
     */
    protected RecexpCyclicRuleException(String name) {
        super(name);
    }
}
<file_sep>package cz.net21.ttulka.recexp;

/**
 * Referenced rule not found exception.
 *
 * @author ttulka
 * @see Recexp
 */
public class RecexpRuleNotFoundException extends RecexpException {

    /**
     * @param name the rule name
     */
    protected RecexpRuleNotFoundException(String name) {
        super(name);
    }
}

languages: Java Markdown

repo_language: Java

repo_name: ttulka/recursive-expressions


text:
<file_sep>classifier-fiddle
=================

Fiddler for Classifiers

repo_name: fridiculous/classifier-fiddle


text:
<repo_name>elisweetlife/SQL-challenge<file_sep>/config.py
#password
pw = "<PASSWORD> Github upload"
<file_sep>/README.md
# SQL-Challenge

Evaluated a Kaggle employee dataset and designed tables to hold data within a CSV and import into a SQL database. Learned how to create ERDs and schemas to auto populate data table column headers and prep for data dumps. Utilized PostgresSQL to evaluate tables and test SQL queries.
<file_sep>/schema.sql
SELECT * FROM employees
SELECT * FROM departments
SELECT * FROM dept_manager
SELECT * FROM dept_emp
SELECT * FROM titles
SELECT * FROM salaries

CREATE TABLE "employees" (
    "emp_no" 		INT   			NOT NULL,
    "birth_date" 	DATE   			NOT NULL,
    "first_name" 	VARCHAR(14)   	NOT NULL,
    "last_name" 	VARCHAR(16)   	NOT NULL,
    "gender" 		VARCHAR(1)   	NOT NULL,
    "hire_date" 	DATE   			NOT NULL,
	PRIMARY KEY (emp_no)
);

CREATE TABLE "departments" (
    "dept_no" 		VARCHAR(4)   	NOT NULL,
    "dept_name" 	VARCHAR(40)   	NOT NULL,
	PRIMARY KEY (dept_no),
	UNIQUE 		(dept_name)
);

CREATE TABLE "dept_manager" (
    "dept_no" 		VARCHAR(4)   	NOT NULL,
    "emp_no" 		INT   			NOT NULL,
    "from_date" 	DATE   			NOT NULL,
    "to_date" 		DATE   			NOT NULL,
	FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
	FOREIGN KEY (dept_no) REFERENCES departments (dept_no),
	PRIMARY KEY (emp_no, dept_no)
);

CREATE TABLE "dept_emp" (
    "emp_no" 		INT   		NOT NULL,
    "dept_no" 		VARCHAR(4)     NOT NULL,
    "from_date" 	DATE   		NOT NULL,
    "to_date" 		DATE   		NOT NULL,
	FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
	FOREIGN KEY (dept_no) REFERENCES departments (dept_no),
	PRIMARY KEY (emp_no, dept_no)
);

CREATE TABLE "titles" (
    "emp_no" 		INT   		NOT NULL,
    "title" 		VARCHAR(50)   	NOT NULL,
    "from_date" 	DATE   		NOT NULL,
    "to_date" 		DATE   		NOT NULL,
	FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
	PRIMARY KEY (emp_no, title, from_date)
);

CREATE TABLE "salaries" (
    "emp_no" 		INT   		NOT NULL,
    "salary" 		INT  	 	NOT NULL,
    "from_date" 	DATE   		NOT NULL,
    "to_date" 		DATE   		NOT NULL,
    FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
	PRIMARY KEY (emp_no, from_date)
);

<file_sep>/SQL-ChallengeHW.sql
SELECT * FROM employees
SELECT * FROM departments
SELECT * FROM dept_manager
SELECT * FROM dept_emp
SELECT * FROM titles
SELECT * FROM salaries

--1. List the following details of each employee:
--employee number, last name, first name, gender, and salary.
SELECT  e.emp_no AS "Employee Number",
		e.first_name AS "First Name",
		e.last_name AS "Last Name",
		e.gender AS "Gender",
		s.salary AS "Salary"
FROM employees AS e
LEFT JOIN salaries AS s ON
s.emp_no=e.emp_no
ORDER BY e.emp_no

--2. List employees who were hired in 1986.
SELECT * FROM employees
WHERE hire_date BETWEEN '1986-01-01' AND '1986-12-31'
--GROUP BY hire_date

--3. List the manager of each department with the following information:
--department number, department name, the manager's employee number, last name,
--first name, and start and end employment dates.

SELECT  e.emp_no AS "Employee Number",
		e.first_name AS "First Name",
		e.last_name AS "Last Name",
		e.hire_date AS "Employee Hire Date",
		d.dept_name AS "Department Name",
		dm.dept_no AS "Department Number",
		dm.emp_no AS "Managers Employee Number",
		dm.from_date AS "Hired Date",
		dm.to_date AS "Last Day Date"
FROM dept_manager AS dm
	INNER JOIN departments AS d
		ON(dm.dept_no=d.dept_no)
	INNER JOIN employees AS e
		ON(dm.emp_no=e.emp_no)

--4. List the department of each employee with the following information:
--employee number, last name, first name, and department name.

SELECT  e.emp_no AS "Employee Number",
		e.first_name AS "First Name",
		e.last_name AS "Last Name",
		d.dept_name AS "Department Name"
		--de.dept_no AS "Department Number"
FROM employees AS e
	INNER JOIN dept_emp AS de
		ON(e.emp_no=de.emp_no)
	INNER JOIN departments AS d
		ON(de.dept_no=d.dept_no)
ORDER BY e.emp_no;

--5. List all employees whose first name is "Hercules" and last names begin with "B."

SELECT * FROM employees
WHERE first_name = 'Hercules' AND last_name LIKE 'B%'

--6. List all employees in the Sales department, including their employee number,
--last name, first name, and department name.

SELECT  e.emp_no AS "Employee Number",
		e.first_name AS "First Name",
		e.last_name AS "Last Name",
		d.dept_name AS "Department Name"
		--de.dept_no AS "Department Number"
FROM employees AS e
	INNER JOIN dept_emp AS de
		ON(e.emp_no=de.emp_no)
	INNER JOIN departments AS d
		ON(de.dept_no=d.dept_no)
WHERE d.dept_name = 'Sales'
ORDER BY e.emp_no;

--7. List all employees in the Sales and Development departments,
--including their employee number, last name, first name, and department name.

SELECT  e.emp_no AS "Employee Number",
		e.first_name AS "First Name",
		e.last_name AS "Last Name",
		d.dept_name AS "Department Name"
		--de.dept_no AS "Department Number"
FROM employees AS e
	INNER JOIN dept_emp AS de
		ON(e.emp_no=de.emp_no)
	INNER JOIN departments AS d
		ON(de.dept_no=d.dept_no)
WHERE d.dept_name IN ('Sales', 'Development')
ORDER BY d.dept_name DESC

--8. In descending order, list the frequency count of employee last names,
--i.e., how many employees share each last name.

SELECT last_name, COUNT (last_name)
FROM employees
GROUP BY last_name
ORDER BY COUNT(last_name)

-- Extra Credit
SELECT * FROM employees
WHERE emp_no = 499942

languages: Markdown SQL Python

repo_name: elisweetlife/SQL-challenge


text:
<repo_name>cheapdental/theme<file_sep>/README.md
# theme
#teszt

repo_name: cheapdental/theme


text:
<file_sep>Original version of the WW2 Polish Antistasi gamemode created by Barbaloni, this is an edited version and all credit for original files and code go to the Antistasi team.
A3 - <NAME> (Antistasi WWII) Steam page - https://steamcommunity.com/sharedfiles/filedetails/?id=1500572611&searchtext=antistasi+

repo_language: Text

repo_name: ChrisWithAKube/POLHAAntistasiCWAK


text:
<repo_name>Alzubi/hello-world<file_sep>/README.md
# hello-world

Create a Repository: hello-world
Create new branch from master: readme-edits
make changes to README.md

Commit changes

repo_name: Alzubi/hello-world


text:
<repo_name>subalchaudhari/lwcSuperBadge<file_sep>/force-app/main/default/lwc/boatSearch/boatSearch.js
import { LightningElement,api,track } from 'lwc';
import { NavigationMixin  } from 'lightning/navigation';

export default class BoatSearch extends NavigationMixin(LightningElement) {
    @api isLoading = false;
    selectedboattype ='';

    createNewBoat(){
       this[NavigationMixin.Navigate]({
        type: 'standard__objectPage',
        attributes: {
            objectApiName: 'Boat__c',
            actionName: 'new'
        }
       });
    }

    handleLoading(){
        this.isLoading = true;
    }

    handleDoneLoading(){
        this.isLoading = false;
    }

    searchBoats(event){
        this.selectedboattype = event.detail.boatTypeId;
        //alert('after event: selected boat Type: '+ this.selectedboattype );
        //alert(this.selectedboattype );
        //this.selectedboattype = event.detail
        this.template.querySelector('c-boat-search-results').searchBoats(this.selectedboattype);
    }
}<file_sep>/scripts/Azure/scripts/getDeltaBuild_Me.sh
#!/bin/bash

Start_Date=$1
End_Date=$2
branchName=$3

################################################################################
echo 'Starting Salesforce Prepare Build Job'
echo 'Command Name = ' $0
echo 'Start Date   = ' $Start_Date
echo 'End Date     = ' $End_Date
echo 'Branch Name  = ' $branchName
################################################################################

#LOG_PATH=/var/lib/jenkins/sf-build-job/git/
LOG_PATH_logs=$AGENT_BUILDDIRECTORY/logs
#JENKINS_WS_PATH=/var/lib/jenkins/jobs/MBOLT-ContinuousDelivery-GIT/workspace/sfdc
JENKINS_WS_PATH_sfdc=$AGENT_BUILDDIRECTORY/sfdc
#REPO_LOCAL_COPY_PATH=/var/lib/jenkins/sf-build-job/git/sf_dev_ops
REPO_LOCAL_COPY_PATH=$AGENT_BUILDDIRECTORY/s
#PKG_PATH=/var/lib/jenkins/sf-build-job/git/build/build-$4/
#PKG_PATH=$AGENT_BUILDDIRECTORY/builds/build-$4/

mkdir -p $LOG_PATH_logs
mkdir -p $JENKINS_WS_PATH_sfdc
#mkdir -p $PKG_PATH

cd $REPO_LOCAL_COPY_PATH
echo 'Git branch list:'
git checkout $branchName

if [[ `git branch --list $branchName`  ]];then
	echo "Branch " $branchName "exists !"
else
	echo "Branch " $branchName "does not exists !"
	exit;

fi

cp /dev/null $LOG_PATH_logs/out.log
chmod 777 $LOG_PATH_logs/out.log
cp /dev/null $LOG_PATH_logs/main.log
chmod 777 $LOG_PATH_logs/main.log
cp /dev/null $LOG_PATH_logs/mainprocessed.log
chmod 777 $LOG_PATH_logs/mainprocessed.log

#rm -rf $JENKINS_WS_PATH_sfdc/src
#echo "Cleaned up Workspace looks like below..."
#ls -alR $JENKINS_WS_PATH_sfdc/src

#cd $REPO_LOCAL_COPY_PATH
#git pull
git checkout $3
git log --since $Start_Date --until $End_Date --name-only --pretty=format:"%H$" >> $LOG_PATH_logs/main.log

index=0;
lines=`cat $LOG_PATH_logs/main.log`
IFS=$'\n'
        for line in $lines
        do
                echo '>> '$line
                if [[ $line = *\$ ]]; then
                        echo "pattern" $line
                        rev=`echo $line | cut -d '$' -f1`
                        echo "rev =" $rev
                else
                        filex=$(basename "$line")
                        echo "filex = "$filex
                        if [[ $filex = *.* ]] ; then
                               # echo "hello"
                                filenameArray[$index]=$index" & "$line" & "$rev
                        else
                                filenameArray[$index]=$index" & "$line" & "$rev
                        fi
                        ((index++))
                 fi
        done
echo ${#filenameArray[@]}
echo ${filenameArray[@]}

num=${#filenameArray[@]}
echo "num = " $num

for (( i=0; i<=num+1; i++ ))
do
        if [ "${#filenameArray[i]}" -eq 0 ]; then
                echo "i = " $i position has no elements
                continue
        fi

        echo ${filenameArray[i]} >> $LOG_PATH_logs/mainprocessed.log
done

cat $LOG_PATH_logs/mainprocessed.log | awk -F"&" '{print$1"@"$2"@"$3}' | sort -n | awk -F " " '!arr[$3]++' >> $LOG_PATH_logs/out.log

#mkdir -p $JENKINS_WS_PATH_sfdc/src/

cat $LOG_PATH_logs/out.log | while read line
do
  file=$(echo $line | awk -F"@" '{printf" "$2" "}'|xargs)
  version=$(echo $line | awk -F"@" '{printf" "$3" "}'|xargs)
  echo "Processing file " $file   " Version:=>" $version

  fileName=$(basename "$file")
  echo "fileName = "$fileName
  if [[ $fileName = *.* ]] ; then
        dir=$(dirname "$file")
        echo 'Current dirtory path: ' $dir
        mkdir -p $JENKINS_WS_PATH_sfdc/src/"$dir"
        exportDir=/src/$dir
        echo 'export dir:' $exportDir
  else
  #     echo "Its not file..."
        mkdir -p $JENKINS_WS_PATH_sfdc/src/"$file"
        exportDir=/src/$file
        echo 'only file: ' $file
        echo '@file export dir:' $exportDir
  fi

  if [[ $file == *".cls"* ]];then
         cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".cls-meta.xml"* ]];then
        #echo "Getting the Meta XML"
        metaXML=$(echo $file |cut -d '@' -f1 |sed 's/\.cls/.cls-meta.xml/')
        echo $metaXML
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # component File Filter
  if [[ $file == *".component"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".component-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.component/.component-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # Email File Filter
  if [[ $file == *".email"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".email-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.email/.email-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # Page File Filter
  if [[ $file == *".page"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".page-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.page/.page-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # resource File Filter
  if [[ $file == *".resource"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".resource-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.resource/.resource-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

   # trigger File Filter
  if [[ $file == *".trigger"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".trigger-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.trigger/.trigger-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # analyticSnapshots File Filter
  if [[ $file == *".snapshots"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # applications File Filter
  if [[ $file == *".app"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # dashboards File Filter
  if [[ $file == *".dashboard"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # datacategorygroups File Filter
  if [[ $file == *".datacategorygroup"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # flows File Filter
  if [[ $file == *".flow"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # homePageLayouts File Filter
  if [[ $file == *".homePageLayout"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # labels File Filter
  if [[ $file == *".labels"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # layouts File Filter
  if [[ $file == *".layout"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # object File Filter
  if [[ $file == *".object"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # objectTranslations File Filter
 # if [[ $file == *".objectTranslation"* ]];then
 # cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
 #
 # fi

  # portals File Filter
  if [[ $file == *".portal"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # profiles File Filter
  if [[ $file == *"profile"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # remoteSiteSettings File Filter
  if [[ $file == *".remoteSite"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # reports File Filter
  if [[ $file == *".report"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # reportTypes File Filter
  if [[ $file == *".reportType"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # sites File Filter
  if [[ $file == *".site"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".site-meta.xml"* ]];then
        #echo "Getting the Meta XML"
        metaXML=$(echo $file |cut -d '@' -f1 |sed 's/\.site/.site-meta.xml/')
        echo $metaXML
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi

  fi

  # tabs File Filter
  if [[ $file == *".tab"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

 # # translations File Filter
 # if [[ $file == *".translation"* ]];then
 #    cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
 #
 # fi

  # weblinks File Filter
  if [[ $file == *".weblink"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # workflows File Filter
  if [[ $file == *".workflow"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

done

branchName=$(echo $3 | sed 's/\/\...//g')
echo "Branch Name:" $branchName

cp $REPO_LOCAL_COPY_PATH/ant-salesforce.jar $JENKINS_WS_PATH_sfdc/
#cp $REPO_LOCAL_COPY_PATH/deployable-package.xml $JENKINS_WS_PATH_sfdc/src/
cp $REPO_LOCAL_COPY_PATH/src/package.xml $JENKINS_WS_PATH_sfdc/src/
cp $REPO_LOCAL_COPY_PATH/build.xml $JENKINS_WS_PATH_sfdc/
cp $REPO_LOCAL_COPY_PATH/build.properties $JENKINS_WS_PATH_sfdc/
cd $JENKINS_WS_PATH_sfdc/src/src
mv * ../
rm -rf $JENKINS_WS_PATH_sfdc/src/src

###################################################################################
#cd $PKG_PATH/
#cp -r $JENKINS_WS_PATH_sfdc/src .
#cd $PKG_PATH/
###################################################################################

echo 'List of final package:'
ls -l $JENKINS_WS_PATH_sfdc
echo 'src folder content:'
ls -l $JENKINS_WS_PATH_sfdc/src

#echo 'Main log:'
#cat $LOG_PATH_logs/main.log
#echo 'Process log:'
#cat $LOG_PATH_logs/mainprocessed.log
#echo 'out log:'
#cat $LOG_PATH_logs/out.log
#echo 'PKG_Path'
#ls -l $PKG_PATH/src
#buildZip=$(echo salesforce-build-$4.zip)
#zip -r $buildZip *<file_sep>/force-app/main/default/lwc/boatDetailTabs/boatDetailTabs.js
import { LightningElement, wire,api,track } from 'lwc';
// Custom Labels Imports
// import labelDetails for Details
// import labelReviews for Reviews
// import labelAddReview for Add_Review
// import labelFullDetails for Full_Details
// import labelPleaseSelectABoat for Please_select_a_boat
import labelPleaseSelectABoat from '@salesforce/label/c.Please_select_a_boat';
import labelFullDetails from '@salesforce/label/c.Full_Details';
import labelAddReview from '@salesforce/label/c.Add_Review';
import labelReviews from '@salesforce/label/c.Reviews';
import labelDetails from '@salesforce/label/c.Details';

// Boat__c Schema Imports
// import BOAT_ID_FIELD for the Boat Id
// import BOAT_NAME_FIELD for the boat Name
//import BOAT_OBJECT from '@salesforce/schema/Boat__c';
import BOAT_ID_FIELD from '@salesforce/schema/Boat__c.Id';
import BOAT_NAME_FIELD from '@salesforce/schema/Boat__c.Name';
import {getFieldValue, getRecord} from 'lightning/uiRecordApi';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { subscribe, unsubscribe, MessageContext } from 'lightning/messageService';
const BOAT_FIELDS = [BOAT_ID_FIELD, BOAT_NAME_FIELD];
export default class BoatDetailTabs extends LightningElement {
  @track
  boatId;
  @wire(getRecord,{ recordId : '$boatId',fields:BOAT_FIELDS})
  wiredRecord;
  label = {
    labelDetails,
    labelReviews,
    labelAddReview,
    labelFullDetails,
    labelPleaseSelectABoat,
  };
  @wire(MessageContext) messageContext;

  // Decide when to show or hide the icon
  // returns 'utility:anchor' or null
  get detailsTabIconName() {

    return (this.wiredRecord.data ? 'utility:anchor' :'');
  }

  // Utilize getFieldValue to extract the boat name from the record wire
  get boatName() {
    return getFieldValue(this.wiredRecord.data,BOAT_NAME_FIELD);
  }

  // Private
  subscription = null;

  // Subscribe to the message channel
  subscribeMC() {
    // local boatId must receive the recordId from the message
    this.subscription = subscribe(
      this.messageContext,
      BOATMC,
      (message)=>{
        this.boatId = message.recordId;
        console.log('Boat Id in details: '+ this.boatId);
      }
    )
  }

  // Calls subscribeMC()
  connectedCallback() {
    this.subscribeMC();
  }

  // Navigates to record page
  navigateToRecordViewPage() { }

  // Navigates back to the review list, and refreshes reviews component
  handleReviewCreated() { }
}<file_sep>/scripts/Azure/scripts/gitDeltaBuild_DateRange.sh
#!/bin/bash

Start_Date=$1
End_Date=$2
branchName=$3

################################################################################
echo 'Starting Salesforce Prepare Build Job'
echo 'Command Name = ' $0
echo 'Start Date   = ' $Start_Date
echo 'End Date     = ' $End_Date
echo 'Branch Name  = ' $branchName
################################################################################

#LOG_PATH=/var/lib/jenkins/sf-build-job/git/
LOG_PATH_logs=$AGENT_BUILDDIRECTORY/logs
#JENKINS_WS_PATH=/var/lib/jenkins/jobs/MBOLT-ContinuousDelivery-GIT/workspace/sfdc
JENKINS_WS_PATH_sfdc=$AGENT_BUILDDIRECTORY/sfdc
#REPO_LOCAL_COPY_PATH=/var/lib/jenkins/sf-build-job/git/sf_dev_ops
REPO_LOCAL_COPY_PATH=$AGENT_BUILDDIRECTORY/s
#PKG_PATH=/var/lib/jenkins/sf-build-job/git/build/build-$4/
#PKG_PATH=$AGENT_BUILDDIRECTORY/builds/build-$4/

echo $REPO_LOCAL_COPY_PATH
echo $JENKINS_WS_PATH_sfdc
echo $LOG_PATH_logs

mkdir -p $LOG_PATH_logs
mkdir -p $JENKINS_WS_PATH_sfdc
#mkdir -p $PKG_PATH

cd $REPO_LOCAL_COPY_PATH
echo 'Git branch list:'
git checkout $branchName

if [[ `git branch --list $branchName`  ]];then
	echo "Branch " $branchName "exists !"
else
	echo "Branch " $branchName "does not exists !"
	exit;

fi

echo $branchName

cp /dev/null $LOG_PATH_logs/out.log
chmod 777 $LOG_PATH_logs/out.log
cp /dev/null $LOG_PATH_logs/main.log
chmod 777 $LOG_PATH_logs/main.log
cp /dev/null $LOG_PATH_logs/mainprocessed.log
chmod 777 $LOG_PATH_logs/mainprocessed.log

#rm -rf $JENKINS_WS_PATH_sfdc/src
#echo "Cleaned up Workspace looks like below..."
#ls -alR $JENKINS_WS_PATH_sfdc/src

#cd $REPO_LOCAL_COPY_PATH
#git pull
git checkout $3
git log --since "$Start_Date" --until "$End_Date" --name-only --pretty=format:"%H$" >> $LOG_PATH_logs/main.log

index=0;
lines=`cat $LOG_PATH_logs/main.log`
IFS=$'\n'
        for line in $lines
        do
                echo '>> '$line
                if [[ $line = *\$ ]]; then
                        echo "pattern" $line
                        rev=`echo $line | cut -d '$' -f1`
                        echo "rev =" $rev
                else
                        filex=$(basename "$line")
                        echo "filex = "$filex
                        if [[ $filex = *.* ]] ; then
                               # echo "hello"
                                filenameArray[$index]=$index" & "$line" & "$rev
                        else
                                filenameArray[$index]=$index" & "$line" & "$rev
                        fi
                        ((index++))
                 fi
        done
echo ${#filenameArray[@]}
echo ${filenameArray[@]}

num=${#filenameArray[@]}
echo "num = " $num

for (( i=0; i<=num+1; i++ ))
do
        if [ "${#filenameArray[i]}" -eq 0 ]; then
                echo "i = " $i position has no elements
                continue
        fi

        echo ${filenameArray[i]} >> $LOG_PATH_logs/mainprocessed.log
done

cat $LOG_PATH_logs/mainprocessed.log | awk -F"&" '{print$1"@"$2"@"$3}' | sort -n | awk -F "@" '!arr[$2]++' >> $LOG_PATH_logs/out.log

#mkdir -p $JENKINS_WS_PATH_sfdc/src/

cat $LOG_PATH_logs/out.log | while read line
do
  #file=$(echo $line | awk -F"@" '{printf" "$2" "}'|xargs)
  file=$(echo $line | cut -d '@' -f2 |xargs)
  version=$(echo $line | awk -F"@" '{printf" "$3" "}'|xargs)
  echo "Processing file " $file   " Version:=>" $version

  fileName=$(basename "$file")
  echo "fileName = "$fileName
  if [[ $fileName = *.* ]] ; then
        dir=$(dirname "$file")
        echo 'Current dirtory path: ' $dir
        mkdir -p $JENKINS_WS_PATH_sfdc/src/"$dir"
        exportDir=/src/$dir
        echo 'export dir:' $exportDir
  else
  #     echo "Its not file..."
        mkdir -p $JENKINS_WS_PATH_sfdc/src/"$file"
        exportDir=/src/$file
        echo 'only file: ' $file
        echo '@file export dir:' $exportDir
  fi

  if [[ $file == *".cls"* ]];then
         cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".cls-meta.xml"* ]];then
        #echo "Getting the Meta XML"
        metaXML=$(echo $file |cut -d '@' -f1 |sed 's/\.cls/.cls-meta.xml/')
        echo $metaXML
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

   # content Asset Filter Supriya
  if [[ $file == *".asset"* ]];then
         cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".asset-meta.xml"* ]];then
        #echo "Getting the Meta XML"
        metaXML=$(echo $file |cut -d '@' -f1 |sed 's/\.asset/.asset-meta.xml/')
        echo $metaXML
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # component File Filter
  if [[ $file == *".component"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".component-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.component/.component-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # Email File Filter
  if [[ $file == *".email"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".email-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.email/.email-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # Page File Filter
  if [[ $file == *".page"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".page-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.page/.page-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

  # resource File Filter
  if [[ $file == *".resource"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".resource-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.resource/.resource-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

   # trigger File Filter
  if [[ $file == *".trigger"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".trigger-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.trigger/.trigger-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

   # lwc File Filter Supriya
  #if [[ $file == *".js"* ]];then
     #cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     #if [[ $file != *".js-meta.xml"* ]];then
        #metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.js/.js-meta.xml/')
        #cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
    # fi
  #fi

    # aura File Filter Supriya
  if [[ $file == *".cmp"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".cmp-meta.xml"* ]];then
        metaXML=$(echo $file |cut -d '#' -f1 |sed 's/\.cmp/.cmp-meta.xml/')
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi
  fi

   # lwc html File Filter Supriya
  if [[ $file == *".html"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # aura css File Filter Supriya
  if [[ $file == *".css"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

    # aura js File Filter Supriya
  if [[ $file == *".js"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # aura documentation File Filter Supriya
  if [[ $file == *".auradoc"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # aura event File Filter Supriya
  if [[ $file == *".evt"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # aura design File Filter Supriya
  if [[ $file == *".design"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # aura svg File Filter Supriya
  if [[ $file == *".svg"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

    # appMenu File Filter Supriya
  if [[ $file == *".appMenu"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # analyticSnapshots File Filter
  if [[ $file == *".snapshots"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # assignmentRules File Filter Supriya
  if [[ $file == *".assignmentRules"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # autoResponseRules File Filter Supriya
  if [[ $file == *".autoResponseRules"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
    # community File Filter Supriya
  if [[ $file == *".community"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # connectedApp Filter Supriya
  if [[ $file == *".connectedApp"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # duplicateRule Filter Supriya
  if [[ $file == *".duplicateRule"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # matchingRule Filter Supriya
  if [[ $file == *".matchingRule"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # topicsForObject Filter Supriya
  if [[ $file == *".topicsForObject"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # territory Filter Supriya
  if [[ $file == *".territory"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
  # approvalProcess Filter Supriya
  if [[ $file == *".approvalProcess"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
  # interface Filter Supriya
  if [[ $file == *".intf"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # tokens Filter Supriya
  if [[ $file == *".tokens"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi
   # lightning Bolt Filter Supriya
  if [[ $file == *".lightningBolt"* ]];then
        cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # applications File Filter
  if [[ $file == *".app"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # globalValueSet File Filter Supriya
  if [[ $file == *".globalValueSet"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # dashboards File Filter
  if [[ $file == *".dashboard"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # flexipage File Filter Supriya
  if [[ $file == *".flexipage"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

    # resouce-bundles File Filter Supriya
  if [[ $file == *".resource"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # message Channels File Filter Supriya
  if [[ $file == *".messageChannel"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # role File Filter Supriya
  if [[ $file == *".role"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

    # report and dashboard xml Filter Supriya
  if [[ $file == *".xml"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # datacategorygroups File Filter
  if [[ $file == *".datacategorygroup"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # flows File Filter
  if [[ $file == *".flow"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # homePageLayouts File Filter
  if [[ $file == *".homePageLayout"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # labels File Filter
  if [[ $file == *".labels"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # layouts File Filter
  if [[ $file == *".layout"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # object File Filter
  if [[ $file == *".object"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # quickAction File Filter Supriya
  if [[ $file == *".quickAction"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

    # sharing Rules File Filter Supriya
  if [[ $file == *".sharingRules"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

     # standard Value Set File Filter Supriya
  if [[ $file == *".standardValueSet"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # objectTranslations File Filter
  if [[ $file == *".objectTranslation"* ]];then
    cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # portals File Filter
  if [[ $file == *".portal"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # profiles File Filter Supriya
  if [[ $file == *".profile"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

# profiles File Filter
  #if [[ $file == *//%".profile"* ]];then
   # cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  #fi

   # remoteSiteSettings File Filter
  if [[ $file == *".remoteSite"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # Custom Metadata File Filter Supriya
  if [[ $file == *".md"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # Custom Permissions File Filter Supriya
  if [[ $file == *".customPermission"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # Permissions Sets File Filter Supriya
  if [[ $file == *".permissionset"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # reports File Filter
  if [[ $file == *".report"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # reportTypes File Filter
  if [[ $file == *".reportType"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # sites File Filter
  if [[ $file == *".site"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir
     if [[ $file != *".site-meta.xml"* ]];then
        #echo "Getting the Meta XML"
        metaXML=$(echo $file |cut -d '@' -f1 |sed 's/\.site/.site-meta.xml/')
        echo $metaXML
        cp $REPO_LOCAL_COPY_PATH/$metaXML $JENKINS_WS_PATH_sfdc/$exportDir
     fi

  fi

  # tabs File Filter
  if [[ $file == *".tab"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

 # translations File Filter
  if [[ $file == *".translation"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

  # weblinks File Filter
  if [[ $file == *".weblink"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

   # workflows File Filter
  if [[ $file == *".workflow"* ]];then
     cp $REPO_LOCAL_COPY_PATH/$file $JENKINS_WS_PATH_sfdc/$exportDir

  fi

done

branchName=$(echo $3 | sed 's/\/\...//g')
echo "Branch Name:" $branchName

cp $REPO_LOCAL_COPY_PATH/ant-salesforce.jar $JENKINS_WS_PATH_sfdc/
#cp $REPO_LOCAL_COPY_PATH/deployable-package.xml $JENKINS_WS_PATH_sfdc/src/
cp $REPO_LOCAL_COPY_PATH/src/package.xml $JENKINS_WS_PATH_sfdc/src/
cp $REPO_LOCAL_COPY_PATH/build.xml $JENKINS_WS_PATH_sfdc/
cp $REPO_LOCAL_COPY_PATH/build.properties $JENKINS_WS_PATH_sfdc/
#echo $REPO_LOCAL_COPY_PATH "echo1"
#echo $JENKINS_WS_PATH_sfdc "echo2"
cd $JENKINS_WS_PATH_sfdc/src/src
mv * ../
rm -rf $JENKINS_WS_PATH_sfdc/src/src

###################################################################################
#cd $PKG_PATH/
#cp -r $JENKINS_WS_PATH_sfdc/src .
#cd $PKG_PATH/
###################################################################################

echo 'List of final package:'
ls -l $JENKINS_WS_PATH_sfdc
echo 'src folder content:'
ls -l $JENKINS_WS_PATH_sfdc/src

#echo 'Main log:'
#cat $LOG_PATH_logs/main.log
#echo 'Process log:'
#cat $LOG_PATH_logs/mainprocessed.log
#echo 'out log:'
#cat $LOG_PATH_logs/out.log
#echo 'PKG_Path'
#ls -l $PKG_PATH/src
#buildZip=$(echo salesforce-build-$4.zip)
#zip -r $buildZip *

languages: Shell JavaScript

repo_language: Shell

repo_name: subalchaudhari/lwcSuperBadge


text:
<file_sep># Realtime Chat Application

### [Live Site](https://realtime-chat-application.netlify.com)

![Chat Application](https://i.ytimg.com/vi/ZwFA3YMfkoc/maxresdefault.jpg)

## Introduction

Full Realtime Chat Application. using React on the front end, with NodeJS + Socket.io web socket library on the back end.

handling sending and receiving messages using web sockets and Socket.io to make any real-time application.

Setup:

- run `npm i && npm start` for both client and server side to start the development server
  If you have troubles with create-react-app, make sure to run it as 'npx create-react-app'

repo_name: Abderrahmenla/chat-app


text:
<file_sep># Virtual_Stylist_Assistant

The training set and test set are given in the folders as named.
Here, MNIST Fashion Class dataset used which contains 70000 images;

1. 60000 for training
2. 10000 for testing

Images are 28*28 grayscale images. Each image is represented by a single row in the dataset with 28*28 = 784 pixel values present in the 784 columns.

The 10 target classes are as follows:

0 => T-shirt/top 1 => Trouser 2 => Pullover 3 => Dress 4 => Coat 5 => Sandal 6 => Shirt 7 => Sneaker 8 => Bag 9 => Ankle boot

Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255.

Go through the jupyter notebook file for the code which has a clear visualization of the dataset used.


text:
<file_sep># Full Nav Calc V.0.0.4
require 'date'

transactions = [
                {:date => '2011-04-16', :action => "BUY", :ticker => "AAPL", :price => 11.0, :qty => 15.0},
                {:date => '2011-04-17', :action => "BUY", :ticker => "AAPL", :price => 12.0, :qty => 15.0},
                # {:date => '2011-05-22', :action => "SELL", :ticker => "AAPL", :price => 11.0, :qty => 15.0},
                # {:date => '2011-05-23', :action => "SELL", :ticker => "AAPL", :price => 11.0, :qty => 15.0},
                # {:date => '2011-06-16', :action => "BUY", :ticker => "AAPL", :price => 11.0, :qty => 15.0}
                {:date => '2011-04-16', :action => "BUY", :ticker => "AAPL", :price => 11.0, :qty => 15.0},
                {:date => '2011-04-16', :action => "BUY", :ticker => "AAPL", :price => 12.0, :qty => 5.0},
                {:date => '2011-04-17', :action => "BUY", :ticker => "AAPL", :price => 12.0, :qty => 5.0},
                {:date => '2011-04-19', :action => "SELL", :ticker => "AAPL", :price => 10.0, :qty => 20.0},
                {:date => '2011-04-22', :action => "SELL", :ticker => "AAPL", :price => 15.0, :qty => 5.0},
                {:date => '2011-05-01', :action => "BUY", :ticker => "AAPL", :price => 12.0, :qty => 55.0},
                {:date => '2011-05-02', :action => "BUY", :ticker => "AAPL", :price => 13.0, :qty => 55.0},
                {:date => '2011-05-04', :action => "SELL", :ticker => "AAPL", :price => 13.0, :qty => 100.0},
                {:date => '2011-05-04', :action => "SELL", :ticker => "AAPL", :price => 13.0, :qty => 10.0},
                {:date => '2011-05-19', :action => "BUY", :ticker => "AAPL", :price => 100.0, :qty => 5000.0},
                {:date => '2011-05-20', :action => "BUY", :ticker => "AAPL", :price => 101.0, :qty => 500.0},
                {:date => '2011-05-25', :action => "SELL", :ticker => "AAPL", :price => 100.0, :qty => 500.0},
                {:date => '2011-06-09', :action => "BUY", :ticker => "GOOG", :price => 100.0, :qty => 500.0},
                {:date => '2011-06-12', :action => "SELL", :ticker => "GOOG", :price => 55.0, :qty => 100.0}
                # {:date => '2011-06-12', :action => "CASH ADJUSTMENT", :total => -200000}
               ]

eod_prices = [
              {:date => '2011-04-15', :ticker => 'AAPL', :eod_price => 9.0},
              {:date => '2011-04-16', :ticker => 'AAPL', :eod_price => 10.0},
              {:date => '2011-04-17', :ticker => 'AAPL', :eod_price => 11.0},
              {:date =>'2011-04-18', :ticker => 'AAPL', :eod_price => 12.0},
              {:date => '2011-04-19', :ticker => 'AAPL', :eod_price => 11.0},
              {:date => '2011-04-20', :ticker => 'AAPL', :eod_price => 13.0},
              {:date => '2011-04-21', :ticker => 'AAPL', :eod_price => 12.0},
              {:date => '2011-04-22', :ticker => 'AAPL', :eod_price => 14.0},
              {:date => '2011-05-01', :ticker => 'AAPL', :eod_price => 17.0},
              {:date => '2011-05-02', :ticker => 'AAPL', :eod_price => 19.0},
              {:date => '2011-05-03', :ticker => 'AAPL', :eod_price => 22.0},
              {:date => '2011-05-04', :ticker => 'AAPL', :eod_price => 22.0},
              {:date => '2011-05-05', :ticker => 'AAPL', :eod_price => 22.0},
              {:date => '2011-05-06', :ticker => 'AAPL', :eod_price => 22.0},
              {:date => '2011-05-21', :ticker => 'AAPL', :eod_price => 31.0},
              {:date => '2011-05-22', :ticker => 'AAPL', :eod_price => 31.0},
              {:date => '2011-06-04', :ticker => 'AAPL', :eod_price => 10.0},
              {:date => '2011-06-09', :ticker => 'AAPL', :eod_price => 10.0},
              {:date => '2011-06-09', :ticker => 'GOOG', :eod_price => 55.0},
              {:date => '2011-06-10', :ticker => 'GOOG', :eod_price => 100.0},
              {:date => '2011-06-11', :ticker => 'GOOG', :eod_price => 99.0},
              {:date => '2011-06-20', :ticker => 'GOOG', :eod_price => 604.0}
             ]

###### EMPTY ARRAYS ######

open_positions = []

trades_array = []
sells_log = []

cash_changes = []

###### Taking arrays to create a main array to work with ######

#loop through the transactions array
transactions.each_with_index do |trade,idx|

############# BUY CHECK
  if trade[:action] == 'BUY'

  # shovel the transactions hash into trades_array
  trades_array << {:date => trade[:date], :desc => trade[:action], :ticker => trade[:ticker], :price => trade[:price], :qty => trade[:qty]}

  ###############################################

    #check if Buy exists in open_positions array, if not add to array
    if open_positions.any? {|o| o[:ticker] == trade[:ticker] && o[:price] == trade[:price] && o[:qty] > 0 && o[:date] == trade[:date] && o[:mark] != true}
      matching_positions = open_positions.select {|o| o[:ticker] == trade[:ticker] && o[:price] == trade[:price] && o[:mark] != true}
      last_index = (matching_positions.count) - 1
      matching_positions[last_index][:qty] += trade[:qty]
    else
      open_positions << {:date => trade[:date], :ticker => trade[:ticker], :price => trade[:price], :qty => trade[:qty], :log => 'BUY'}
        if open_positions.any? {|o| o[:ticker] == trade[:ticker] && o[:price] == trade[:price] && Date.parse(o[:date]) < Date.parse(trade[:date])}
          matching_positions = open_positions.select {|o| o[:ticker] == trade[:ticker] && o[:price] == trade[:price] && Date.parse(o[:date]) < Date.parse(trade[:date])}
          last_index = (matching_positions.count) - 1
          add_previous_qty = matching_positions[last_index][:qty]
          last_position = (open_positions.count) - 1
          open_positions[last_position][:qty] += add_previous_qty
        end
    end

    unique_prices = transactions.select {|o| o[:ticker] == trade[:ticker]}.uniq! {|t| t[:price]}
    if unique_prices != nil
      unique_prices.each do |uq|
        check_positions = open_positions.select {|o| o[:ticker] == trade[:ticker] && o[:price] == uq[:price]}
        check_pos_count = check_positions.count - 1
        check_positions.each_with_index do |pos, idx|
          if idx < check_pos_count
            pos[:mark] = true
          end
        end
      end
    end
  ###############################################

############# SELL CHECK
  elsif trade[:action] == 'SELL'

  ###############################################

    if open_positions.any? {|o| o[:ticker] == trade[:ticker] && o[:qty] > 0 && o[:mark] != true}
      ops = open_positions.select {|o| o[:ticker] == trade[:ticker] && o[:qty] > 0 && o[:mark] != true}
      qty_sold = trade[:qty]
      ops.each do |op|
        if qty_sold > 0 && qty_sold >= op[:qty]
          remainder = qty_sold - op[:qty]
          op_decrease = qty_sold - remainder
          qty_subtracted = op[:qty] - op_decrease
          open_positions << {:date => trade[:date], :ticker => trade[:ticker], :price => op[:price], :qty => qty_subtracted, :sold => op_decrease, :log => 'SELL'}
          sells_log << {:date => trade[:date], :desc => 'SELL', :ticker => trade[:ticker], :price => op[:price], :qty => op_decrease, :sell_price => trade[:price]}
          qty_sold = remainder
        elsif qty_sold > 0 && qty_sold < op[:qty]
          qty_subtracted = op[:qty] - qty_sold
          open_positions << {:date => trade[:date], :ticker => trade[:ticker], :price => op[:price], :qty => qty_subtracted, :sold => qty_sold, :log => 'SELL'}
          sells_log << {:date => trade[:date], :desc => 'SELL', :ticker => trade[:ticker], :price => op[:price], :qty => qty_sold, :sell_price => trade[:price]}
          break
        else
          puts "ERROR with qty_sold if: #{op} :: #{trade} :: #{qty_sold}"
        end
      end
    end

    unique_prices = transactions.select {|o| o[:ticker] == trade[:ticker]}.uniq! {|t| t[:price]}
    if unique_prices != nil
      unique_prices.each do |uq|
        check_positions = open_positions.select {|o| o[:ticker] == trade[:ticker] && o[:price] == uq[:price]}
        check_pos_count = check_positions.count - 1
        check_positions.each_with_index do |pos, idx|
          if idx < check_pos_count
            pos[:mark] = true
          end
        end
      end
    end

  ###############################################

  elsif trade[:action] == 'CASH ADJUSTMENT'
    cash_changes << {:date => trade[:date], :desc => 'CASH ADJUSTMENT', :total => trade[:total]}

  else
    puts '[BUY/SELL] - ERROR: Action not BUY or SELL!'
  end

end

op_log = []
market_log = []

op_buy_log = []
op_buy = open_positions.select {|o| o[:log] == 'BUY'}
op_buy.each do |op|
  op_buy_log << {:date => op[:date], :desc => 'POS', :ticker => op[:ticker], :price => op[:price], :qty => op[:qty], :order => 2}
  op_log << {:date => op[:date], :ticker => op[:ticker], :price => op[:price], :qty => op[:qty]}
end

op_sell_log = []
op_sell = open_positions.select {|o| o[:log] == 'SELL'}
op_sell.each do |op|
  op_sell_log << {:date => op[:date], :desc => 'POS', :ticker => op[:ticker], :price => op[:price], :qty => op[:qty], :order => 4}
  op_log << {:date => op[:date], :ticker => op[:ticker], :price => op[:price], :qty => op[:qty]}
end

 ###############################################

op_log.each_with_index do |op, idx|
  if op[:qty] > 0
    start_date = op[:date]
    if op_log.any? {|o| o[:ticker] == op[:ticker] && o[:price] == op[:price] && Date.parse(o[:date]) >= Date.parse(op[:date]) && o[:qty] == 0 && o[:mark] != true}
      end_day = op_log.find {|o| o[:ticker] == op[:ticker] && o[:price] == op[:price] && Date.parse(o[:date]) >= Date.parse(op[:date]) && o[:qty] == 0 && o[:mark] != true}
      find_mrkt = eod_prices.select {|o| o[:ticker] == op[:ticker] && Date.parse(o[:date]) >= Date.parse(op[:date]) && Date.parse(o[:date]) < Date.parse(end_day[:date])}
      find_mrkt.each do |mkt|
        #puts "#{idx} :: #{mkt[:date]} | #{mkt[:ticker]} | Mrkt Price: #{mkt[:eod_price]} | Book: #{op[:price]} | Qty: #{op[:qty]}"
        market_log << {:date => mkt[:date], :desc => 'MRKT', :ticker => mkt[:ticker], :price => mkt[:eod_price], :qty => op[:qty], :book_price => op[:price]}
      end
      end_day[:mark] = true
    else
      find_mrkt = eod_prices.select {|o| o[:ticker] == op[:ticker] && Date.parse(o[:date]) >= Date.parse(op[:date])}
      find_mrkt.each do |mkt|
        #puts "#{idx} :: #{mkt[:date]} | #{mkt[:ticker]} | Mrkt Price: #{mkt[:eod_price]} | Book: #{op[:price]} | Qty: #{op[:qty]}"
        market_log << {:date => mkt[:date], :desc => 'MRKT', :ticker => mkt[:ticker], :price => mkt[:eod_price], :qty => op[:qty], :book_price => op[:price]}
      end
    end
  end
end

  ###############################################

if sells_log != nil
  trades_array += sells_log
end

if cash_changes != nil
  trades_array += cash_changes
end

if market_log !=nil
  market_log.uniq!
  trades_array += market_log
end

trades_array.sort! { |x, y| Date.parse(x[:date]) <=> Date.parse(y[:date])}

negative_sells = trades_array.select {|t| t[:desc] == 'SELL'}
negative_sells.each do |trade|
  trade[:qty] *=-1
end

###### VARIABLES ######

nav_units = 1000.0
initial_cash_balance = 2100000.0
cash_balance = initial_cash_balance
stock_balance = 0.0
nav_per_unit = cash_balance / nav_units
market_stock_balance = 0.0

trades_count = trades_array.count
qty = 0.0
portfolio = []

puts '============================================================================='
puts "Starting: Cash Balance: #{cash_balance} || Stock Balance: #{stock_balance}"
puts "Starting Net Asset Value Units: #{nav_units} ||  NAV per Unit: #{nav_per_unit}"
puts '============================================================================='

single_dash = '----------------------------------------------------------------------------------------------------'

trades_array.each_with_index do |trade, idx|
puts single_dash
  if trade[:desc] == 'BUY'
    book_value = trade[:qty] * trade[:price] * -1
    cash_balance += book_value
    stock_balance += (book_value * -1)
    total_value = cash_balance + stock_balance
    puts "[#{idx+1}] || #{trade[:date]} || [#{trade[:desc]}] || [#{trade[:ticker]}] || Book Price: #{trade[:price]} || Qty: #{trade[:qty]} || Book Value: #{book_value}"
    puts "     Cash Balance: #{cash_balance} || Stock Balance: #{stock_balance} || Total Value: #{total_value}"

  elsif trade[:desc] == 'SELL'
    sell_value = trade[:qty] * trade[:sell_price] * -1
    cash_balance += sell_value
    stock_balance += (trade[:price] * -1)
    total_value = cash_balance + stock_balance
    puts "[#{idx+1}] || #{trade[:date]} || [#{trade[:desc]}] || [#{trade[:ticker]}] || Sell Price: #{trade[:sell_price]} || Qty: #{trade[:qty]} || Sell Value: #{sell_value}"
    book_value = trade[:price] * trade[:qty]
    puts "     Book Price: #{trade[:price]} || Book Value: #{book_value}"
    profit = sell_value - book_value
    profit_percent = ((profit) / book_value) * 100
    puts "     Profit: #{profit} || Profit %: #{profit_percent}%"
    puts "     Cash Balance: #{cash_balance} || Stock Balance: #{stock_balance} || Total Value: #{total_value}"

  elsif trade[:desc] == 'MRKT'
    book_value = trade[:book_price] * trade[:qty]
    mrkt_value = trade[:qty] * trade[:price]
    mrkt_difference = mrkt_value - book_value
    stock_balance += mrkt_difference
    total_value = cash_balance + stock_balance
    puts "[#{idx+1}] || #{trade[:date]} || [#{trade[:desc]}] || [#{trade[:ticker]}] || Market Price: #{trade[:price]} || Qty: #{trade[:qty]}"
    puts "     Book Price: #{trade[:book_price]} || Book Value: #{book_value}"
    stock_change = mrkt_value - book_value
    stock_change_percent = ((stock_change) / book_value) * 100
    puts "     Stock Change: #{stock_change} || Stock Change %: #{stock_change_percent}"
    puts "     Cash Balance: #{cash_balance} || Stock Balance: #{stock_balance} || Total Value: #{total_value}"

  elsif trade[:desc] == 'CASH ADJUSTMENT'
    cash_balance += trade[:total]
    total_value = cash_balance + stock_balance
    puts "[#{idx+1}] || #{trade[:date]} || CASH ADJUSTMENT for $#{trade[:total]}"
    puts "     Cash Balance: #{cash_balance} || Stock Balance: #{stock_balance} || Total Value: #{total_value}"
  end

  if idx == trades_count - 1
    portfolio = [total_value - initial_cash_balance, ((total_value - initial_cash_balance) / initial_cash_balance) * 100]
  end

end

puts single_dash

puts ''
puts 'PORTFOLIO STATUS:'
puts "Total Value Change: $#{portfolio[0]} || Return: #{portfolio[1]}%"
puts ''

puts '============================================================================='
puts 'Positions:'
op_log.sort! { |x, y| Date.parse(x[:date]) <=> Date.parse(y[:date])}.each do |op|
  if op[:qty] > 0
    puts "#{op[:date]} || [#{op[:ticker]}] || Book Price: #{op[:price]} || Qty: #{op[:qty]}"
  else
    puts "#{op[:date]} || [#{op[:ticker]}] || Book Price: #{op[:price]} || Qty: #{op[:qty]} - [CLOSED]"
  end
end<file_sep>require 'open-uri'
require 'csv'
require 'mechanize'

#################################################################################
# Collect End of Day Market Prices

ticker = 'GOOG'

agent = Mechanize.new
page = agent.get("http://finance.yahoo.com/q/hp?s=#{ticker}+Historical+Prices")

dl_csv = page.link_with(:text => 'Download to Spreadsheet').href

puts dl_csv

def read(url, ticker)
 CSV.new(open(url), :headers => :first_row).each do |line|
   puts " #{ticker} || #{line['Date']} || #{line['Close']} || #{line['Adj Close']} "
 end
end

read(dl_csv, ticker)

#################################################################################

# Collect Current Market Prices

tickers = ["GOOG", "AAPL", "NOK"]
plus = '+'

ticker_string = ''

tickers.each_with_index do |ticker, idx|
  ticker_string = ticker_string.concat(ticker.to_s)
  if idx < tickers.count-1
    ticker_string = ticker_string+plus
  end
end

url = "http://finance.yahoo.com/d/quotes.csv?s=#{ticker_string}&f=sd1t1l1"

 CSV.new(open(url)).each do |line|
   puts "Ticker: #{line[0]} || Last Trade Date: #{line[1]} || Last Trade Time: #{line[2]} || Last Trade Price: #{line[3]}"
 end

# s = symbol
# n = name
# l1 = Last Trade (Price Only)
# d1 = Last Trade Date
# t1 = Last Trade Time
# o = open
# h = Day's High
# g = Day's Low
# d = Dividend/Share
# r = P/E Ratio<file_sep>kurotrade
============

This is to test eventual logic that will be integrated into kurotrade.

This script is for kurotrade's position tracking.

### Needs to be refactored!

## FAQ:

1. Why is this called Curo instead of Kuro?

- Done on purpose! :)

2. OH GOD. if in ifs.

- I'll fix it later...

languages: Markdown Ruby