text:
# blockchain-starter-kit

Hello! This GitHub repository contains a starter kit for building a blockchain application using the IBM Blockchain Platform. The starter kit includes everything you need for developing smart contracts, exposing them via RESTful APIs, and building end user applications. It also includes tooling that allows you to set up an IBM Cloud DevOps toolchain that will automatically deploy your blockchain application, and any future changes you make, to the IBM Cloud.

Follow the steps below to get started.

## 1. Setting up the local development environment

In order to use this starter kit, you will need to know how to develop blockchain applications. The IBM Blockchain Platform is built on open source technologies from the Linux Foundation Hyperledger Project, including Hyperledger Fabric and Hyperledger Composer.

You will use these skills later on as part of the starter kit, so don't skip ahead!

### Hyperledger Fabric

Hyperledger Fabric is a platform for building blockchain applications. Hyperledger Fabric provides the blockchain technology itself, along with APIs and SDKs that allow you to develop smart contracts and end user applications.

You can learn more about Hyperledger Fabric, including how to set up your local development environment, by following the Hyperledger Fabric tutorials available here: http://hyperledger-fabric.readthedocs.io/en/release-1.1/tutorials.html

In particular, we recommend that you follow the Hyperledger Fabric "Writing Your First Application" and "Chaincode for Developers" tutorials. These tutorials will teach you how to develop a smart contract, and build an end user application.

### Hyperledger Composer

Hyperledger Composer is a framework or layer that builds on top of Hyperledger Fabric, that provides functionality that allows you to model your blockchain business network, and easily generate RESTful APIs and end user applications.

You can learn more about Hyperledger Composer, including how to set up your local development environment, by following the Hyperledger Composer tutorial available here: https://hyperledger.github.io/composer/latest/tutorials/tutorials.html

In particular, we recommend that you follow the Hyperledger Composer development tutorial. This tutorial will teach you how to develop a smart contract, expose it via a RESTful API, and build an end user application.

### Choosing between the two

This starter kit is designed to work with smart contracts developed using either Hyperledger Fabric or Hyperledger Composer. You can choose either of the two, depending on your skills, and the needs of your blockchain solution.

Please note that currently, this starter kit can only generate RESTful APIs for smart contracts developed using Hyperledger Composer. You will need to build your own RESTful API server for smart contracts developed using Hyperledger Fabric.

## 2. Setting up the project and DevOps toolchain

To start building a blockchain application using this starter kit, you must first clone this GitHub repository into a new GitHub repository. You will then develop your blockchain application by working on the cloned GitHub repository. You do not need to manually clone this GitHub repository; please carry on reading!

You also want to set up a DevOps toolchain that will automatically build, test, and deploy your blockchain application to the IBM Cloud. The IBM Cloud DevOps service can be used to to run the DevOps toolchain, and this starter kit includes configuration suitable for use with the IBM Cloud DevOps service.

Click the following link to set up a DevOps toolchain for your blockchain application:

[Set up DevOps toolchain](https://console.bluemix.net/devops/setup/deploy/?repository=https%3A//github.com/sstone1/blockchain-starter-kit&branch=master&env_id=ibm%3Ayp%3Aus-south)

The "Create a Toolchain" page will appear:

![Toolchain initial screen](./media/toolchain-initial.png)

You must need to specify a name for your DevOps toolchain in the "Toolchain Name" field. In this example, I'll use "simons-blockchain-app" as the toolchain name:

![Toolchain name specified](./media/toolchain-name-specified.png)

Next, if you haven't authorized the IBM Cloud DevOps service to access your GitHub organization, you will see an "Authorize" button:

![Toolchain authorization required](./media/toolchain-auth-required.png)

You must click this button and authorize the IBM Cloud DevOps service to access your GitHub organization to continue. You will then see the following options:

![Toolchain authorization complete](./media/toolchain-auth-complete.png)

You must now specify a name for your clone of this GitHub repository. We recommend that you give it the same name that you used for the DevOps toolchain. In this example, I'll use "simons-blockchain-app" as the name of the cloned GitHub repository:

![Toolchain GitHub options specified](./media/toolchain-github-specified.png)

That's it! Click the "Create" button to create your new DevOps toolchain, and GitHub repository. You should be taken to your newly created DevOps toolchain page:

![Toolchain created](./media/toolchain-created.png)

The "GitHub" button in the middle will take you to your newly created GitHub repository. You will clone this GitHub repository into your local development environment, so you can work on your blockchain application.

The "Delivery Pipeline" button on the right will take you to the delivery pipeline for your DevOps toolchain. From here, you can inspect the output from the latest automated build and deployment of your blockchain application.

## 3. Cloning the GitHub repository

Click on the "GitHub" button to go to your newly created GitHub repository. If you are no longer on the DevOps toolchain page, you can find it by navigating to your GitHub organisation on [https://github.com](https://github.com).

![GitHub repository](./media/github-repo.png)

At the top of the page, you can see a link to the DevOps toolchain - useful if you have lost the link and need to find your way back!

Clone this GitHub repository to your local development environment using your favourite Git tool of choice. If you open this repository in an editor such as Visual Studio Code, you should see the following project structure:

![VSCode initial project structure](./media/vscode-initial.png)

## 4. Creating a smart contract

### Hyperledger Fabric

Create a directory in the `contracts` directory in your GitHub repository. The name of this directory will be the name of the smart contract. Inside this new directory, you can place the Go (.go) files that make up your smart contract developed using Hyperledger Fabric chaincode.

In this example, I have created a smart contract called "marbles":

![Chaincode](./media/chaincode.png)

You can work on this smart contract using your favourite editor, following the documentation on the Hyperledger Fabric website.

### Hyperledger Composer

You can use the Yeoman plugin provided by Hyperledger Composer to create a skeleton smart contract for use in your blockchain application. You should have installed Yeoman and this plugin as part of the first step in this guide.

Using the command line, change into the `contracts` directory in your GitHub repository. Run Yeoman using `yo` to generate a skeleton smart contract in this directory. Ensure that you select the "Hyperledger Composer" generator, and then specify that you want to create a "Business Network" project.

In this example, I have created a smart contract called "simons-network":

![Yeoman business network](./media/yeoman-business-network.png)

![Business network](./media/business-network.png)

You can work on this smart contract using your favourite editor, following the documentation on the Hyperledger Composer website.

### Pushing the changes

The new smart contract will appear as pending changes in your GitHub repository. Add, commit, and push these changes into your GitHub repository. The DevOps toolchain you created earlier will detect these changes, and then automatically build, test, and deploy those changes to the IBM Cloud.

## 5. Checking the status of the DevOps toolchain

Navigate to the DevOps toolchain page, and click on the "Delivery Pipeline" button. You should see the following page, giving you an overview of the current status of your delivery pipeline:

![Delivery Pipeline overview](./media/delivery-pipeline-overview.png)

The delivery pipeline is made up of two phases, "BUILD" and "DEPLOY".

The "BUILD" phase of the delivery pipeline clones your GitHub repository, installs any dependencies, and runs all of the automated unit tests for all of your smart contracts. If any unit tests fail, then the delivery pipeline will fail and your changes will not be deployed.

The "DEPLOY" phase of the delivery pipeline deploys your smart contracts into the IBM Cloud. It is reponsible for provisioning and configuring an instance of the IBM Blockchain Platform: Starter Plan (the blockchain network), an instance of Cloudant (the wallet for blockchain credentials), deploying the smart contracts, and deploying RESTful API servers for each deployed smart contract.

If you click "View logs and history", you can see the latest logs for your build:

![Delivery Pipeline logs](./media/delivery-pipeline-logs.png)

Both "BUILD" and "DELIVERY" phases should be green and showing that no errors have occurred. If this is not the case, you must use the logs to investigate the cause of the errors.

## 6. Accessing the deployed REST server

### Hyperledger Fabric

Currently, this starter kit does not deploy a RESTful API server for smart contracts developed using Hyperledger Fabric.

### Hyperledger Composer

The DevOps toolchain has automatically deployed a RESTful API server for each deployed smart contract. You can use these RESTful APIs to build end user applications that interact with a smart contract.

The URLs for the deployed RESTful API servers are available in the logs for the "DELIVERY" phase, but you can also find them in the [IBM Cloud Dashboard](https://console.bluemix.net/dashboard/apps). The RESTful API server is deployed as an application, with a name made up of "composer-rest-server-" and the name of the smart contract. In this example, the RESTful API server is called "composer-rest-server-simons-network":

![IBM Cloud Dashboard](./media/ibm-cloud-dashboard.png)

Click on the application in the list to navigate to the application details page:

![IBM Cloud RESTful API server application](./media/ibm-cloud-rest-app.png)

Click on the "Visit App URL" link at the top to navigate to the RESTful API explorer, that allows you to discover and try out the RESTful APIs for your deployed smart contract:

![RESTful API explorer](./media/rest-api-explorer.png)

## 7. Updating the deployed smart contract

### Hyperledger Fabric

Changes to deployed smart contracts will also be automatically deployed by the DevOps toolchain as well. You can test this by changing the code in a `.go` file in your smart contract.

Add, commit, and push these changes into your GitHub repository. The DevOps toolchain you created earlier will detect these changes, and then automatically build, test, and deploy those changes to the IBM Cloud.

### Hyperledger Composer

Changes to deployed smart contracts will also be automatically deployed by the DevOps toolchain as well. You can test this by adding a new asset definition to a `.cto` file in your smart contract, for example:

```
asset SimonsAsset extends SampleAsset {

}
```

Add, commit, and push these changes into your GitHub repository. The DevOps toolchain you created earlier will detect these changes, and then automatically build, test, and deploy those changes to the IBM Cloud.

The RESTful API server will be automatically restarted as part of the deployment, and new RESTful APIs will be available for the new asset type that you have defined:

![Updated RESTful API explorer](./media/rest-api-updated.png)

repository: mttrbrts/clause-sample-perishable-goods

repo_name: mttrbrts/clause-sample-perishable-goods


text:
## Functional Javascript

### Wat?!

---

## Why Functional?

---

#### Write Better Code

**Greater Confidence**

Testable code promotes reliable re-writing and can be objectively ensured to have fewer bugs. Who wants to fix code that was thought to already have been fixed?

**Increased Productivity**

Safe, stable code can be relied on and you can move onto other, more important or interesting, projects. Composing preexisting code will reduce new code and require fewer tests.

**Easier Comprehension**

Shorter, more focused, code is easier to grasp for yourself and other developers. Fewer lines of code means fewer chances for things to go wrong.

---

## SO!

### What does it all mean?

---

## Moar Laziness!

---

## Hooked?

### Good, now some boring stuff.

---

#### Agenda

  1. Introduction
      - Why Javascript?
      - Programming Paradigms
  2. Functional Programming Concepts
      - Functional Javascript snippets
  3. Code Refactoring Examples
  4. Questions
  5. Teach myself - basically I don't care about any of you

---

#### Me

  * Front-end engineer for [@QuickenLoans](http://twitter.com/@QuickenLoans)
  * website [JoshuaKalis.com](http://joshuakalis.com)
  * twitter.com/[@kalisjoshua](http://twitter.com/kalisjoshua)

---

#### Brief experience time-line

  1. Started as a Graphic Designer, NOT a programmer
  2. Moved to Web Design through images first then CSS and HTML
  3. Picked up ASP Classic
  4. Forced to learn Javascript (HATED all of it!)
  5. Learned a little of these: PHP4, C# .NET 2.0, Java
  6. Began to LOVE Javascript

*Self-taught mostly.*

---

## Hi, my name is Josh.

### I <3 Javascript. I might be biased.

---

#### Javascript has a LOT of BAD parts!

  * Variables are free to be overwritten at any time
  * Type coercion within equality checks are unreliable
  * The 'this' value can be tricky for n00bs (as well as everyone else from time to time)
  * Blocks are optional for control structures
  * Switch fall-through
  * The 'arguments' object inside function calls
  * Automatic semi-colon insertion
  * The difference in function statements and expressions
  * Misunderstood misused constructs: eval, with, continue, void
  * Typed wrappers: new Boolean(true), new Number(9), new Array(), etc.
  * new (necessary at times but...)
  * Unused reserved words
  * Unicode
  * The typeof operator is in accurate
  * Floating point numbers: 0.1 + 0.2 !== 0.3 // true
  * The plus (+) operator for [addition concatenation infix]
  * Hoisting
  * NaN... Nyan cat?
  * and (many) more... :(

---

#### What is there to love about Javascript?

  * Ubiquitous
      - It's almost everywhere
      - Setup is done for you
  * Forgiving
      - Making mistakes might still achieve the goal you want
      - Easy to start programming
  * Useful
      - People like having interactive web pages
      - Employable skill
  * Multi-paradigm
      - Write however you want
  * ... and more (probably) but lets move on

---

#### Main Programming Paradigms ([source](http://people.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigm-overview-section.html))

  * Imperative, Procedural, or Structured
      - 1954 FORTRAN
      - "First do this and next do that"
  * Object Oriented
      - 1960s Simula 67
      - "Send messages between objects to simulate the temporal evolution of a set of real world phenomena"
  * Functional
      - 1960s LISP
      - "Evaluate an expression and use the resulting value for something"
  * Others? - [yes, there are lots](http://en.wikipedia.org/wiki/Programming_paradigm#Programming_paradigms)

---

#### Imperative

```javascript
var message = 'Hello ';
var promptMessage = 'What is your name?';
var name = prompt(promptMessage);
alert(message + name);
```

  1. Set some variables.
  2. Ask the user for their name and store that to a variable.
  3. Finally, greet them with a message including their name.

Do we see the 'Procedure' here?

  > "... describes computation in terms of statements that change a program state." ~~ [wikipedia](http://en.wikipedia.org/wiki/Imperative_programming)

---

#### Object Oriented

```javascript
function Greeting () {
    this.name = prompt(Greeting.promptMessage);
}

Greeting.promptMessage = 'What is your name?'; // static(-like) property
Greeting.prototype.say = function (message) {  // inherited function
    alert(message + this.name);
}

var personalGreeting = new Greeting();

personalGreeting.say('Hello ');
```

Here we gain some re-usability, albeit with some verbosity.

  1. Define a 'class'; see the quotes, because Javascript doesn't truly have classes.
      - Added a 'static' property; that is publicly available
      - Added a type-based method; prototypically inherited by all instances
  2. Create an instance of the 'class' with an instance variable of the user's name.
  3. Greet the user with a message including their name.

---

#### I write non-functional Javascript

Just to set you at ease, I am not a functional Javascript doyen writing everything in a functional manner.

**Functional**

Focus is on 'what' to do to accomplish the desired outcome.

---

#### Fair Warning

Functional Programming might infect your brain and change the way that you think about problems. You might find yourself re-evaluating old code and saying something similar to:

  > "The small experience I've had with #Haskell is already changing the way I write #JavaScript, mostly regarding avoiding side effects." ~~ [@tlhunter](https://twitter.com/tlhunter/status/262648059442376704 )

---

#### What is Functional?

  > "In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in lambda calculus, a formal system developed in the 1930s to investigate function definition, function application, and recursion. Many functional programming languages can be viewed as elaborations on the lambda calculus." ~~ [wikipedia](http://en.wikipedia.org/wiki/Functional_programming)

---

## That's Boring!

### And what...?

---

#### What does functional mean?

Here are the topics I found to be most talked about within the FP research that I performed for this talk.

  * Purity
  * Functions as Values
  * Higher Order Functions
  * Closure
  * Currying
  * Partial Application
  * Composition
  * Lazy Evaluation
  * Continuations
  * Continuation Passing Style (CPS)

---

#### Impurity

Relying on side effects leads to problems and brain-ache.

```javascript
var sum = 0;

function addToSum (a) {
  sum += a;
  return sum;
}

addToSum(1); // returns 1
addToSum(2); // returns 3
sum = 0;
addToSum(3); // returns 3 -> WTF!
```

This code is reliant on no other programmers changing the value of sum (intentionally or otherwise); it is also not testable over the life of execution because of that.

---

#### Purity

  * Referential transparency
  * Computation is the evaluation of mathematical functions
  * One input set will yield the same output every time

```javascript
function sum (a, b) {
  return a + b;
}

// ...

sum(1, 2); // returns 3, every time.
```

This is referentially transparent, meaning it can be logically reasoned about and the input dictates the output. Testing this will be straight-forward and reliable.

---

#### Functions as values

A function is a 'value' that can be assigned to an 'identifier'.
This declaration:

```javascript
function add (a, b) {
  return a + b;
}
```

... is very similar to this expression:

```javascript
var add = function (a, b) {
  return a + b;
}
```

The only difference being when they are initialized in the Javascript interpreter. The end result is the same; a function identified as 'add'.
  > "Function Expressions and Functional Programming are inseparable." ~~ [JavaScript JavaScript](http://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/)

---

#### Higher Order Functions

  * Takes a function as an argument (or)
  * Returns a function as a result

Examples: Array mutators, Event Handlers, etc.

##### Functions as arguments

```javascript
[1, 2, 3, 4, 5, 6]
  .map(function (num) {
    return num * 3.14159;
  });
```

---

#### Higher Order Functions (cont.)

Examples: bind, 'factories', etc.

**Functions as returned values**

```javascript
// add factory
function makeAdder (baseValue) {
  return function (x) {
    return baseValue + x;
  };
}

var add5 = makeAdder(5);

add5(10);   // returns 15
add5(1000); // returns 1005
add5(-4);   // returns 1
```

or...

```javascript
function add (a, b) {
  return a + b;
}

var add5 = add.bind(null, 5); // partial function application 'topic coming soon'
```

---

#### IIFE - Immediately Invoked Function Expression

And now for a little (Algebraic) Substitution. The two equations below are equal.

  * 3 * (1 + 2) = 9
  * 3 * (3) = 9

```javascript
var add = function (a, b) {return a + b;};

add(1, 2); // returns 3 every time

// Baby step, remember from math class, parens are just grouping
(add)(1, 2); // returns 3 every time

// Here is the IIFE
(function (a, b) {return a + b;})(1, 2); // returns 3 every time
```

---

#### Closure (lexical scoping)

Objects retain access to the context (scope) in which they were created.

```javascript
var outterObj = (function () {
  var hidden = 'I have a secret.';

  // return this object to outterObj
  // privileged methods inside have access to 'hidden' through closure
  return {
    get: function () {
      return hidden;
    }
    , set: function (newValue) {
      hidden = newValue;
    }
  };
}());

outterObj.get();  // returns 'I have a secret.'
outterObj.set('Javascript is awesome!');
outterObj.get();  // returns 'Javascript is awesome!'
outterObj.hidden; // undefined
```

---

#### Scope Chain

Let's take a little side step for a second. Behold the ASCII diagram.

```
program execution drills down through scopes building a scope chain
          ↓
+-------------------+
|    Global Scope   | <-- default location for variables
|-------------------|
| Namespace Context | <-- single global namespace object
|-------------------|
|    IIFE Context   | <-- variables instantiated with 'var' inside
|-------------------|
|        ...        |
|-------------------|
|  Binding Context  | <-- functions can have a binding context
|-------------------|
| Execution Context | <-- argument values and closure variables
+-------------------+
          ↑
variable resolution looks up the scope chain
finding the reference or hitting global and returning undefined
```

---

#### Currying
  > "...transforming a function that takes n multiple arguments [into] a chain of functions, each with a single argument..." ~~ [wikipedia](http://en.wikipedia.org/wiki/Currying)

This might take some explanation to fully grasp; it did for me anyway.

```javascript
function sumOfSix (a, b, c, d, e, f) {
  return a + b + c + d + e + f;
}

sumOfSix(1, 2, 3); // some argument values will be undefined

                   // curry is a fictitious function here
var sumOfSixCurried = curry(sumOfSix);
sumOfSixCurried(1);       // returns a new function expecting one argument
sumOfSixCurried(1)(2);    // returns a new function expecting one argument
sumOfSixCurried(1)(2)(3); // returns a new function expecting one argument
sumOfSixCurried(1)(2)(3)(4)(5)(6); // returns 21
```

---

#### Partial Application

Reducing the number of needed arguments by supplying values ahead of time.

```javascript
function add (a, b) {
  return a + b;
}

var add5 = add.bind(null, 5);

add5(10); // returns 15
add5(-4); // returns 1
```

The bind method on the Function prototype allows us to do two things: explicitly set the context a function will execute with - value of 'this' inside the function - and supply arguments that will be available when the function is called.

[Partial Application in JavaScript by Ben Alman](http://benalman.com/news/2012/09/partial-application-in-javascript/)

```javascript
// !WARNING! unsafe for actual use
function partial (fn) {
  var args = [].slice.call(arguments, 1);     // get all arguments after the first
  return function () {
    fn.apply(null, args.concat(arguments)); // add args to partially applied args
  }
}
```

---

#### Composition

A new function that, when called, will pass the output of one function call as the input of the next and so on through all functions in the composition.

```javascript
function fnA (_) { return _ + 2; }
function fnB (_) { return _ * 3; }
function fnC (_) { return _ - 5; }

var resultA = fnA(7);           // 9
var resultB = fnB(resultA);     // 27
var resultC = fnC(resultB);     // 22

// or

var result = fnC(fnB(fnA(7)));  // 22
```

with composition:

```javascript
var compositionABC = compose(fnA, fnB, fnC);
var result = compositionABC(7);             // 22

// ...

var map = [13, 17, 23].map(compositionABC); // [40, 52, 70]
```

Composition reduces the number of times the list is iterated over from once per function in the composition to just once. Benefits: reusable, passable, composable, testable, scalable etc.

---

#### Lazy evaluation

Known as Generators, Sequences, or Streams ([StreamJS](http://streamjs.org/)), these constructs only return values on-demand. Collections of infinite length are actually workable without enormous processing power or infinite system memory.

```javascript
// native Javascript array (not lazy)
var jsArray = [1,2,3,4,5,6,7,8,9];

jsArray.length;  // returns 9
```

Lazy evaluated structures will work quite a bit differently.

```javascript
// using Stream.js library
var simple = Stream.range(); // create a stream of natural numbers [1,2,3...∞]

simple.length(); // returns... umm, infinitely loops as it attempts to find the end

simple.take(10).length(); // returns 10
```

Checkout Stream and do some cool things. I would love to see it!

---

#### Continuations

Continuations are not possible in Javascript. [http://idea-log.blogspot.com/](http://idea-log.blogspot.com/2005/10/why-are-continuations-so-confusing-and.html)

Think of the old "goto" statements of yore but add in the fact that state of computation/execution is kept.

  > "[a reification of] an instance of a computational process at a given point in the process's execution" ~~ [http://eriwen.com/](http://eriwen.com/javascript/cps-tail-call-elimination/)

Javascript does not support Continuations natively; however, the Rhino environment does provide them as first-class objects.

  * Resume execution with pre-existing state

---

#### Continuation-Passing Style (CPS)

Commonly used as callbacks in Javascript land.

```javascript
doAJAX(
    'http://url.to.api'
  , JSON.stringify({name: 'Joshua'})
  , function succesHandler (data) {/*do cool stuff*/}
  , function failHandler  (error) {/*do cool stuff*/});
```

Possible stack overflow problems for deeply nested calls due to no tail optimization.

  > "No procedure is allowed to return to its caller ever..." ~~ [By example: Continuation-passing style in JavaScript](http://matt.might.net/articles/by-example-continuation-passing-style/)

---

#### Functional Elsewhere?

We can gain some of the benefits that Functional offers us by just working in that way.

  > "Programming in a functional style can also be accomplished in languages that aren't specifically designed for functional programming." ~~ [wikipedia](http://en.wikipedia.org/wiki/Functional_programming)

  * Avoid reliance on state transformations
  * Write functions side affect free
  * Prefer composition over inheritance

---

## Example Time!

---

## #FunctionalJS

### Go, now, and be functional

---

#### Further Learning

  * Point Free
  * Monads

---

#### Resources

  1. [Functional Programming - Wikipedia](http://en.wikipedia.org/wiki/Functional_programming)
  2. [Functional Programming For The Rest of Us](http://www.defmacro.org/ramblings/fp.html)
  3. [Pure, functional JavaScript](http://cjohansen.no/talks/2012/sdc-functional/#1)
  4. [Stream.js](http://streamjs.org/)
  5. [Functional Programming - igstan.ro](http://igstan.ro/files/functional-programming.pdf)
  6. [Function Declarations vs. Function Expressions](http://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/)
  7. [By example: Continuation-passing style in JavaScript](http://matt.might.net/articles/by-example-continuation-passing-style/)
  8. [Continuation-Passing Style](http://marijnhaverbeke.nl/cps/)
  9. [lz](https://github.com/goatslacker/lz)
  10. [http://idea-log.blogspot.com/](http://idea-log.blogspot.com/2005/10/why-are-continuations-so-confusing-and.html)
  11. [Overview of the four main programming paradigms](http://people.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigm-overview-section.html)

---

## Joshua T Kalis

### August 2012

license: MIT

branch_name: refs/heads/main

extension: md

gha_language: CSS

gha_license_id: MIT

license_type: permissive


text:
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- [Profile Information](https://wiki.vg/Mojang_API#Profile_Information) endpoint.
- [Change skin](https://wiki.vg/Mojang_API#Change_Skin) endpoint.
- [Upload skin](https://wiki.vg/Mojang_API#Upload_Skin) endpoint.

## [0.2.1] - 2020-06-10
### Added
- [Check if security questions are needed](https://wiki.vg/Mojang_API#Check_if_security_questions_are_needed) endpoint.
- [Get list of questions](https://wiki.vg/Mojang_API#Get_list_of_questions) endpoint.
- [Send back the answers](https://wiki.vg/Mojang_API#Send_back_the_answers) endpoint.
- [Statistics](https://wiki.vg/Mojang_API#Statistics) endpoint.
- Allow `ramsey/uuid` v4.
- Allow `guzzlehttp/guzzle` v7.

### Changed
- Changed the threshold value for [Playernames -> UUIDs](https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs) endpoint
  from `100` to `10`.

## [0.2.0] - 2019-05-07
### Added
- This CHANGELOG.md file.
- `\Ely\Mojang\Api::setClient()` method to override default HTTP client.
- [API Status](https://wiki.vg/Mojang_API#API_Status) endpoint.
- [UUID to Name history](https://wiki.vg/Mojang_API#UUID_-.3E_Name_history) endpoint.
- [Playernames -> UUIDs](https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs) endpoint.
- [Change Skin](https://wiki.vg/Mojang_API#Change_Skin) endpoint.
- [Reset Skin](https://wiki.vg/Mojang_API#Reset_Skin) endpoint.
- [Blocked Servers](https://wiki.vg/Mojang_API#Blocked_Servers) endpoint.
- [Refresh](https://wiki.vg/Authentication#Refresh) endpoint.
- [Signout](https://wiki.vg/Authentication#Signout) endpoint.
- [Invalidate](https://wiki.vg/Authentication#Invalidate) endpoint.

### Changed
- The constructor no longer has arguments.

### Fixed
- Change `static` to `self` in `\Ely\Mojang\Response\Properties\Factory` to allow its extending.
- Fix `validate` endpoint URL.

### Removed
- `\Ely\Mojang\Api::create()` static method. Use constructor instead.

## [0.1.0] - 2019-04-01
### Added
- Initial implementation

[Unreleased]: https://github.com/elyby/mojang-api/compare/0.2.1...HEAD
[0.2.1]: https://github.com/elyby/mojang-api/compare/0.2.0...0.2.1
[0.2.0]: https://github.com/elyby/mojang-api/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/elyby/mojang-api/releases/tag/0.1.0

repository: elyby/mojang-api

branch_name: refs/heads/master

gha_language: PHP

repo_name: elyby/mojang-api


text:
# Large Scale Resources

## Accessing PEARL

You will receive three files:
 - `tmpXXX` is the private key file for ssh if you are on a Mac or Linux machine.
 - `tmpXXX.ppk` is the private key file for ssh if you are on a Windows machine using Putty.
 - `passphrase.txt` is the password for your ssh private key which you will need to enter when prompted.

### On Windows

 - Download [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
 - Install PuTTY And PuTTYgen
 - [Follow these instructions on connecting to a server using a private key](https://devops.ionos.com/tutorials/use-ssh-keys-with-putty-on-windows/#connect-to-server-with-private-key)
     - The address you need to enter under session is<EMAIL_ADDRESS>(assuming `tmp100` is your private key name).
     - When importing the private key you'll need to open the `.ppk` file. e.g. `tmp100.ppk`
 - After you open the connection when you are prompted for the password, you will need to enter the phrase in the `passphrase.txt` text file.

### On Mac/Linux

Assuming your username is `tmp100` and that your key file is called `tmp100` you can use the following command to ssh into the PEARL system.

You'll need to change the permissions of the key to enable it to work correctly on unix. To change this you can simply run:

```bash
chmod 600 tmp100
```

Once you have changed permissions. You can ssh as normal:

```bash
ssh -i tmp100<EMAIL_ADDRESS>```
When you are prompted for the password, you will need to enter the phrase in the `passphrase.txt` text file.

Your temporary accounts will close automatically on Wednesday 29th of September. If you wish to apply for a permanent account you can sign up [here](https://www.turing.ac.uk/research/asg/pearl).

## Viewing Files
PEARL currently only provides a command line interface. To open and edit files in this tutorial you will need to use a command line text editor. Both `vim` and `nano` are installed on the system. A vim tutorial can be found [here](https://vim.fandom.com/wiki/Tutorial).

## Singularity

### Pulling Images
There are lots of places where you can get existing container images for Singularity.

 - [Singularity Container Library](https://cloud.sylabs.io/library)
 - [Docker hub](https://hub.docker.com/search?q=&type=image)
 - [NVIDIA GPU Cloud](https://ngc.nvidia.com/catalog/all)

Some examples of pulling images from each of these locations. We've already downloaded the images we need, so don't run these during the session as they can take a long time to download:

```bash
singularity pull library://library/default/centos

singularity pull docker://tensorflow/tensorflow:latest-gpu

singularity pull docker://nvcr.io/nvidia/tensorflow:20.07-tf1-py3
```

### Running Containers

There are three different commands that can be used to run singularity containers:

 - `exec`: execute an arbitrary command inside the container. In the example below we run python inside the container, import tensorflow, and print the tensorflow version.

```bash
singularity exec tensorflow_latest-gpu.sif python -c "import tensorflow as tf; print(tf.__version__)"
```
 - `shell`: run the container and start an interactive shell prompt.

```bash
singularity shell tensorflow_latest-gpu.sif
```

 - `run`: the command specified by the image's `%runscript`. More on this in the next section.
```bash
singularity run tensorflow_latest-gpu.sif
```

For example, if we want to run some python code using the tensorflow image we can run:

```bash
singularity exec tensorflow_latest-gpu.sif python train_fmnist.py
```

Which will start training a FMNIST classification model.

### Building Containers
There are many, many prepackaged images out there, but what do we do if we want to make our own image? We can use Singularity build scripts to specify how to create an new image. For information on build scripts can be found in the [Singularity docs](https://sylabs.io/guides/3.6/user-guide/quick_start.html#build-images-from-scratch).

In this simple example we create a very minimal image that has a couple of additional applications packaged into it.

 - `BootStrap:`: where to get the base image from. Common options are:
   - `library`: the singularity container repos
   - `docker`: a docker image from docker hub or elsewhere
   - `localimage`: a singularity image on your machine
 - `From:`: the name of the image to pull from the repository. In this case we're pulling a blank Ubuntu image from the singularity hub.
 - `%post`: this is the heart of the build script. This is where you write the commands to install additional packages ontop of the base image.
 - `%environment`: set any environment variables for the image.
 - `%runscript`: the command to run when the user starts the container with the `singularity run` command.

```
BootStrap: library
From: ubuntu:16.04

%post
    apt-get -y update
    apt-get -y install fortune cowsay lolcat

%environment
    export LC_ALL=C
    export PATH=/usr/games:$PATH

%runscript fortune | cowsay | lolcat
```

To build the image we use the `build` command. The first argument is the name of the output image file. The second argument is the build script definition file. The `--fakeroot` option is required to

```bash
singularity build --fakeroot lolcow.sif lolcow.def
```

Finally we can run the image we created:

```bash
singularity run lolcow.sif
```

## SLURM
SLURM is a job scheduling system. It can be used to schedule jobs on a shared resource such as PEARL. Jobs submitted to the queue will be run when resources (in our case available GPUs) become available.

We can interact with SLURM to find out the status of the SLURM job queues using the following commands:

```bash
#show all job queues
sinfo
#show all pending or running jobs
squeue
#show previously run jobs for user
sacct
#show pending/running jobs for user pearl008
squeue –u pearl008
```

We can run an interactive shell with the following command. This will allocate a single GPU resource on the PEARL system and provide a bash prompt. Note that the `--reservation=Diamond2020` is only required during the workshop.

```bash
srun --gres=gpu:1 --reservation=scimlWorkshop --pty bash
```

An example of a very basic batch script. Each of the `#SBATCH` lines set an option in SLURM. Again, as above, the `--reservation=scimlWorkshop` is only required during the workshop. Each of the options are as follows:

 - `gres`: set the generic resources for this job. Here we're specifying we want one GPU.
 - `job-name`: set the display name of the job. This will be visible in the public queue.
 - `time`: set the estimated maximum time of the job. Jobs that run beyond this value will be killed automatically.
 - `mem`: set the required CPU RAM for the job. On the DGX system you have up to 1.5TB of shared RAM available. But you will only have 16GB on GPU RAM per GPU.

```bash
#!/bin/bash
#SBATCH --reservation=scimlWorkshop
#SBATCH --gres=gpu:1
#SBATCH --job-name ="ML Job"
#SBATCH --time=0-00:10:00
#SBATCH --mem=1GB

nvidia-smi
```
We can submit our job to the queue with the following command:

```bash
sbatch simple-job.job
```

You can run any arbitrary bash command in your job script. For example, we can run singularity containers. Remember if we want the GPU to be accessible we must add the `--nv` flag to the singularity command!

```bash
#!/bin/bash
#SBATCH --reservation=scimlWorkshop
#SBATCH --gres=gpu:1
singularity exec --nv tensorflow_latest-gpu.sif nvidia-smi
```

We can then submit this job with the following command:

```bash
sbatch simple-singularity-job.job
```

## Exercises

- Exercise 1:
  - There is a script called `train_fmnist.py`. This trains the same dense model from the first lesson on neural networks on the fashion MNIST dataset.
  - Write a batch script to run this with the `tensorflow_latest-gpu.sif` container.
  - Submit the job and check the progress

- Exercise 2:
  - Create a script for the autoencoder example from the autoencoder practical
  - Write a batch script to run this with the `tensorflow_latest-gpu.sif` container.
  - Submit the job and check it runs


text:
---
title: Connect Apps to Facebook
connection: Facebook
index: 13
image: /media/connections/facebook.png
seo_alias: facebook
description: Learn how to add login functionality to your app with Facebook. You will need to generate keys, copy these into your Auth0 settings, and enable the connection.
toc: true
public: true
topics:
  - authentication
  - connections
  - social
  - facebook
contentType: how-to
useCase:
  - add-login
  - customize-connections
  - add-idp
---
<%= include('../../../snippets/social/facebook/0') %>
<%= include('../../../snippets/social/facebook/1') %>
<%= include('../../../snippets/social/facebook/2') %>
<%= include('../../../snippets/social/facebook/3') %>
<%= include('../../../snippets/social/facebook/4') %>
<%= include('../../../snippets/social/facebook/5') %>
<%= include('../../../snippets/social/facebook/6') %>
<%= include('../../../snippets/social/facebook/7') %>
<%= include('../_quickstart-links.md') %>

gha_language: JavaScript


text:
# Jenkins OpenStack Deployment Plugin

The OpenStack Deployment Plugin enables packaging multi-rpm products, and deploying these products on an Openstack environment

The plugin assumes the following:
  - Product components are packaged as RPMs
  - Product artifacts are uploaded to Nexus
  - Artifacts which are not in Nexus can be retrieved via http
  - Heat templates exist in a git repository
  - Deployment scripts exist in either a git repository or are attached as a tar.gz file to each artifact in Nexus

The Heat repository is expected to have this structure:
```sh
`-- <product name>
    |-- <product name>.env.yaml
    |-- <product name>.yaml
    `-- <product name>.yaml.dependencies
        |-- embedded yaml.yaml
        |-- some bash.sh
        |-- some other bash.sh
        `-- some other bash.sh
```
For example - this is the structure of the demo heat template:
```
`-- demo
    |-- demo.env.yaml
    |-- demo.yaml
    `-- demo.yaml.dependencies
        |-- __stand_alone_external_instance.yaml
        |-- check_installation.sh
        |-- component_installation.sh
        |-- general_user_data.sh
        `-- vci-utility-scripts
```
The heat stack can be found in [Sample HEAT template](https://github.com/naamab/jenkins-openstack-deployment-plugin/tree/master/Sample%20HEAT%20template/demo)

Prior to adding create/deploy product/profile, you should set your Nexus server credentials in the Manage Jenkins / configure System page:
![Jenkins general settings](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/general_settings.jpg)

To package your product:
1. Create a 'Freestyle' job

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/create_1.jpg)

2. Add a 'Create Product' step:

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/create_2.jpg)

3.  Select group ID, artifact ID, and set git repository paths for your heat templates and deployment scripts
Heat git repo is mandatory.  Scripts and puppets repos are optional.

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/create_3.jpg)

4. Add dependent products, artifacts and external dependencies.
External dependencies are resources which do not exist in Nexus.
They should be accessible via http.

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/create_5.jpg)

Once you build your product, 3 artifacts are uploaded to Nexus:
1. POM file, describing your dependencies
2. TAR file containing your heat templates, deployment scripts and external dependencies
3. RPM containing your Puppet scripts (built from the Puppet git repo and from the puppet scripts tar uploaded with each component.

Now you can define a 'deploy' job to deploy the product you packaged in an OpenStack environment
1. Create a free-style job

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/deploy_1.jpg)

2. Mark job as 'parameterized' and define a string parameter named 'version'

3.  Add a 'Deploy Product' built step

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/deploy_2.jpg)

4. Set product parameters and OpenStack credentials

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/deploy_3.jpg)

5. You may define product-specific parameters, and assign a value to common parameters

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/deploy_5.jpg)

6. A yum repository is required.
The machine have a link pointing /var/www/html to /ci-repo.
Jenkins will copy the artifacts to this yum repo. In order to accomplish this you will need to provide the proper SSH private key.

![enter image description here](https://raw.githubusercontent.com/foundation-runtime/jenkins-openstack-deployment-plugin/master/resources/images/deploy_9.jpg)


text:
# Platforms::Yammer

This is an easy-to-use Ruby library which takes all the hard work out of writing a Yammer App.

Platforms::Yammer supports all documented API endpoints, and has the flexibility of being able to call new, updated, or undocumented API endpoints too.

## Usage

This gem consists of two main parts. You need to have already [created an App](https://developer.yammer.com/docs/getting-started) in Yammer before using this gem.

### 1. Authentication

Assuming the "Redirect URI" for your App is `https://www.myapp.com/auth/yammer/callback`, in your routes file set that route to a controller of your choice. `SessionsController` is used in the examples below..

```ruby
# config/routes.rb

Rails.application.routes.draw do
  # ...
  match '/auth/:provider/callback', to: 'sessions#callback', via: [:get, :post]
  # ...
end
```

In the Sessions controller, include the `Platforms::Yammer::Authentication` module and call `save_identity` in the `callback` method:

```ruby
# app/controllers/sessions_controller

class SessionsController < ApplicationController
  include Platforms::Yammer::Authentication

  before_action :set_token

  def callback
    # ...
    save_identity
    # ...
  end

end
```

This will give you instance variables `@platforms_user`, `@platforms_network`, `@token`, and `@switch_network_ids`, giving you details of the Yammer user.
Some of this information will be useful to store in a [session](https://guides.rubyonrails.org/security.html#session-storage).
See {Platforms::Yammer::Authentication#save_identity} for more details.

This callback method also has access to more detailed information about the logged-in user through `request.env[omniauth.auth']`. More information about the data that is stored in that variable can be found in the OmniAuth [Auth Hash Schema](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema) description.

Switching between Yammer Networks is achieved through {Platforms::Yammer::Authentication#switch_identity}, which is treated as a regular API request.

### 2. API Requests

Use the `@token`, found during [Authentication](#authentication), to create a new {Platforms::Yammer::Client}. That client can then be used to make API requests.

```ruby
client = Platforms::Yammer::Client.new(@token)
messages = client.messages.get
```

More detail on the configuration options for the {Platforms::Yammer::Client} can be found in the class documentation, including how to change the handling of HTTP errors.

Extra request parameters and headers can generally be passed in the subsequent parameters to a method:

```ruby
messages = client.messages.get { :older_than => 123 }, { :custom => :header }
```

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'platforms-yammer'
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install platforms-yammer
```

Once the gem is installed, from your Rails directory you can run the following generator to complete the installation:

```bash
$ rails generate platforms:yammer:install
```

This will:

* Complete the installation of the [Platforms::Core](https://github.com/collabital/platforms-core) gem; and
* Add a basic initializer to `config/initializers/platforms_yammer.rb`.

## Configuration

REST-based APIs require authentication to get started. Please refer to the Yammer documentation for how to configure an integration.

### Configuring the Keys

Edit the initializer to add the credentials of your Yammer integration:

```ruby
# config/initializers/platforms_yammer.rb

```

### Starting a New App

Your application needs to have at least `Network` and `User` models. These can be created by calling the generator:

```bash
$ rails generate platforms:core:network foo some_info:string
$ rails generate platforms:core:user bar user more_info:string
$ rake db:migrate
```

Typically these would actually be called "Network" and "User", but here we have called them "Foo" and "Bar".

For more detailed instructions, refer to the documentation for configuring [Platforms::Core](https://github.com/collabital/platforms-core#configuration).

### Adding to an Existing App

If you already have `Network` and `User` models (which let's assume are called "Foo" and "Bar" respectively), you can configure them for Platforms::Core by using the generator with the `--existing-model` flag:

```bash
$ rails generate platforms:core:network foo --existing-model
$ rails generate platforms:core:user bar --existing-model
$ rake db:migrate
```

For more detailed instructions, refer to the documentation for configuring [Platforms::Core](https://github.com/collabital/platforms-core#configuration).

## Documentation

You can generate the documentation by running

```bash
$ rake yard
```

If not everything is documented, check this with:
```bash
$ yard stats --list-undoc
```

## Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md).

## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

repository: collabital/platforms-yammer

repo_name: collabital/platforms-yammer


text:
## Role Identification for League of Legends

### Setup

Install from GitHub using pip:  `pip install git+https://github.com/meraki-analytics/role-identification.git`

This code uses [Cassiopeia](https://github.com/meraki-analytics/cassiopeia), which will also be installed if it isn't already.

### Example

    # Pull the data required to make role assignments
    champion_roles = get_data()

    # Pull a summoner's most recent match using Cassiopeia
    summoner = Summoner(name="Kalturi", region="NA")
    match = summoner.match_history[0]

    # Use this role identification code to get the blue team's roles
    roles = get_team_roles(match.blue_team, champion_roles)
    print({role.name: champion.name for role, champion in roles.items()})

    # Output:
    # {'top': 'Pantheon', 'jungle': 'Nunu', 'mid': 'Akali', 'adc': 'Caitlyn', 'support': 'Morgana'}

See the `examples` directory for more.

### Work-In-Progress

This code is a work in progress. It currently uses aggregated data from champion.gg to identify which champions play what roles. It then does a simple brute force calculation to identify the most likely lane assignment of each champion.

In the future, we will replace champion.gg's data and the brute force algorithm with a robust machine learning algorithm that takes into account the champion, summoner spells, and runes.

repository: PatrickLTran/role-identification

repo_name: PatrickLTran/role-identification


text:
# ruby-prehistory

[ruby/ruby](https://github.com/ruby/ruby) contains history of Ruby
development since 1998. This is the very first commit in ruby/ruby.

```
commit 392296c12de9d7f9be03a8205250ba0844cb9d38
Author: (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date:   Fri Jan 16 12:13:05 1998 +0000

    New repository initialized by cvs2svn.

    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
```

But actually this is not the birth of Ruby, as the word "New repository" indicates.
You can get the old archives here:

http://ftp.ruby-lang.org/pub/ruby/

This tool downloads and converts them into a git repository, so that you can
trace the diffs between very old ruby, 0.xx for example.

## Usage

```
$ mkdir old_rubies
$ ruby make.rb old_rubies
```

This will get the archives, create git repo, unpack each and add the content to the repo.

## License

MIT

repository: yhara/ruby-prehistory

gha_language: Ruby

repo_name: yhara/ruby-prehistory


text:
# Modulation - Explicit Dependency Management for Ruby

[![Gem Version](https://badge.fury.io/rb/modulation.svg)](http://rubygems.org/gems/modulation)
[![Modulation Test](https://github.com/digital-fabric/modulation/workflows/Tests/badge.svg)](https://github.com/digital-fabric/modulation/actions?query=workflow%3ATests)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/digital-fabric/modulation/blob/master/LICENSE)

> Modulation | mɒdjʊˈleɪʃ(ə)n | *Music* -  a change from one key to another in a
> piece of music.

[INSTALL](#installing-modulation) |
[GUIDE](#organizing-your-code-with-modulation) |
[API](#api-reference) |
[EXAMPLES](examples) |
[RDOC](https://www.rubydoc.info/gems/modulation/)

Modulation provides an alternative way of organizing your Ruby code. Modulation
lets you explicitly import and export declarations in order to better control
dependencies in your codebase. Modulation helps you refrain from littering
the global namespace with a myriad modules, or complex multi-level nested
module hierarchies.

Using Modulation, you will always be able to tell where a class or module comes
from, and you'll have full control over which parts of a module's code you wish
to expose to the outside world. Modulation can also help you write Ruby code in
a functional style, minimizing boilerplate code.

> Note: Modulation is not a replacement for RubyGems. Rather, Modulation is
> intended for managing dependencies between source files *inside* your Ruby
> applications. Though it does support loading gems that were written using
> Modulation, it is not intended as a comprehensive solution for using
> third-party libraries.

## Features

- **[Complete isolation of each module](#organizing-your-code-with-modulation)**
  prevents literring of the global namespace.
- **Explicit [exporting](#exporting-declarations) and
  [importing](#importing-declarations) of methods and constants** lets you
  control the public interface for each module, as well as keep track of all
  dependencies in your code.
- **[Tagged paths](#using-tags-to-designate-common-subdirectories)** simplify
  the management of dependencies in large applications.
- **[Lazy Loading](#lazy-loading)** improves start up time and memory
  consumption.
- **[Hot module reloading](#reloading-modules)** streamlines your development
  process.
- **[Module mocking](#mocking-modules)** facilitates testing.
- **[Dependency introspection](#dependency-introspection)** lets you introspect
  your dependencies at runtime.
- **[Application packing](#packing-applications-with-modulation)** lets you
  bundle your code in a single, optionally obfuscated file (WIP).

## Rationale

You're probably asking yourself "what the ****?" , but when your Ruby app grows
and is split into multiple files loaded using `#require`, you'll soon hit some
issues:

- Once a file is `#require`d, any class, module or constant in it is available
  to any other file in your codebase. All "globals" (classes, modules,
  constants) are loaded, well, globally, in a single namespace. Name conflicts
  are easy in Ruby.
- To avoid class name conflicts, classes need to be nested under a single
  hierarchical tree, sometime reaching 4 levels or more. Just look at Rails.
- Since a `#require`d class or module can be loaded in any file and then made
  available to all files, it's easy to lose track of where it was loaded, and
  where it is used.
- There's no easy way to hide implementation-specific classes or methods. Yes,
  there's `#private`, `#private_constant` etc, but by default everything is
  `#public`!
- Extracting functionality is harder when modules are namespaced and
  dependencies are implicit.
- Writing reusable functional code requires wrapping it in modules using
  `class << self`, `def self.foo ...`, `extend self` or `include Singleton`
  (the pain of implementing singletons in Ruby has been
  [discussed](https://practicingruby.com/articles/ruby-and-the-singleton-pattern-dont-get-along)
  [before](https://ieftimov.com/singleton-pattern).)

> There's a [recent discussion](https://bugs.ruby-lang.org/issues/14982) on the
> Ruby bug tracker regarding possible solutions to the problem of top-level
> name collision. Hopefully, the present gem could contribute to an eventual
> "official" API.

Personally, I have found that managing dependencies with `#require` in large
codebases is... not as elegant or painfree as I would expect from a
first-class development environment. I also wanted to have a better solution
for writing in a functional style.

So I came up with Modulation, a small gem that takes a different approach to
organizing Ruby code: any so-called global declarations are hidden unless
explicitly exported, and the global namespace remains clutter-free. All
dependencies between source files are explicit, visible, and easy to understand.

## Installing Modulation

You can install the Modulation using `gem install`, or add it to your `Gemfile`:

```ruby
gem 'modulation'
```

## Organizing your code with Modulation

Modulation builds on the idea of a Ruby `Module` as a
["collection of methods and constants"](https://ruby-doc.org/core-2.6.5/Module.html).
Using modulation, each Ruby source file becomes a module. Modules usually
export method and constant declarations (usually an API for a specific,
well-defined functionality) to be shared with other modules. Modules can also
import declarations from other modules. Anything not exported remains hidden
inside the module and normally cannot be accessed from the outside.

Each source file is evaluated in the context of a newly-created `Module`
instance, with some additional methods for introspection and miscellaneous
operations such as [hot reloading](#reloading-modules).

Modulation provides alternative APIs for loading modules. Instead of using
`require` and `require_relative`, we use `import`, `import_map` etc, discussed
in detail in the [API reference](#api-reference).

## Basic Usage

### Exporting declarations

Any class, module or constant be exported using `#export`:

```ruby
export :User, :Session

class User
...
end

class Session
...
end
```

A module may also expose a set of methods without using `class << self`, for
example when writing in a functional style:

*seq.rb*
```ruby
export :fib, :luc

def fib(n)
  (0..1).include?(n) ? n : (fib(n - 1) + fib(n - 2))
end

def luc(n)
  (0..1).include?(n) ? (2 - n) : (luc(n - 1) + luc(n - 2))
end
```
*app.rb*
```ruby
require 'modulation'
Seq = import('./seq')
puts Seq.fib(10)
```

Another way to export methods and constants is by passing a hash to `#export`:

*module.rb*
```ruby
export(
  foo: :bar,
  baz: -> { 'hello' },
  MY_CONST: 42
)

def bar
  :baz
end
```

*app.rb*
```ruby
m = import('./module')
m.foo #=> :baz
m.baz #=> 'hello'
m::MY_CONST #=> 42
```

Any capitalized key will be interpreted as a const, otherwise it will be defined
as a method. If the value is a symbol, Modulation will look for the
corresponding method or const definition and will treat the key as an alias.

The `export` method can be called multiple times. Its behavior is additive:

```ruby
# this:
export :foo, :bar

# is the same as this:
export :foo
export :bar
```

### Importing declarations

Declarations from another module can be imported using `#import`:

```ruby
require 'modulation'
Models = import('./models')
...

user = Models::User.new(...)

...
```

Alternatively, a module interested in a single declaration from another module
can use the following technique:

```ruby
require 'modulation'
User = import('./models')::User
...

user = User.new(...)
```

### A word about paths

Paths given to `import` are always considered relative to the importing file,
unless they are absolute (e.g. `/home/dave/repo/my_app`), specify a
[tag](#using-tags-to-designate-common-subdirectories) or reference a
[gem](#importing-gems-using-modulation). This is true for all Modulation APIs
that accept path arguments.

## Advanced Usage

### Using tags to designate common subdirectories

Normally, module paths are always relative to the file calling the `#import`
method, just like `#require_relative`. This can become a problem once you start
moving your source files around. In addition, in applications where your source
files are arranged in multiple directories, it can quickly become tedious to do
stuff like `Post = import('../models/post')`.

Modulation provides an alternative to relative paths in the form of tagged
sources. A tagged source is simply a path associated with a label. For example,
an application may tag `lib/models` simply as `@models`. Once tags are defined,
they can be used when importing files, e.g. `import('@models/post')`.

To define tags, use `Modulation.add_tags`:

```ruby
Modulation.add_tags(
  models: '../lib/models',
  views:  '../lib/views'
)

...

User = import '@models/user'
```

### Importing all source files in a directory

To load all source files in a directory you can use `#import_all`:

```ruby
import_all('./ext')
```

Groups of modules providing a uniform interface can also be loaded using
`#import_map`:

```ruby
API = import_map('./math_api') #=> hash mapping filenames to modules
API.keys #=> ['add', 'mul', 'sub', 'div']
API['add'].(2, 2) #=> 4
```

The `#import_map` takes an optional block to transform hash keys:

```ruby
API = import_map('./math_api') { |name, mod| name.to_sym }
API.keys #=> [:add, :mul, :sub, :div]
API[:add].(2, 2) #=> 4
```

### Importing methods into classes and objects

Modulation provides the `#extend_from` and `#include_from` methods to include
imported methods in classes and objects:

```ruby
module Sequences
  extend_from('./seq.rb')
end

Sequences.fib(5)

# extend integers
require 'modulation'
class Integer
  include_from('./seq.rb')

  def seq(kind)
    send(kind, self)
  end
end

5.seq(:fib)
```

The `#include_from` method accepts an optional list of symbols to import:

```ruby
class Integer
  include_from './seq.rb', :fib
end

5.fib
```

### Default exports

A module may wish to expose just a single class or constant, in which case it
can use `#export_default`:

*user.rb*
```ruby
export_default :User

class User
  ...
end
```

*app.rb*
```ruby
require 'modulation'
User = import('./user')
User.new(...)
```

The default exported value can also be defined directly thus:

*config.rb*
```ruby
export_default(
  host: 'localhost',
  port: 1234,
  ...
)
```

*app.rb*
```ruby
require 'modulation'
config = import('./config')
db.connect(config[:host], config[:port])
```

### Circular dependencies

Circular dependencies, while not the best practice for organizing a code base,
are sometimes useful. Modulation supports circular dependencies, with the
exception of modules with default exports.

### Accessing a module's root namespace from nested modules within itself

The special constant `MODULE` allows you to access the containing module from
nested modules or classes. This lets you call methods defined in the module's
root namespace, or otherwise introspect the module:

```ruby
export :AsyncServer

# Await a promise-like callable
def await
  calling_fiber = Fiber.current
  p = ->(v = nil) {calling_fiber.resume v}
  yield p
  Fiber.yield
end

class AsyncServer < SomeTCPServer
  def async_read
    MODULE.await {|p| on_read {|data| p.(data)}}
  end
end
```

### Accessing the global namespace

If you need to access the global namespace inside a module just prefix the
class name with double colons:

```ruby
class ::GlobalClass
  ...
end

::ENV = { ... }

what_is = ::THE_MEANING_OF_LIFE
```

### Programmatic module creation

In addition to loading modules from files, modules can be created dynamically at
runtime using `Modulation.create`. You can create modules by supplying a hash
prototype, a string or a block:

```ruby
# Using a hash prototype
m = Modulation.create(
  add: -> x, y { x + y },
  mul: -> x, y { x * y }
)
m.add(2, 3)
m.mul(2, 3)

# Using a string
m = Modulation.create <<~RUBY
export :foo

def foo
  :bar
end
RUBY

m.foo

# Using a block
m = Modulation.create do { |mod|
  export :foo

  def foo
    :bar
  end

  class mod::BAZ
    ...
  end
}

m.foo
```

The creation of a objects using a hash prototype is also available as a separate
gem called [eg](https://github.com/digital-fabric/eg/).

### Unit testing modules

Methods and constants that are not exported can be tested using the `#__expose!`
method. Thus you can keep implementation details hidden, while being able to
easily test them:

*parser.rb*
```ruby
export :parse

def parse(inp)
  split(inp).map(&:to_sym)
end

# private method
def split(inp)
  inp.split(',').map(&:strip)
end
```

*test_seq.rb*
```ruby
require 'modulation'
require 'minitest/autorun'

Parser = import('../lib/parser').__expose!

class FibTest < Minitest::Test
  def test_that_split_trims_split_parts
    assert_equal(%w[abc def ghi], Parser.split(' abc ,def , ghi  '))
  end
end
```

### Mocking modules

Modules loaded by Modulation can be easily mocked when running tests or specs,
using `Modulation.mock`:

```ruby
require 'minitest/autorun'
require 'modulation'

module MockStorage
  extend self

  def get_user(user_id)
    {
      user_id: user_id,
      name: 'John Doe',
      email<EMAIL_ADDRESS>    }
  end
end

class UserControllerTest < Minitest::Test
  def test_user_storage
    Modulation.mock('../lib/storage', MockStorage) do
      controller = UserController.new
      ...
    end
  end
end
```

`Modulation.mock` accepts a module path and a receiver, and the module stays
mocked within the given block.

### Lazy Loading

Modulation allows the use of lazy-loaded modules - loading of modules only once
they're needed by the application, in similar fashion to `Module#auto_load`. To
lazy load modules use the `#auto_import` method, which takes a constant name and
a path:

```ruby
export :foo

auto_import :BAR, './bar'

def foo
  # the bar module will only be loaded once this method is called
  MODULE::BAR
end
```

> Lazy-loaded constants must always be qualified. When referring to a
> lazy-loaded constant from the module's top namespace, use the `MODULE`
> namespace, as shown above.

The `#auto_import` method can also take a hash mapping constant names to paths.
This is especially useful when multiple concerns are grouped under a single
namespace:

```ruby
export_default :SuperNet

module SuperNet
  auto_import(
    HTTP1:      './http1',
    HTTP2:      './http2',
    WebSockets: './websockets'
  )
end

SuperNet::HTTP1 #=> loads the http1 module
```

### Reloading modules

Modules can be reloaded at run-time for easy hot code reloading:

```ruby
require 'modulation'
SQL = import('./sql')
...
SQL.__reload!
```

Another way to reload modules is using `Modulation.reload`, which accepts a
module or a filename:

```ruby
require 'filewatcher'

FileWatcher.new(['lib']).watch do |fn, event|
  if(event == :changed)
    Modulation.reload(fn)
  end
end
```

> When a module is reloaded, its entire content - constants and methods - will
> be replaced. That means that any code using that module could continue to use
> it without even being aware it was reloaded, providing its API has not
> changed.

Reloading of modules with default exports is also possible. Modulation will
extend the exported value with a `#__reload!` method. The value will need to be
reassigned:

```ruby
require 'modulation'
settings = import('settings')
...
settings = settings.__reload!
```

Please note that Modulation does not include a directory watcher that
automatically reloads changed modules. This is due to multiple considerations
that include the chosen threading model, or the reactor engine in use, or even
the chosen solution for watching files (whether it's an external gem or an
internal tool).

It is, however, quite trivial to watch files using
[`directory_watcher`](https://rubygems.org/gems/directory_watcher/):

```ruby
require 'directory_watcher'

dw = DirectoryWatcher.new 'lib', glob: '**/*.rb', interval: 2, pre_load: true
dw.add_observer do |*events|
  events.each do |e|
    next unless e.type == :modified

    Modulation.reload e.path
  end
end

dw.start
```

### Retaining state between reloads

Before a module is reloaded, all of its methods and constants are removed. In
some cases, a module might need to retain state across reloads. You can do this
by simply using instance variables:

```ruby
export :value, :inc

@counter ||= 0

def value
  @counter
end

def incr
  @counter += 1
end
```

Care must be taken not to reassign values outside of methods, as this will
overwrite any value retained in the instance variable. To assign initial values,
use the `||=` operator as in the example above. See also the
[reload example](examples/reload).

### Dependency introspection

Modulation allows runtime introspection of dependencies between modules. You can
interrogate a module's dependencies (i.e. the modules it imports) by calling
`#__depedencies`:

*m1.rb*
```ruby
import ('./m2')
```

*app.rb*
```ruby
m1 = import('./m1')
m1.__depedencies #=> [<Module m2>]
```

You can also iterate over a module's entire dependency tree by using
`#__traverse_dependencies`:

```ruby
m1 = import('./m1')
m1.__traverse_dependencies { |mod| ... }
```

To introspect reverse dependencies (modules *using* a particular module), use
`#__dependent_modules`:

```ruby
m1 = import('./m1')
m1.__depedencies #=> [<Module m2>]
m1.__dependencies.first.__dependent_modules #=> [<Module m1>]
```

## Running Modulation-based applications

Modulation provides a binary script for running Modulation-based applications.
`mdl` is a wrapper around Ruby that loads your application's main file as a
module, and then runs your application's entry point method. Let's look at a
sample application:

*app.rb*
```ruby
def greet(name)
  puts "Hello, #{name}!"
end

def main
  print "Enter your name: "
  name = gets
  greet(name)
end
```

To run this application, execute `mdl app.rb`, or `mdl run app.rb`. `mdl` will
automatically require the `modulation` gem and call the application's entry
point, `#main`.

## Packing applications with Modulation

> *Note*: application packing is at the present time an experimental feature.
> There might be security concerns for packaging your app, such as leaking
> filenames from the developer's machine.

Modulation can also be used to package your entire application into a single
portable file that can be copied to another machine and run as is. To package
your app, use `mdl pack`. This command will perform a dynamic analysis of all
the app's dependencies and will put them together into a single Ruby file.

For more information have a look at the [app](examples/app) example.

## Writing gems using Modulation

Modulation can be used to write gems, providing fine-grained control over your
gem's public APIs and letting you hide any implementation details. In order to
allow loading a gem using either `#require` or `#import`, code your gem's main
file normally, but add  `require 'modulation/gem'` at the top, and export your
gem's main namespace as a default export, e.g.:

```ruby
require 'modulation/gem'

export_default :MyGem

module MyGem
  ...
  MyClass = import('my_gem/my_class')
  ...
end
```

## Importing gems using Modulation

Gems written using modulation can also be loaded using `#import`. If modulation
does not find the module specified by the given relative path, it will attempt
to load a gem by the same name. It is also possible to load specific files
inside modules by specifying a sub-path:

```ruby
require 'modulation'
MyFeature = import 'my_gem/my_feature'
```

> **Note**: Since there's not much of a point in `#import`ing gems that do not
> use Modulation to export symbols, Modulation will refuse to import any gem
> that does not depend on Modulation.

## Writing modules that patch external classes or modules

It is generally recommended you refrain from causing side effects or patching
external code in your modules. When you do have to patch external classes or
modules (i.e. core, stdlib, or some third-party code) in your module, it's
useful to remember that any module may be eventually reloaded by the application
code. This means that any patching done during the loading of your module must
be [idempotent](https://en.wikipedia.org/wiki/Idempotence), i.e. have the same
effect when performed multiple times. Take for example the following module
code:

```ruby
module ::Kernel
  # aliasing #sleep more than once will break your code
  alias_method :orig_sleep, :sleep

  def sleep(duration)
    STDERR.puts "Going to sleep..."
    orig_sleep(duration)
    STDERR.puts "Woke up!"
  end
end
```

Running the above code more than once would cause an infinite loop when calling
`Kernel#sleep`. In order to prevent this situation, modulation provides the
`Module#alias_method_once` method, which prevents aliasing the original method
more than once:

```ruby
module ::Kernel
  # alias_method_once is idempotent
  alias_method_once :orig_sleep, :sleep

  def sleep(duration)
    STDERR.puts "Going to sleep..."
    orig_sleep(duration)
    STDERR.puts "Woke up!"
  end
end
```

## Coding style recommendations

* Import modules into constants, not variables:

  ```ruby
  Settings = import('./settings')
  ```

* Place your exports at the top of your module, followed by `#require`s,
  followed by `#import`s:

  ```ruby
  export :foo, :bar, :baz

  require 'json'

  Core = import('./core')

  ...
  ```

## API Reference

### Kernel

#### `Kernel#auto_import_map(path, options = {})`

Returns a hash mapping keys to corresponding module files inside the given
directory path. Modules are loaded automatically upon accessing hash keys.

#### `Kernel#import(path)`

Returns a loaded module identified by the given path. The path can contain
[tags](#using-tags-to-designate-common-subdirectories)

#### `Kernel#import_all(path)`

#### `Kernel#import_map(path, options = {})`

### Module

#### `Module#__module_info`

Returns a hash containing information about the module. This currently includes
the following entries:

location|Absolute module file path
exported_symbols|Array containing all symbols exported by the module

### `Module#__reload!`

#### `Module#alias_method_once(new_name, old_name)`

#### `Module#auto_import(sym, path)`

#### `Module#export(*symbols)`

#### `Module#export_default(value)`

#### `Module#export_from_receiver(receiver)`

#### `Module#extend_from(path)`

#### `Module#include_from(path, *symbols)`

#### `Module::MODULE`

### Modulation

#### `Modulation.full_backtrace!`

#### `Modulation.reload`

## Why you should not use Modulation

- Modulation is not production-ready.
- Modulation is not thread-safe.
- Modulation doesn't play well with rdoc/yard.
- Modulation (probably) doesn't play well with `Marshal`.
- Modulation (probably) doesn't play well with code-analysis tools.

repository: digital-fabric/modulation

repo_name: digital-fabric/modulation


text:
# brainfuck-py

[![Run on Repl.it](https://replit.com/badge/github/itsrainingmani/brainfuck-py)](https://replit.com/new/github/itsrainingmani/brainfuck-py)

Simple brainfuck interpreter written in Python.

## What is Brainfuck

From [Wikipedia](https://en.wikipedia.org/wiki/Brainfuck)

```quote
Brainfuck is an esoteric programming language created in 1993 by Urban Müller.

Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer.
While it is fully Turing complete, it is not intended for practical use, but to challenge and amuse programmers.
Brainfuck requires one to break commands into microscopic steps.

The language's name is a reference to the slang term brainfuck,
which refers to things so complicated or unusual that they exceed the limits of one's understanding,
as it was not meant or made for designing actual software but to challenge the boundaries of computer programming.
```

## Usage

To evaluate a brainfuck code file with extension _.b_ , run the following command in your shell

```shell
poetry run interpret <filename>
```

To use the built-in Brainfuck REPL, run the following command

```shell
$ poetry run repl

Welcome to the Brainfuck REPL
Here you can enter simple Brainfuck code and see the output immediately
>
```

## Instruction List

There are eight brainfuck instructions.

| Instruction | Description                                                                                |
|-------------|--------------------------------------------------------------------------------------------------------|
| >           | Increment the data pointer by one (to point to the next cell to the right).                            |
| <           | Decrement the data pointer by one (to point to the next cell to the left).                             |
| +           | Increment the byte at the data pointer by one.                                                         |
| -           | Decrement the byte at the data pointer by one.                                                         |
| .           | Output the byte at the data pointer.                                                                   |
| ,           | Accept one byte of input, storing its value in the byte at the data pointer.                           |
| [           | If the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command. |
| ]           | If the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command. |

## References

The following links were highly useful in developing this interpreter

* [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)
* [Brainfuck Esolang wiki](https://esolangs.org/wiki/brainfuck)
* [Some Brainfuck fluff by Daniel Cristofani](http://www.hevanet.com/cristofd/brainfuck/)

repository: itsrainingmani/brainfuck-py

repo_name: itsrainingmani/brainfuck-py


text:
# Bot pull request rules

Bot pull request should contain new bot only.
In particular, the following set of rules exist:

* Pull request MUST NOT change any code outside `TicTacToeGame.Players`
* For bot of name EXAMPLE several objects MUST be added:
    * Folder `TicTacToeGame.Players\EXAMPLE` containing all bot code
    * Class `TicTacToeGame.Players.EXAMPLE.EXAMPLEBot` which MUST inherit `TicTacToeGame.Players.BotPlayer`
    * Enum element `TicTacToeGame.Players.Enums.BotKind.EXAMPLE`
    * `case` in `TicTacToeGame.Players.BotFactory` which simply returns class instanse
* Namespaces MUST be aligned to folders
* No code changes in `TicTacToeGame.Players` except described above are allowed

repository: OPEXGroup/TicTacToeGame

gha_language: C#

repo_name: OPEXGroup/TicTacToeGame


text:
[linkedin]: https://www.linkedin.com/in/rodrigo-barbosa-710b10180/,
[license-badge]: https://img.shields.io/github/license/RodrigoBLima/DBZ-React?color=%238257E5
[star-badge]: https://img.shields.io/github/stars/RodrigoBLima/DBZ-React?color=8257E5&logo=github
[last-commit-badge]: https://img.shields.io/github/last-commit/RodrigoBLima/DBZ-React?color=%238257E5
[codacy-badge]: https://app.codacy.com/project/badge/Grade/b2d32fa731984f3e9c3eaa814861c9db
[license-url]: https://github.com/RodrigoBLima/DBZ-React/blob/master/LICENSE
[issues-url]: https://github.com/RodrigoBLima/DBZ-React/issues/
[node-url]: https://nodejs.org/en
[yarn-url]: https://classic.yarnpkg.com/
[npm-url]:  https://www.npmjs.com/
[BADGE_LICENSE]: https://img.shields.io/github/license/RodrigoBLima/DBZ-React
[BADGE_TYPESCRIPT]: https://badges.frapsoft.com/typescript/code/typescript.png?v=101
[BADGE_WEB_REACT]: https://img.shields.io/badge/web-react-blue
[BADGE_SERVER_NODEJS]: https://img.shields.io/badge/server-nodejs-important
[BADGE_OPEN_SOURCE]: https://badges.frapsoft.com/os/v1/open-source.png?v=103
[BADGE_NODE_VERSION]: https://img.shields.io/badge/node-12.18.0-green
[BADGE_NPM_VERSION]: https://img.shields.io/badge/npm-6.14.4-red
[BADGE_OPEN_ISSUES]: https://img.shields.io/github/issues/RodrigoBLima/DBZ-React?c

Dragon Ball API with ReactJS

> yarn is required

[![Linkedin Badge](https://img.shields.io/badge/-RodrigoBarbosa-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://https://www.linkedin.com/in/rodrigo-barbosa-710b10180/)][linkedin]
![BADGE_LICENSE] ![BADGE_WEB_REACT] ![BADGE_SERVER_NODEJS] ![BADGE_OPEN_SOURCE] ![BADGE_NODE_VERSION]
![Git Stars][star-badge]
![Last Commit][last-commit-badge]
![Codacy Quality][codacy-badge]

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.

Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.

You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.

See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.

It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.

Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

 The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

# License
[MIT License](/LICENSE)

repository: RodrigoBLima/DBZ-React

gha_language: TypeScript

repo_name: RodrigoBLima/DBZ-React


text:
---
author: dealingwith
date: '2006-04-18 18:00:00'
layout: post
slug: quote-of-the-day-words-of-the-day
status: publish
title: quote of the day + words of the day
wordpress_id: '1240'
categories:
 - quotable
 - word of the day
---

> ...the school of experience--not reasoning out of a solution a priori, but
making a great many small mistakes fast, and then keeping a record of them.
This is where the 21st century has a profound [oracular][1] advantage over the
intellectual experience of all previous centuries--it can simply search the
daylights out of vast datamines of experience, at the press of a button.

> The ability to make many small mistakes in a hurry is a vital accomplishment
for any society that intends to be sustainable. It's not necessary that every
experience be sensible logical or even sane--but it's vitally important to
register, catalog and data-mine the errors.

[#][2]

[futurity][3], [qua][4], [bucolic][5], [tony][6]

   [1]: http://dictionary.reference.com/search?q=oracular

   [2]: http://www.google.com/search?q=shaping+things

   [3]: http://dictionary.reference.com/search?q=futurity

   [4]: http://dictionary.reference.com/search?q=qua

   [5]: http://dictionary.reference.com/search?q=bucolic

   [6]: http://dictionary.reference.com/search?q=tony

repository: dealingwith/poole

extension: markdown

repo_name: dealingwith/poole


text:
# PermissiveDict

Dictionary class with loose rules for returning an attribute or a requested key value.
--------------------------------------------------------------------------------------

Note: may resort to iterating the dict values to find the matching requested key, so is potentially slow.

Key is first directly found using the exact key, and then loose rules are used.

Installing
----------

    pip install permissive-dict

Key Search Rules:
-----------------

1. Keys compared without regard to case.
2. Spaces, underscores, full-stops and dashes are equivalent in a requested key.
3. Requested key is converted to str and stripped for wild card searching.
4. Items in the list can be retrieved by, get, attribute_access, call or array requested_key.
5. First matching element is returned.
6. Default of '' is used instead of dict standard None or raising KeyError
7.

Keys can be accessed as attributes, array index, get() or by calling the instance variable.

Key and value can be set as an attribute.
-----------------------------------------

Example:

    a = PermissiveDict()
    a.hello = 4
    a.hello == a['hello'] == a('hello') == a.get('HellO')

Converting an entire list of dicts
----------------------------------

An entire list of dictionaries can be converted to PermissiveDict using
the `convert_list` method.  NOTE: no deep conversion is done and child
dictionaries are not converted.

Example:

    list_of_dicts = [dict(a=n) for n in range(10)]
    permissive_list = PermissiveDict.convert_list(list_of_dicts)

Notes
-----

Only Python 3 is supported.

Release history
---------------
1.0.4 Fix missing handling of _ and -

repository: Martlark/PermissiveDict

gha_language: Python

repo_name: Martlark/PermissiveDict


text:
# vmsh
Spawn debug container with shell access in virtual machines

# Usage

- Run `just pts` in one terminal to get a `/dev/pts/x`.
- Run `just qemu` in another terminal to spawn a VM.
- Run `just attach-qemu-sh /dev/pts/x` in another terminal to attach the first terminal to the shell which is spawned into the VM.

# Related work

Build small vm images with [microvm.nix](https://github.com/astro/microvm.nix)

repository: Luis-Hebendanz/vmsh

repo_name: Luis-Hebendanz/vmsh


text:
# BinG: Automatic Balancing in Games

Bing is a video game development framework that aims to balance the game's difficulty according to the current player's skill.

This approach's objective is to provide a way for the designer to freely determine which aspects of the game will change in accordance to the player, and under what circunstances.

BinG operates by using python, more specifically the kanren library, to translate the conditions and actions specified by the game designer as rules and facts through logical programming.

# Team

The BinG team is composed by students and a teacher from Instituto Federal do Rio de Janeiro, and collaborators from Universidade
Federal Fluminense, both in Brazil.

- José Ricardo da Silva Junior (teacher/research advisor)
- Felipe Machado de Azeredo Figueira (student)
- Lucas Marcio Nascimento (graduate)
- Rogério Medeiros Dias (student)

Collaborators:

- Esteban Walter Gonzalez Clua
- Troy Costa Kohwalter
- Leonardo Gresta Paulino Murta

# Publications

KOHWALTER, T. C.; FIGUEIRA, F. M. A.; SERDEIRO, E. A. M; JUNIOR, J. R. S.; MURTA, L. G. P; CLUA, E. W. G;
Understanding Game Sessions Through Provenance. In: Entertainment Computing, 2018.

FIGUEIRA, F. M. A.; NASCIMENTO, L. M. C.; JUNIOR, J. R. S.; KOHWALTER, T. C.; MURTA, L. G. P; CLUA, E. W. G;
BinG: A Framework for Dynamic Game Balancing using Provenance. In: SBGAMES, 2018.

repository: josericardojr/BinG

repo_name: josericardojr/BinG


text:
# Justification Factory - Justification Diagrams Editor and Visualizer (JDEV)
This GUI expose in a graphical way the differents services exposed by the Justification Factory Engine
## Stakeholders:
  * Owner: Clément Duffau ([duffau@i3s.unice.fr](duffau@i3s.unice.fr))
  * Students:
    * Carlier Maxime ([maxime.carlier@etu.unice.fr](maxime.carlier@etu.unice.fr))
    * Chevalier Mathias ([mathias.chevalier@etu.unice.fr](mathias.chevalier@etu.unice.fr))

## Technologies

  * Angular 5
  * JointJS - Diagram Design Library
  * TypeScript
  * Karma
  * Jasmine

## Dependencies needed

* nodeJs
* npm (which supposedly come within nodeJs installation)
* Justification Factory Engine instance

## To run the platform
* Run `npm install` at the root of the cloned directory.
* Run `ng serve` to start the development server.


text:
## Chapter 4: Complex Calculations
### Exercise 3: Most decorated athlete per region
Your goal for this exercise is to show the most decorated athlete per region. To set up this report, you need to leverage the ROW_NUMBER() window function, which numbers each row as an incremental integer, where the first row is 1, the second is 2, and so on.

Syntax for this window function is ROW_NUMBER() OVER (PARTITION BY field ORDER BY field). Notice how there is no argument within the initial function.

When set up correctly, a row_num = 1 represents the most decorated athlete within that region. Note that you cannot use a window calculation within a HAVING or WHERE statement, so you will need to use a subquery to filter.

Feel free to reference the [E:R Diagram](https://assets.datacamp.com/production/repositories/3815/datasets/ed6586166b9158f3bc66814cb40b059ace13667d/ER_diagram_pdf.png). We will use summer_games_clean to avoid null handling.

### Instructions for the exercises:
- Query 1:
    - Build a query that pulls region, athlete_name, and total_golds by joining summer_games_clean, athletes, and countries.
    - Add a field called row_num that uses ROW_NUMBER() to assign a regional rank to each athlete based on total golds won.

- Query 2:
    - Alias the subquery as subquery
    - Query region, athlete_name, and total_golds, and then filter for only the top athlete per region.

### Sample database:

![](https://camo.githubusercontent.com/2eeb4b9f8be1109ec87e0da6ca16ff85bc57b21a/68747470733a2f2f692e6962622e636f2f7462364b7274672f436170747572652d342e706e67)

![](https://i.ibb.co/tp7VpVd/Capture-1.png)

![](https://camo.githubusercontent.com/b031568d9ac99edddb3aed1263ebf10ac3098e61/68747470733a2f2f692e6962622e636f2f646d56564668312f436170747572652d322e706e67)

### Query given as the solution:
**Query 1**:
```sql
SELECT
	-- Query region, country, and total gold medals
	region,
    name AS athlete_name,
    SUM(gold) AS total_golds,
    -- Assign a regional rank to each athlete
    ROW_NUMBER() OVER (PARTITION by region ORDER BY SUM(gold) DESC) AS row_num
FROM summer_games_clean
JOIN countries
ON summer_games_clean.country_id = countries.id
JOIN athletes
ON summer_games_clean.athlete_id = athletes.id
GROUP BY region, athlete_name;
```
**Query 2**:
```sql
-- Query region, athlete name, and total_golds
SELECT
	region,
    athlete_name,
    total_golds
FROM
    (SELECT
        -- Query region, country, and total gold medals
        region,
        name AS athlete_name,
        SUM(gold) AS total_golds,
        -- Assign a regional rank to each athlete
        ROW_NUMBER() OVER (PARTITION BY region ORDER BY SUM(gold) DESC) AS row_num
    FROM summer_games_clean AS s
    JOIN athletes AS a
    ON a.id = s.athlete_id
    JOIN countries AS c
    ON s.country_id = c.id
    -- Alias as subquery
    GROUP BY region, athlete_name) AS subquery
-- Filter for only the top athlete per region
WHERE row_num = 1;
```

url: https://raw.githubusercontent.com/naeemahaz/Reporting-in-SQL-DataCamp-Course-Exercises/0671ae331c160666b4d3cc617d2577600911dc30/Chapter 4 - Complex Calculations/Exercise 3.md

filename: Exercise 3.md


text:
# gem5-CA-Lab-Auth-

_Authors: Iason-Georgios Velentzas & Georgios Savvidis_

## Lab1

### [1.1]Basic_configs
This file consists of two basic ideas based on `starter_se.py`:
+ System's Basic Parameters are defined.
+ System's Basic Characteristics are reported and explained.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/%5B1.1%5DBasic_configs)

### [1.2]Config_Validation
This file reports all Basic Characteristics mentioned in [1.1] based on the `config.json` file created by gem5, thus validating them.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/%5B1.2%5DConfig_Validation)

###### References:7
[DDR3-1600-8x8 Reference 1](https://github.com/uart/gem5-mirror/blob/master/src/mem/DRAMCtrl.py?fbclid=IwAR2rouQPULwbeunSy-R05zFbjXAenb0x4-L29RGdlkFvCQezmn5dcK_49o)

[DDR3-1600-8x8 Reference 2](https://en.wikipedia.org/wiki/DDR3_SDRAM)

### [1.3.]gem5_CPU_Models
This file included all in-order CPU Models in gem5 and their bried explanation.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/Part3/%5B1.3.%5Dgem5_CPU_Models)

##### References:
[InOrder CPU Model](http://gem5.org/InOrder)

[MinorCPU](http://www.gem5.org/docs/html/minor.html)

[HPICPU](http://www.gem5.org/wiki/images/c/cf/Summit2017_starterkit.pdf)

#### [1.3.a]test_exec
This file shows the timing of both CPU Models Simulations

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/Part3/%5B1.3.a%5Dtime_exec)

[link to C file](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/Part3/test.c)

#### [1.3.b]Results_Explained
This file explains the reasoning behind the two CPU Model differences.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/Part3/%5B1.3.b%5DResults_Explained)

#### [1.3.c]comparisons
This file explains the comparisons when changing the CPU clock and memory type on both our CPU Models respectively.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/Part3/%5B1.3.c%5DComparisons)

[link to cmd instructions](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab1/%5BL1%5Dcmd_instructions.sh)

## Lab2
#### [2.1.1]caches
This file shows the simulation's requested parameters.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B2.1.1%5D%20caches.md)

#### [2.1.2]benchmark info
This file shows every benchmark info using the specified CPU configuration.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B2.1.2%5D%20benchmark%20info.md)

#### [2.1.3]benchmark cpu clock
This shows benchmark simulation time and clock parameters when changing CPU Clock.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B2.1.3%5D%20benchmark%20cpu%20clock.md)

#### [2.2.1]Simulation_Analysis
This file shows the whole simulation logic and procedure that was used.
This file also includes step [2.2.2]Diagram_Figures for total configuration ratings.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B2.2.1%5D%20Simulation_Analysis.md)

[CSV, Figure files & Scripts used for the first Simulation Iterations](https://github.com/DukeSav/gem5-CA-Lab-Auth-/tree/master/Lab2/CSV_round1)

[CSV, Figure files & Scripts used for the second Simulation Iterations](https://github.com/DukeSav/gem5-CA-Lab-Auth-/tree/master/Lab2/CSV_round2)

[All R scripts used](https://github.com/DukeSav/gem5-CA-Lab-Auth-/tree/master/Lab2/R_scripts)

#### [2.2.2]Simulation_Diagrams
These files show the final diagrams which undermine the behaviour of every benchmark based on every parameter.

[Figures for the Total Diagrams](https://github.com/DukeSav/gem5-CA-Lab-Auth-/tree/master/Lab2/%5B2.2%5D%20DiagramsOfEffect)

#### [2.3]Cost_Function
In this file you can see the procedure followed to model the Cost_Function and the rationale behind it
[Cost_Function_Procedure](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B3%5D%20Cost%20Function)

#### [2.3]Cost_Function_2
In this file you can see the procedure followed to model the Cost_Function for the second time and the rationale behind it
[Cost_Function_2_Procedure](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab2/%5B2.3%5D%20Cost%20Function_2.md)

Some plots that demonstrate the behavior of this function under certain parameters configured.

[Plots_of_Cost](https://github.com/DukeSav/gem5-CA-Lab-Auth-/tree/master/Lab2/Cost_Plots)

#### References
[gem5 Options](http://gem5.org/Running_gem5?fbclid=IwAR02b7hjfnl2kE4V0OERKJ3SkCIoYpphi0vaF_f5XjJYMPA6Qly9hMBojys)

[Published specCPU2006 Simulations on various CPUs](https://www.spec.org/cpu2006/results/cint2006.html?fbclid=IwAR1maHonZUh6oLhSujRqPHt11gIxMT-wpjjLAQeBolON8w3rn9juKU0kq0Q)

[Thorough Report on CPU architecture](https://akkadia.org/drepper/cpumemory.pdf?fbclid=IwAR3-7uozhX6LCHK6u5rYGZcqurjTzKQ8OCe66hs7vnn-dyb4PCumUbQHFTk)

[specCPU2006 Simulations on a specific CPU and Conclusions](https://www.ece.lsu.edu/lpeng/papers/isast08.pdf?fbclid=IwAR02b7hjfnl2kE4V0OERKJ3SkCIoYpphi0vaF_f5XjJYMPA6Qly9hMBojys)

#### [3.1.1]Dynamic Power - Leakage
In this file you can see description on dynamic power and leakage, as well their behaviour in programms.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab3/Part1/%5B3.1.1%5DDynamic%20Power%20-%20Leakage.md)

#### [3.1.2]Energy
In this file you can see how energy efficiency is modeled how each parameter affects it.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab3/Part1/%5B3.1.2%5DEnergy.md)

#### [3.1.3]Different CPUs
In this file each CPU's energy efficiency is calculated.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab3/Part1/%5B3.1.3%5DDifferent%20CPUs.md)

#### [3.2.1]EDAP Calculation
In this file Area, Delay and Energy is modeled based on parameters the two simulators provide us.

[link](https://github.com/DukeSav/gem5-CA-Lab-Auth-/blob/master/Lab3/Part2/%5B3.2.1%5DEDAP%20Calculation.md)

#### [3.2.2]  McPAT configs
In this file we get all cofiguration from Lab2, run them with McPAT and plot their results.

[link]()

#### [3.2.3] Cost Function - EDAP
In this file EDAP is calculated based on the modeling explained in [3.2.1]. Results are plotted and compared to the Lab 2 cost function

[link]()