text:
---
title: "Web-scraping Jeopardy Contestant Profiles"
date: '2020-03-12'
layout: post
summary: Utilizing Python's BeautifulSoup and Tweepy libraries, we can collect and organize Jeopardy contestant data publicly recorded online to build profiles on the 'typical' Jeopardy contestant.

categories: Workshop Python Jeopardy
---

*This is a two part workshop for UCLA DataFest competitors on
how to organize a data analytics project with Python.*

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

Weeknights mean Jeopardy in my household. I’ll watch the show with anyone that’s willing to listen as I mutter answers at a television screen while Alex Trebek asks challenging trivia questions. Jeopardy has been a central feature of my life, bonding with my Dad over dinner or competing with college roommates to see who is the “smartest”.

The show is known for its structured and professional manner, where
contestants are cordial with one another, and everyone demonstrates a sort of
deference to the show and its now legendary host. After the first
commercial break, however, all contestants are given a chance to discuss
something interesting about themselves. This is where, in my opinion,
anyone who is a fan of the Bachelor gets a taste of their favorite
snack: human judgement. It’s fun watching contestants talk about being
mistaken for Nicolas Cage in Mexico, or tell embarrassing stories about
coaching Quidditch teams (these are real examples!)

As an exercise in exemplifying how to conduct an independent data analytics project,
I thought it would be fun to look at anyone but the Champions.
More specifically, I want to take a deep dive into the types of people
that make it onto the show, and what aspect of their lives they think is
worth discussing in front of a live audience. From a data perspective, can we
simulate the contestant's fun facts and create a Jeopardy *Watson* with its
own personality?

Part 1: Capturing The Data
----------------

We can collect information on Jeopardy contestants from the
[*Official Jeopardy Archive*](https://j-archive.com/). The Jeopardy Archive collects and maintains all
details related to the show, including each contestant’s name, occupation,
hometown, number of games won, cash winnings, and more.
Using the BeautifulSoup library in Python 3.7, we can scrape the website for
these variables and build a data set of details for each contestant on each show.

### Web-Scrape the Jeopardy Archive

Reviewing an individual game on the archive, we see the page stores player's details at the top of each game, and their total scores throughout each of the rounds, displaying their total and final scores at the end at the bottom.

To capture this information, we can put together a function that will iterate through the pages to pull these out for each game played. We will start on game ID [6389](http://www.j-archive.com/showgame.php?game_id=6389), and iterate back in time to capture a specified number of games.

```python
# Set-Up
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup  #main web-scraping package
import requests # allows you to send https requests
import pandas as pd # for manipulating data into data frames
import re # regular expressions package

# Define Function that sets a game ID and number of pages to extract from the jeopardy archive
def jep_scraper(game_id = 6389, num_pages_to_extract = 300):

    # initialize variables
    index = 0
    new_game_id = 0

    output = []
    error_catalog = []

    archive_link = "http://www.j-archive.com/showgame.php?game_id="
    jeopardy_archive_link = archive_link + str(game_id)

    while index < num_pages_to_extract:
        # get page, timeout set to 5 seconds
        page_response = requests.get(jeopardy_archive_link, timeout=5)

        # confirm no error with pull
        try:
            page_response.raise_for_status()
            pass
        except:
            print("HTML ERROR CODE: " + str(page_response.status_code))

        page_content = BeautifulSoup(page_response.content, "html.parser")

        # create empty variables to fill
        anecdotes = []
        final_scores = []
        names = []
        show_info1 = []
        show_info2 = []
        show_info3 = []

        #title date
        title_date = page_content.find_all('title')[0].text

        # iterate through three contestants
        for j in range(0, 3):
            #Find all anecdotes for contestants
            paragraphs = page_content.find_all("p")[j].text

            # Final all final scores for contestants
            try:
                table1 = page_content.find_all(lambda tag: tag.name == 'td' and

                                           (tag.get('class') == ['score_positive']
                                            or
                                            tag.get('class') == ['score_negative']
                                            # some scores can be negative!! See 5913
                                           )
                                          )[9:12][j].text
                pass

            except IndexError:
                print("Error 1 @ Game ID:" + str(new_game_id))
                # error output - used to locate mismatched fields
                error_catalog.append(jeopardy_archive_link)
                # store links from archive (typically special events)

            #extract player names and details
            try:
                table2 = page_content.find_all(lambda tag: tag.name == 'td' and
                                   tag.get('class') == ['score_player_nickname'])[j].text
                pass

            except IndexError:
                print("Error 2 @ Game ID:" + str(new_game_id))
                # error output - used to locate mismatched fields
                error_catalog.append(jeopardy_archive_link)
                # store links from archive (typically special events)

            try:
                table3 = page_content.find_all(lambda tag: tag.name == 'td' and
                                   tag.get('class') == ['score_remarks'])[j].text
                pass

            except IndexError:
                print("Error 3 @ Game ID:" + str(new_game_id))
                # error output - used to locate mismatched fields
                error_catalog.append(jeopardy_archive_link)
                # store links from archive (typically special events)

            #append these player details together
            anecdotes.append(paragraphs)
            final_scores.append(table1)
            names.append(table2)

        # reorder and correct data (anecdotes go 2 1 0 / names and scores go 0 1 2 )
        show_info1.extend([names[0],anecdotes[2],final_scores[0],title_date])
        show_info2.extend([names[1],anecdotes[1],final_scores[1],title_date])
        show_info3.extend([names[2],anecdotes[0],final_scores[2],title_date])

        #add to final output file
        output.append(show_info1)
        output.append(show_info2)
        output.append(show_info3)

        #create link to next page by creating previous page number
        new_game_id = page_content.find_all(lambda tag: tag.name == 'a' and
                                                    tag.get('href') and
                                                    tag.text == "[<< previous game]")
        #print(new_game_id)
        #[<a href="showgame.php?game_id=6388">[<< previous game]</a>]
        # WE WANT THE GAME ID ----------^^^^

        new_game_id = re.findall(r'\d+', str(new_game_id[0]))[0]
        # USE REGEX TO CAPTURE JUST DIGITS

        # create next page link
        jeopardy_archive_link = archive_link + new_game_id
        jeopardy_archive_link

        #update iterator
        index = index + 1

    #return items
    return output, error_catalog

```

The function  works by extracting the title of each game, and assigning it to each player, along with their scores and details. One of the tricky aspects with
this data is that the players are named right to left, but their data is recorded left to right. This is a simple problem but one
that can isn't obvious without cross checking some live game footage.

Once a game's information has been scraped, the function simply calls
the previous page's link, and loops continuously until it finds the predetermined number of game details. Any errors found are stored in a separate output list, for review once the task is complete. These errors highlight some of the different game types that jeopardy tends to host, such as the Celebrity or Team tournaments (i.e. Game ID [6223](http://www.j-archive.com/showgame.php?game_id=6223) )

### Extract Tweets from @CoolJepStories

But what about those "fun facts" that players share after the first
commercial break? These are not recorded at all on the archive, and there is next to no centralized database for these anywhere online.

To get a sense of these anecdotes, we rely on the work of Chad
Mosher, as there are no episode transcripts easily available
online [^1]. Chad ran the @CoolJeopardyStories account from February
11th, 2014 to July 26th, 2019, where he created tweet length version’s
of each show contestant’s story. While these transcription aren’t
perfect representations, they get to the meat of the stories and will
work for our purposes.

First, we set up a Twitter developer account to extract data from the site. Once we have credentials, we can build a simple script using the Tweepy package in Python to extract tweets from specified accounts.

```python
# -*- coding: utf-8 -*-
import tweepy
import pandas as pd

# fill these in with your own twitter developer information
consumer_key= '###############################'
consumer_secret= '###############################'
access_key = '###############################'
access_secret= '###############################'

#User ID
userID = "@CoolJepStories"
# Authorization to consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
# Access to user's access key and access secret
auth.set_access_token(access_key, access_secret)
# Calling api
api = tweepy.API(auth)
```

Twitter contains plenty of documentation on how to use their API, as
well as other resources online. We first want to specify the number of tweets to call from the user account, as well as they type of tweets. In this case, we only need actual tweets from the account (no retweets.)

```python
# 1750 tweets to be extracted
number_of_tweets=1750
tweets = api.user_timeline(screen_name=userID, count = number_of_tweets,
                           include_rts = False, tweet_mode="extended")

all_tweets = []
all_tweets.extend(tweets)
oldest_id = tweets[-1].id
while True:
    tweets = api.user_timeline(screen_name=userID,
                           count=200, # max allowed count
                           include_rts = False,
                           max_id = oldest_id - 1,
                           # Necessary to keep full_text
                           # otherwise only the first 140 words are extracted
                           tweet_mode = 'extended'
                           )
    if len(tweets) == 0:
        break
    oldest_id = tweets[-1].id
    all_tweets.extend(tweets)
    print('N of tweets downloaded till now {}'.format(len(all_tweets)))

```
We can then continuously call chunks of these tweets, 200 at a time in this case due to limits on the API. Once collected, we use Pandas to convert them to a Dataframe, and quickly save them to a csv to avoid having to run anything again.

```python
#transform the tweets into an array that will populate the csv
outtweets = [[tweet.id_str,
              tweet.created_at,
              tweet.favorite_count,
              tweet.retweet_count,
              tweet.full_text.encode("utf-8").decode("utf-8")]
             for idx,tweet in enumerate(all_tweets)]
df = pd.DataFrame(outtweets,columns=["id","created_at","favorite_count","retweet_count", "text"])
df.to_csv('%s_tweets.csv' % userID,index=False)

```

After some additional data cleaning and string extraction, we can merge these datasets together on their respective player IDs and
date fields to create a full data set of contestant details.
The final dataset for our analysis contains *1,971* contestants playing in games ranging from October 24th, 2010 to July 26th, 2019.

*Read Part 2 for the analysis of the contestant data!*

---

#### Data

[Jeopardy Archive](https://j-archive.com/)

#### Code

[Github](https://github.com/JamesWWilson/Jeopardy-Fun-Facts)

#### Footnotes + Citations

[^1]: If you work for Jeopardy or NBC, I would love access to transcripts from the show to analyze!


text:
Contributing
============
Report an issue
---------------
Please follow the guidelines below when creating an issue so that your issue can be more promptly resolved:
* Provide information including: the version of PHP and IPTool, the type of operating system and Web server;
* Provide the complete error call stack if available;
* Describe the steps for reproducing the issue. It would be even better if you could provide code to reproduce the issue;

Do not report an issue if you are asking how to use some IPTool feature. You should use the [Documentation](https://github/ddrv/iptool/wiki).

Before you report an issue, please search through existing issues to see if your issue is already reported or fixed to make sure you are not reporting a duplicated issue. Also make sure you have the latest version of IPTool and see if the issue still exists.

Translate documentstion
-----------------------
1. Put documentation translations under `docs/<language>.md` where `<language>` is the language code of the language docs are translated to. For the Russian translation it is `docs/ru.md`.
2. Make pull request

license: MIT

repository: ipstack/finder

branch_name: refs/heads/master

extension: md

gha_language: PHP

gha_license_id: MIT

license_type: permissive

repo_name: ipstack/finder


text:
# Development Pods Dependency Checker

A tool which checks your development pod's dependencies for iOS projects written in electron.

[如果你也用 Development Pods](https://zxy.vercel.app/development-pods-dependency-checker)

## screenshot

![](./shot.gif)

## development and run

`> yarn install`

`> electron-forge start`

## publish

`> electron-forge publish`

## releases

[Releases](https://github.com/X140Yu/development-pods-dependency-checker/releases)

## License

MIT


text:
# Tapufind Mac Removal
This script try to fully remove Tapufind.

These are the **known** folders where tapufind can be found and from files will be removed:
- /Users/$USER/Library/LaunchAgents
- /Users/Shared (work in progress...)

Also, this folder, witch contains Safari cache, will be removed after user confirmation:
/Library/Cahes/com.apple.Safari

I might have been infected via torrent downloading so you know... Watch out.

If you got infected I would be pleased if you could tell me where you found tapu files at and also their names.
I am specially interested in /Users/Shared folder, because I am almost sure that tapu creates several kind of files different names, but with a same pattern.

You can find me as @angelidito almost everywhere.

license: Unlicense

repository: angelidito/Mac-Tapufind-virus-removal

repo_name: angelidito/Mac-Tapufind-virus-removal


text:
# Kiprotich Amos Koech Personal Gallery
## Author

[Kiprotich Amos Koech](https://github.com/amoskipz/Gallery)

# Description
This is a Django application for a personal gallery that allows a user to upload images for others to view in detail, by location or by category and be able to share the image link.

##  Live Link

## Setup and Installation

##### Cloning the repository:
 ```bash
 https://github.com/amoskipz/Gallery
```
##### Navigate into the project folder and install dependencies
 ```bash
 pip install -r requirements.txt
```
##### Install and activate Virtual environment
 ```bash
 virtualenv virtual && source virtual/bin/activate
```

 ##### Setup Database
  SetUp your database User and Password, then makemigrations
 ```bash
 python manage.py makemigrations
 ```
 Then Migrate
 ```bash
 python manage.py migrate
```
##### Run the application
 ```bash
 python manage.py runserver
```

##### Testing the application
 ```bash
 python manage.py test
```

## Technologies used

* [Python3.8](https://www.python.org/)
* [Django 3.1.2](https://www.djangoproject.com/download/)
* [Heroku](https://heroku.com)

## Known Bugs
* None, reach out below incase of any.

## Contact Information
In case of any question or complaints, please<EMAIL_ADDRESS>me

## License

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

 Copyright (c) 2020 **Kiprotich Amos Koech**

repository: amoskipz/Gallery

repo_name: amoskipz/Gallery


text:
# ClinVarGene

ClinVarGene provides counts of missense and loss of function (LOF) variants per gene, that have a significance of "Pathogenic" found in ClinVar.
LOF variants include nonsense, splice acceptor, splice donor, frameshift, or an initiatior codon.

gha_language: JavaScript


text:
# Puente Website

[![Build Status](https://travis-ci.com/hopetambala/puente-react-gatsby-website.svg?branch=master)](https://travis-ci.com/hopetambala/puente-react-gatsby-website)
![](https://img.shields.io/badge/react-✓-blue.svg)

Puente Website is a modern, responsive website built using Gatsby.js and Content.

<!-- [AWS S3 dev URL](http://website-react-gatsby.s3-website-us-east-1.amazonaws.com
/) -->

## Project Layout
| Key Folder | Parent Folder | Description |
| - | - | - |
| pages | src | Holds the main layout folders for content |
| components | src | Holds the smaller components that are within layouts |

## Development

This project is built with [ReactJS](https://reactjs.org), [Gatsby](https://www.gatsbyjs.org/), and [Contentful](https://www.contentful.com/). Gatsby use's [GraphQL](https://graphql.org/) to retrieve data from Contentful.

This project is a bootstrapped using Gatsby

Here are some quick commands to get started:

- `npm install`: Install Node dependencies
- `npm run develop`: Start the gatsby development server.
- `npm setup`: Run's a setup script that connects this application to the Contentful CMS. Needs system arguments
- `npm run build`: Build a production optimized bundle of the app.
- `npm run deploy`: Deploy a production optimized bundle of the app to AWS s3

### AWS + s3

Get this React App working on AWS by [installing the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-install-cmd).

#### Deploy in your terminal

```
$ npm run deploy
```

#### Permissions and Settings
There's a decent amount that'll be necessary to get this publically consumed on the AWS website itself. Follow [this](https://www.newline.co/fullstack-react/articles/deploying-a-react-app-to-s3/) guide to get those hammered out.

## Resources

- [CSS Boxes](https://www.bypeople.com/css-boxes/)
- [Flexbox](http://flexbox.buildwithreact.com/)
- [Google Domains to S3](https://medium.com/@limichelle21/connecting-google-domains-to-amazon-s3-d0d9da467650)

repository: hopetambala/puente-react-gatsby-website

repo_name: hopetambala/puente-react-gatsby-website


text:
---
title: Setup Wallet & Account
description: How to create a nano account and wallet
tags: nano, wallet, account, crypto, setup, create, use, address, seed, secure, instructions
---

# Setting up an Account

Before you get started make sure to understand some basic facts about [Nano](/getting-started-users/basics) and [storing it](/getting-started-users/storing/basics).

| Usage             | Wallet Approach                         |
| ----------------- | --------------------------------------- |
| Long-term storage | Paper or hardware wallet                |
| Active usage      | Software wallet, backed by paper wallet |
| Giving away       | Paper wallet                            |

## Setup a password manager

Regardless of what wallet you use (software or hardware), you will need to back it up with a paper wallet. Using a password manager as a paper wallet to backup your seeds and secret keys provides the best mix of convenience, security, and durability.

You should be using a password manager for other reasons anyways.

### Setup KeePassXC

Feel free to use whatever password manager you would like. KeePassXC is a good starter recommendation for the following reasons:

- offline
- allows you to manage/backup password file
- open source
- free
- strong encryption
- cross platform

Download KeePassXC

#### Master password selection

You should generate a random password or use a passphrase.

 If you use your password manager frequently enough, you will be able to memorize this password or passphrase. Otherwise, you may have to take additional steps to ensure it is durably backed up (i.e. engraved on a piece of metal).

#### Backup password manager file

Since it is offline, you have full control over how and where you store the encrypted password file (i.e. usb, cloud storage, etc). It is good practice to make multiple copies. Since the password file is encrypted, it is fine to store copies on cloud storage providers like google drive and dropbox. A good mix would be to have multiple local copies (usb, external drives, etc) as well as multiple remote copies on various cloud storage providers.

## Generating an account

To generate an account all you need to do is generate either a random seed or secret key. Software wallets will do this for you and allow for you to export the secret seed or key.

To generate one on your own, you can download one of the following static websites and securely generate one on your local machine. These static pages run locally on your computer and so you can disconnect your computer from the internet when using them. To be extra safe you can copy the file and use it on an "air-gapped" computer.

##### Offline Generators

- Numtel (Download / Github) — Source
- Nanoo.tools (Download / GitHub) — Site

_Note: these generators have not been audited yet_

## Software Wallets

To receive/send transactions and change your representative you will have to import your seed or secret key into a wallet.

- Desktop: Nault.
- Mobile: Natrium.
- Command Line: Atto.

For a comprehensive wallet guide visit nanowallets.guide.

It is your responsibility to properly handle and secure your secret seed or key. Make sure you understand what you are doing before you give any application your secret seed or key, as you are giving them full control over that account.

Follow these [best practices](/getting-started-users/best-practices).

branch_name: refs/heads/main


text:
## Number Practice

Enter the correct number with minimal context.

[Demo](https://ryanford-dev.github.io/number-practice/)

#### Attribution

Thanks to the following for their CC-0 Sounds on [freesound](https://www.freesound.org):
- [EnjoyPA](https://freesound.org/people/EnjoyPA/) for the narrated numbers
- [HenryRichard](https://freesound.org/people/HenryRichard/) for the success tone
- [Breviceps](https://freesound.org/people/Breviceps/) for the error tone

repository: ryanford/number-practice

repo_name: ryanford/number-practice


text:
# setuptools-cmd-deps

![Continuous Integration](https://github.com/jameslan/setuptools-cmd-deps/workflows/Continuous%20Integration/badge.svg)
![pypi](https://img.shields.io/pypi/v/setuptools-cmd-deps)

Configure `setuptools` command dependencies easily.

## Why I need this plugin
Once a custom `setuptools` command is defined and needs to be run before some build-in command,
traditionally, there's no simple way and the solution is to override the build-in command,
to call the new custom command before the command implemented in the super class.

In this way, having an additional class and digging into `setuptools`,
are just to configure the command order or dependency.

This could be simplified by using `setuptools-cmd-deps`:
enable the plugin and add custom configuration.

## Command dependency in the project

If your command is just for the project and it won't be reused,
you could use new setup keyword `cmd_deps` to define the dependencies.

### Enable setuptools-cmd-deps

- If your `setup.py` will run only after all depending packages are installed,
add `setuptools-cmd-deps` in your dependency list,
such as `requirements.txt`, or `Pipfile`.

- If your `setup.py` supports running out of venv,
you may not want these packages to be installed in the system.
Then add `setuptools-cmd-deps` in the `setup_requires` option of your `setuptools`.

### Define dependency

```python
setuptools.setup(
    cmdclass={'generate_py': GenereatePy},
    cmd_deps={'build_py': ['generate_py']},
)
```

## Command dependency to be shared

If you are developing a `setuptools` plugin,
and want the command definition to be used by other project and run before some command,
specify the dependency in the `setuptools.cmd_deps` section in your `entry_points`.

### Enable setuptools-cmd-deps for the target

Add `setuptools-cmd-deps` in the `install_requires` option of your `setuptools`,
so that any project uses your package, will automatically uses `setuptools-cmd-deps`.

### Define dependency

Generally speaking, you already have `distutils.commands` in your `entry_points`.

For example, you defined `gernate_py` command in the `entry_points` as follows,

```
distutils.commands =
    generate_py = command:GeneratePy
```

and want it always run before `build_py`.
Simply add `setuptools.cmd_deps` in the `entry_points` as follows,

```
setuptools.cmd_deps =
    build_py_dep = build_py:generate_py
```

Note that the name `build_py_dep` is not used here.
It is just for the TOML syntax.
For the same reason, if there are multiple dependencies for one command,
it should use dot `.` as delimiter,

```
setuptools.cmd_deps =
    command_dep = command:cmd1.cmd2
```

Both `cmd1` and `cmd2` will be run before `command`.

Or you can have multiple rules,

```
setuptools.cmd_deps =
    command_dep1 = command:cmd1
    command_dep2 = command:cmd2
```

repository: jameslan/setuptools-cmd-deps

gha_language: Python

repo_name: jameslan/setuptools-cmd-deps


text:
# Armor

Armor is a toolchain to protect you from any bugs. It contains toolset to create and simplify DevOps practices. More on wiki
https://github.com/AutomationRockstars/Design/wiki

#Contributing

It's easy to contribute to AutomationRockstars code. Just setup an account on github and fork the project. When you have some code to contribute, send a pull request! Please do not push your changes directly.

License

Armor is licensed with the Apache License, version 2.0. You can find more information on the license here: http://www.apache.org/licenses/LICENSE-2.0.html


text:
# Thai authorities re-open cave where football team was trapped in 2018

Published at: **2019-11-02T17:24:46+00:00**

Author: **Euronews & Reuters **

Original: [euronews](https://www.euronews.com/2019/11/02/thai-authorities-re-open-cave-where-football-team-was-trapped-in-2018)

Thai authorities have re-opened a famous cave where a local football team and their coach were trapped underground for weeks in 2018.
The Tham Laung cave was re-opened on Saturday over a year since the 12 young players for the Wild Boar Academy and their coach were rescued in July 2018.
The team, which had entered the cave on 23 June 2018, where trapped during a flash flood and had to survive on water dripping from the rocks.
The international rescue effort was headline news across the world.
On Saturday, Duangporn Sookawong, 75, who came all the way from the southern Songkhla province, said she believed that the rescue was a miracle and the boys were lucky that they were able to survive despite being stuck in the dark, complex network of caves.
In July, the Thai football team returned to Tham Laung a year since their dramatic rescue to honour a former navy who died in the rescue effort.
They placed flowers next to a portrait of Sergeant Saman Kunan, a former member of an elite Thai Navy Seal unit, who died while he worked underwater.
In April it was revealed that Netflix had agreed a deal to make a mini-series about the rescue, while two books have already been published about it.

repository: dsadlollioygjmzvcxv/tdc-exported

repo_name: dsadlollioygjmzvcxv/tdc-exported


text:
# passport-keycloak-oauth2-oidc

[Passport](http://passportjs.org/) strategy for authenticating with [Keycloak](http://www.keycloak.com/)
using the OAuth2/OIDC API.

This module lets you authenticate using Keycloak in your Node.js applications.
By plugging into Passport, Keycloak authentication can be easily and
unobtrusively integrated into any application or framework that supports
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).

## Install

```bash
$ npm install passport-keycloak-oauth2-oidc
```

## Usage

### Create an Application

Before using `passport-keycloak-oauth2-oidc`, you must create a `realm` and `client` with your Keycloak.

### Configure Strategy

The Keycloak authentication strategy authenticates requests by delegating to
your Keycloak server using the OpenID Connect (OIDC/OAuth 2.0) protocol.

When using this strategy, it's AuthorizationURL and
TokenURL options are generated based on the `authServerURL` and
`realm` options. You can find these two option values
from the `Applications->Installation` section, or from the
`OAuth Clients->Installation` section in your keycloak realm.

Applications must supply a `verify` callback which accepts an `accessToken`,
`refreshToken` and service-specific `profile`, and then calls the `done`
callback supplying a `user`, which should be set to `false` if the
credentials are not valid.  If an exception occured, `err` should be set.

Options:

- `realm`            Name of your KeyCloak realm (set to `master` by default).
- `authServerURL`    Base URL for you Realm authorization endpoint.
- `publicClient`     If your Keycloak client's `Access Type` is set to `public` (`publicClient` set to `true` by default).
- `clientID`         This will match your `Application Name`, `resource` or `OAuth Client Name`.
- `clientSecret`     If your Keycloak client's `Access Type` is set to `confidential` this is required (`publicClient` set to `false`).
- `callbackURL`      URL to which KeyCloak will redirect the user after granting authentication.
- `sslRequired`      requires SSL for (all|external|none) requests (set to `external` by default).

Examples:

```javascript
  var KeyCloakStrategy = require('passport-keycloak-oauth2-oidc').Strategy;
  passport.use(new KeyCloakStrategy({
      clientID: 'myOauthClient',
      realm: 'MyKeyCloakRealm',
      publicClient: 'false',
      clientSecret: '6ee0f303-faef-42d7-ba8e-00cdec755c42',
      sslRequired: 'external',
      authServerURL: 'https://keycloak.example.com/auth',
      callbackURL: 'https://www.example.com/keycloak/callback'
    },
    function(accessToken, refreshToken, profile, done) {
      User.findOrCreate(..., function err, user) {
        done(err, user);
      });
    }
  });
```

### Authenticate Requests

Use `passport.authenticate()`, specifying the `'keycloak'` strategy, to
authenticate requests.

For example, as route middleware in an [Express](http://expressjs.com/)
application:

```javascript
app.get('/auth/keycloak',
  passport.authenticate('keycloak', { scope: ['profile'] }));

app.get('/auth/keycloak/callback',
  passport.authenticate('keycloak', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });
  ```

### How to get Roles

By default, Keycloak returns Roles information within AccessToken.

If you are wondering to fetch Roles (e.g. realm_access roles, resource_access roles etc) within UserInfo endpoint, please make sure that Keycloak returns those claims .

To add these claims to the UserInfo endpoint, edit the `roles` settings in the Client Scopes:

Clients Scopes -> roles -> settings:

- name: roles
- Include In Token Scope: enable

and in the `client roles` mappers settings, an example mapping :

- name: client roles
- mapper type: user client role
- multivalued: on
- token claim name: roles.resource_access.${client_id}.roles
- claim JSON type: string
- add to userinfo: enabled

## License

[The MIT License](http://opensource.org/licenses/MIT)


text:
# FirebaseDemo
Source code for tutorial series over Firebase - Introduction to creating real-time applications.
Series videos can be found here: https://www.youtube.com/playlist?list=PLZm85UZQLd2Qncxk7hNH-m9Te0kdM6GR2

Source code for individual videos can be found by selecting the appropriate video from the BRANCH link above.

repository: BrentAureli/FirebaseDemo

repo_name: BrentAureli/FirebaseDemo


text:
## Installation

Most of the requirements of this projects are exactly the same as [maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark). I put them into one install.sh file. However, it's writen for **CUDA10.0**. If not, you should kindly change the [commond](https://github.com/Wangt-CN/VC-R-CNN/blob/master/install.sh#L9) about installing pytorch in `install.sh`.
Moreover, if you have any problem of your environment, you should check this [issues page](https://github.com/facebookresearch/maskrcnn-benchmark/issues) first. Hope you will find the answer.

### Requirements:

- PyTorch 1.0 from a nightly release. It **will not** work with 1.0 nor 1.0.1. Installation instructions can be found in https://pytorch.org/get-started/locally/
- torchvision from master
- cocoapi
- yacs
- matplotlib
- GCC >= 4.9
- OpenCV
- CUDA >= 9.0

### Step-by-step installation

```bash
# Here we directly provide the instll.bash file for convenient installation.
# first, make sure that your conda is setup properly with the right environment
# for that, check that `which conda`, `which pip` and `which python` points to the
# right path. From a clean conda env, this is what you need to do

conda create --name vc_rcnn -y
conda activate vc_rcnn

# Then just run:
sh install.sh
```


text:
# FFT.CRC32

[![NuGet package](https://img.shields.io/nuget/v/FFT.CRC.svg)](https://nuget.org/packages/FFT.CRC)

A fast, allocation-free implementation for incrementally calculating a CRC32 value on a stream of data slices as each slice becomes available.

[Full Documentation](https://fastfintech.github.io/FFT.CRC)


text:
+++
title = "DVR in the Gazette"
date = "2019-05-23"
description = "For the first time since the Derwent Valley Gazette was relaunched in early 2019, the Derwent Valley Railway has returned to the publication for a very eye-catching front page spread."
image = "/v1558607141/news/11174976_856068491147198_5297583515118285458_n_cah1q5.jpg"
+++

# DVR in the Gazette

For the first time since the *Derwent Valley Gazette* was relaunched in early 2019, the Derwent Valley Railway has returned to the publication for a very eye-catching front page spread. The article, written by Melbourne based supporter (and Derwent Valley expatriate) Steve Balmforth, reiterates the wide ranging benefits the railway could bring to the valley and encourages locals to rally behind the project.

Steve also reminisces on the important role the railway has played in the valley's development. "The train service from New Norfolk was an integral part of community life in the Valley, with regular passenger services to Hobart, plus the small stops along the upper lines through to Maydena" he writes. "The regular log trains to Boyer were common and passenger service from Hobart to Boyer that transported employees to the paper mill. In the 1960s the Hobart Show train excursion was a special, and many would have fond recollections of this train journey."

[Read the full article here](/downloads/DVG15052019TOREAD.pdf)

![Gazette front page](https://res.cloudinary.com/dvrailway/image/upload/v1558611137/news/DVG15052019TOREAD_n61aes.jpg)

repository: derwentvalleyrailway/www

gha_language: HTML

repo_name: derwentvalleyrailway/www


text:
---
title: Corda Services 101
date: "2018-08-19"
published: true
tags: [corda, kotlin, dlt, blockchain, distributed ledger technology]
include_date_in_url: true
github_url: https://github.com/lankydan/corda-services
cover_image: blog-card.png
---

I'm in the mood to write a short and to the point post today. I'm actually curious how quickly I can get this published. So let's go.

This post is about Corda Services (using Corda version `3.2`). What are they? As a developer that uses Spring a lot, I would personally say they are like Beans. There is more than Spring Beans can do, but on a basic level, they are pretty similar. Anyway, let's stop talking about Spring and focus on Corda.

## The bare minimum you need to know

Corda Services are classes external to Flows, that currently, can only be called from within an executing Flow or from another service (which is in turn, called by a Flow). Similar to a `subFlow`, they allow you to reuse code but should be used for different reasons. Such as, a collection of vault query functions or initiating `trackBy` within a node. These are what I tend to use services for anyway.

Corda Services are defined by using the `@CordaService` annotation along with extending `SingletonSerializeAsToken`. Once this is done, when your Cordapp is loaded and the node starts up, the service that you have just defined will be initialised:

```kotlin
@CordaService
class MessageRepository(private val serviceHub: AppServiceHub) : SingletonSerializeAsToken() {

    private companion object {
        val log = loggerFor<MessageRepository>()
    }

    init {
        log.info("I am alive!")
    }

    fun findAll(pageSpec: PageSpecification): Vault.Page<MessageState> =
        serviceHub.vaultService.queryBy(QueryCriteria.LinearStateQueryCriteria(), pageSpec)
}
```

`serviceHub` provides access to everything you need. In this example, the service accesses the `vaultService` to retrieve states from the node's vault.

It is now ready to be used from within your Flows or other services if desired. The snippet below is taken from one of my Flows:

```kotlin
private fun repository() = serviceHub.cordaService(MessageRepository::class.java)
```

`serviceHub` is available in all Flows and provides the `cordaService` function. For input, it requires the class of the service you are trying to retrieve. In this case, the `MessageRepository` is being loaded.

## A tiny bit more information

That is all you need to start using Corda Services. But. I'll give you a bit more information so you don't make some of the same mistakes I made.

Lesson one. When calling a service from a Flow. Do not inject it inside the constructor of the Flow. Instead, call it from somewhere inside the `call` function or any others used from that point. If you don't you'll see the below error message:

```
java.lang.IllegalStateException: This can only be done after the flow has been started.
```

The above is the error you'll get when calling the Flow from a test. If calling from RPC you'll get something like this:

```
Caused by: java.lang.reflect.InvocationTargetException: null
Caused by: java.lang.IllegalStateException: This can only be done after the flow has been started.
```

Likely with a long stacktrace depending on your chosen web framework.

It isn't entirely clear that injecting the service in at this point causes these errors and you might find they pop up for other reasons. But I think it's safe to say, at least in Corda `3.2`, that you should not do anything inside the constructor or during initialisation of a Flow.

Just to make this even clearer, below is the code that accompanied the earlier snippet where I injected the service:

```kotlin
@InitiatingFlow
@StartableByRPC
class ReplyToMessagesFlow : FlowLogic<List<SignedTransaction>>() {

    @Suspendable
    override fun call(): List<SignedTransaction> {
        return messages().map { reply(it) }
    }

    private fun messages() =
        repository().findAll(PageSpecification(1, 100))
            .states
            .filter { it.state.data.recipient == ourIdentity }

    private fun repository() = serviceHub.cordaService(MessageRepository::class.java)

    @Suspendable
    private fun reply(message: StateAndRef<MessageState>) = subFlow(SendMessageFlow(response(message), message))

    private fun response(message: StateAndRef<MessageState>): MessageState {
        val state = message.state.data
        return state.copy(
            contents = "Thanks for your message: ${state.contents}",
            recipient = state.sender,
            sender = state.recipient
        )
    }
}
```

As you can see, the service is injected within the `repository` function which is in turned called by `call`. Following this sort of structure everything will work just fine.

Lesson two. Do not forget to include `serviceHub: AppServiceHub` in your service's constructor (you can call `serviceHub` whatever you like). If you don't do this it won't create the service and you'll find the following error pops up when you try to access it:

```
Caused by: java.lang.IllegalArgumentException: Corda service com.lankydanblog.tutorial.services.MessageRepository does not exist
```

Although, there is a ray of hope in this situation... It is very unlikely you would do this. Because without an instance of `AppServiceHub` there isn't really much you can do with your own service. You will not have access to the vault or any of the other inbuilt services. So, at the end of the day, this lesson is a bit pointless but I still fell into this trap...

## Is that all?

Damn, I think I actually wrote a short post for once! Is that good or bad? I'm not 100% sure...

Anyway, I'm trying really hard to think of some more snippets of information. But I cant. The bare minimum to get a Corda Service working really is nice and easy.

That being said, in the last few weeks, I have learnt that there is some pretty cool and useful stuff that you can do within services that cannot be done within Flows. That is a subject I hope to cover at some point!

## Conclusion

Corda Services allow you to create classes external to Flows where you can logically group code that isn't directly related to the execution of a Flow. My favourite way to use a service is to group vault query functions into a single class (pretty much what I would do in the Spring world). There are a few steps you need to take to ensure you create your service correctly. Firstly, annotate it with `@CordaService` and extend `SingletonSerializeAsToken`. Secondly, make sure that you inject them into your Flows in the correct way, which is pretty much anywhere but the constructor (or `init` in Kotlin). Lastly, remember to include `AppServiceHub` in the service's constructor. Once you are able to use Corda services, you will be able to separate code out of your Flows. Not only making the Flows shorter, but also making them easier to understand while increasing the reusability of the code that you spent your valuable time writing.

The code used for this post can be found on my [GitHub](https://github.com/lankydan/corda-services). There is a lot more in that repository that was not included in this post.

If you found this post helpful, you can follow me on Twitter at [@LankyDanDev](http://www.twitter.com/LankyDanDev) to keep up with my new posts.

repository: lankydan/lankydanblog-jamstack

repo_name: lankydan/lankydanblog-jamstack


text:
# adonisup

Adonis API project creator with my default configuration:

- Yarn
- Vow for testing
- Postgres database
- ESLint and Prettier config
- CircleCI config

## Requirements

- Yarn
- Adonis CLI

```sh
$ npm install -g @adonisjs/cli
```

## Installation

Clone the repo and add `adonisup/bin` to your path.

## Usage

```bash
adonisup myprojectname
```

## Manual Steps

The following steps must done manually after running `emberup`; they have not yet been scripted.

In `package.json`, add the following scripts:

```diff
 "scripts": {
   "start": "node server.js",
   "test": "node ace test",
+  "lint": "eslint \"**/*.js\"",
+  "format": "prettier --write \"**/*.js\""
 },
```

Run `yarn format` and commit the changes.

## License

Apache-2.0

repository: CodingItWrong/adonisup

repo_name: CodingItWrong/adonisup


text:
# User On-boarding - Enterprise Directory Synchronization

Active Directory's Users and Groups can be synchronized to IDCS using the **Microsoft Active Directory Bridge**.

You can select which AD containers of Users and Groups will be synchronized.
A User's password is **NOT** synchronized. So users will need to either -

* "Activate" (have email sent to them with link) which will let them set a password, or
* Federate into IDCS - using your companies' SAML Identity Provider (IDP) - for example - **Active Directory Federation Service (ADFS)**

## Persona

Administrators, End-Users

## Demo Logistics

Windows Server 2012 equipped with .NET framework 4.6+. The script has been tested with Windows 2012 64-bit Server.

## Active Directory Setup

`(Persona: Administrators)`

#### Installing Active Directory
* Log into Active Directory Machine as Administrator

* Copy install script file [createDomain.ps1](resources/createDomain.ps1) onto your Active Directory machine.

* Right click on **createDomain.ps1** and choose run with PowerShell.

![](images/UO-EDS-1.jpg)
![](images/UO-EDS-2.jpg)

* This will run a script and then reboot. It will show a list of errors which can be disregarded. The process should take between 5-10 minutes.

![](images/UO-EDS-3.jpg)
![](images/UO-EDS-4.jpg)
![](images/UO-EDS-5.jpg)

#### Populating Active Directory with required users and Orgs

* Log into Active Directory Machine as<EMAIL_ADDRESS>

* Download and copy [populateAD.ps1 ](resources/populateAD.ps1) to this machine if you have not done so already.

* Right click on **populateAD.ps1** and choose run with PowerShell.

![](images/UO-EDS-6.jpg)
![](images/UO-EDS-7.jpg)

* The powershell script will say *complete* when completed. You can then close the powershell window.

![](images/UO-EDS-8.jpg)
![](images/UO-EDS-9.jpg)

* The Users, OU's and groups should now exist.

![](images/UO-EDS-10.jpg)
![](images/UO-EDS-11.jpg)

## Configure Identity Bridge

`(Persona: Administrators)`

* Log into IDCS Admin Console

![](images/UO-EDS-12.jpg)

* Click [Download and Configure]() under the title **Directory Integrations** from bottom of screen.

* Click the button **Add a Microsoft Active Directory Bridge**

![](images/UO-EDS-13.jpg)

* Click **Download**. This will download the Bridge installer to your local machine.

![](images/UO-EDS-14.jpg)
![](images/UO-EDS-15.jpg)

* Copy the ClientID and Shared secret information

![](images/UO-EDS-16.jpg)

* Copy the downloaded installer on the Windows server

* Launch the Oracle Identity Cloud Service Active Directory Agent installer (double click the **EXE** file) from the Windows Server.

* Click on **Next** on the next 3 screens on the Wizard

![](images/UO-EDS-17.jpg)
![](images/UO-EDS-18.jpg)
![](images/UO-EDS-19.jpg)

* In the *Enter Provided Credentials* window, provide information about your Oracle Identity Cloud Service:
	* **Cloud Service URL:** The Oracle Identity Cloud Service URL. For example, [https://example.oraclecloud.com](https://example.oraclecloud.com)
	* **Identity Bridge Client ID** and **Identity Bridge Secret** - The information you copied from Oracle Identity Cloud Service earlier
	* Click on **Next**

![](images/UO-EDS-20.jpg)

* Provide Active Directory Administrator credentials, uncheck **Use SSL** checkbox, and click on **Test Connection**

![](images/UO-EDS-21.jpg)

* After successful connection test, click on **Next**

![](images/UO-EDS-22.jpg)

* Installer will now install the agent. When finished exist the installer by clicking **Close**.

![](images/UO-EDS-23.jpg)

* Go back to the IDCS Admin Console. Move to **Directory Integrations** menu under **Settings**. The registered client will be listed as active.

![](images/UO-EDS-24.jpg)

* Click the bridge you just registered. The page contains four items where you can select organizational units for users, for groups and configure the synchronization.

![](images/UO-EDS-25.jpg)

* In the **Select Organizational Units (OU's) for Users** section, select the OU's containing the users that you want to synchronize with IDCS. Select **DemoUsers** OU.

* In the **Select organizational units(OU's) for Groups** Section, select OU's containing the groups to be synchronized with IDCS. Select **Groups** OU.

* In the **Set import frequency** section, select the interval at which the agent will run and synchronize users and groups with IDCS. Change the interval to something shorter than 1 Hour. (1-5 minutes are good options)

* The **federated authentication** is enabled by default. This configuration means the user credentials will be validated against a configured Identity Provider. In this demo, uncheck the federated authentication checkbox. IDCS will generate the password for the users and send the notification by email (the email attribute must be filled in Microsoft Active Directory and mapped to IDCS).

![](images/UO-EDS-26.jpg)

* Click on **Save**.

![](images/UO-EDS-27.jpg)

* Summary of the bridge configuration is displayed.

![](images/UO-EDS-28.jpg)

* Click **Attribute Mappings** tab to modify the default attribute mappings between the Microsoft Active Directory and IDCS. Keep the default mappings for the demo.

![](images/UO-EDS-29.jpg)

* Click **Import** tab to see information about the last time the bridge ran. At this moment no information is shown as you did not run it yet.

![](images/UO-EDS-30.jpg)

## Initial Synchronization

`(Persona: Administrators)`

* Click **Import** to manually start the import job.

* Refresh the page until the synchronization is completed.

![](images/UO-EDS-31.jpg)

* Review the synchronization summary displayed :

```
How many users were successfully imported.
How many groups were successfully imported.
How many users failed to import.
How many groups failed to import.
```

![](images/UO-EDS-32.jpg)

## Verify Synchronization

`(Persona: Administrators)`

* In the IDCS admin console, click **Users**.

* The users imported from the Microsoft Active Directory are displayed in IDCS

![](images/UO-EDS-33.jpg)

* Click **Groups**.

* The groups imported from Microsoft Active Directory are displayed in IDCS.

![](images/UO-EDS-34.jpg)

* Click the group **Employees** and then click **Users** tab. The group membership reflects the membership from Active Directory. Verify that **Danny Crane** is part of the **Employees** group.

![](images/UO-EDS-35.jpg)

## Synchronize Changes in Active Directory

`(Persona: Administrators)`

* From IDCS admin console, click the group **OurVendor** and then click **Users** tab. Ensure that no user is assigned to the group.

![](images/UO-EDS-36.jpg)

* Go to **Active Directory Users and Computers** inside the Windows Server. Open the group **OurVendor**. Add **John Wells** as the member.

![](images/UO-EDS-37.jpg)
![](images/UO-EDS-38.jpg)
![](images/UO-EDS-39.jpg)

* Run the **Import** job of the bridge again from IDCS admin console. Refresh until finished.

![](images/UO-EDS-40.jpg)

* Verify that **John Wells** is now a member of the group **OurVendor** in IDCS.

![](images/UO-EDS-41.jpg)

## Activate IDCS Account

`(Persona: End-Users)`

* Login to Gmail as [demoidcs@gmail.com](). Go to the **User1** label. Verify that there is an activation email from IDCS for **Danny Crane**

![](images/UO-EDS-42.jpg)

* Open and review the email. Click on the **Activate Your Account** button.

![](images/UO-EDS-43.jpg)

* IDCS Change Password page will open up. Provide a suitable password that matches the listed **Password Criteria**. Click on **Submit**.

![](images/UO-EDS-44.jpg)

* Verify that you are redirected to IDCS **MyApps** portal, which would be empty for now.

![](images/UO-EDS-45.jpg)

![](images/UO-EDS-46.jpg)

* Go to `My Profile` section from menu located top-right

![](images/UO-EDS-47.jpg)

* Ensure that **Employee** group is visible under **My Access** sub-tab

![](images/UO-EDS-48.jpg)

## Additional Resources

* [Understanding the Bridge](https://docs.oracle.com/en/cloud/paas/identity-cloud/uaids/understanding-bridge.html)

* Tutorial: [Oracle By Example (OBE): Oracle Identity Cloud Service: Integrating with Microsoft Active Directory Using Directory Integrations](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/idcs/idcs_idbridge_obe/idbridge.html)

* An Approach to AD Bridge HA using Docker and Windows Containers - [OTN Link](http://www.oracle.com/technetwork/articles/idm/gutierrez-idcs-idbridge-3960710.html)

repository: jdavies/learning-library

repo_name: jdavies/learning-library


text:
A different take on the stock-standard Perlin fractal, StrataPerlin is a very powerful 'ground fractal' that can be used on its own or layered with other generators. The Perlinesque output is stratified with pattern-matching formulae to generate realistic slabs of minerals ready for erosion. This device is extremely fast to build, even at ultra-high resolutions.

## Properties

### StrataPerlin

- **Scale:**
- **Stratification:**
- **Equalization:**
- **Seed:**

repository: QuadSpinner/GeoGlyph-Docs

branch_name: refs/heads/dev

repo_name: QuadSpinner/GeoGlyph-Docs


text:
## Spook Safe

 Porticode 2.0, October 28th - 29th 2017

 ![Alt Spook Safe](img/logo.png)

 ## Developers

 Design/Logo Creation: Fino

 Front-End: Nikhil Kunde

 Back-End: Amanda J. Kendal-Brown

## Notice

In order to use the "Use Location" Feature, please use the GitHub Pages link, due to limitations with HTTP and Chrome

GitPages Link: [SpookSafe](https://nikhil1231.github.io/halloween/)


text:
# Fixing web test flakiness

We'd like to stamp out all the tests that have ordering dependencies. This helps
make the tests more reliable and, eventually, will make it so we can run tests
in a random order and avoid new ordering dependencies being introduced. To get
there, we need to weed out and fix all the existing ordering dependencies.

## Diagnosing test ordering flakiness

These are steps for diagnosing ordering flakiness once you have a test that you
believe depends on an earlier test running.

### Bisect test ordering

1. Run the tests such that the test in question fails.
2. Run `./tools/print_web_test_ordering.py` and save the output to a file. This
   outputs the tests run in the order they were run on each content_shell
   instance.
3. Create a file that contains only the tests run on that worker in the same
   order as in your saved output file. The last line in the file should be the
   failing test.
4. Run
   `./tools/bisect_web_test_ordering.py --test-list=path/to/file/from/step/3`

The bisect_web_test_ordering.py script should spit out a list of tests at the
end that causes the test to fail.

*** promo
At the moment bisect_web_test_ordering.py only allows you to find tests that
fail due to a previous test running. It's a small change to the script to make
it work for tests that pass due to a previous test running (i.e. to figure out
which test it depends on running before it). Contact ojan@chromium if you're
interested in adding that feature to the script.
***

### Manual bisect

Instead of running `bisect_web_test_ordering.py`, you can manually do the work
of step 4 above.

1. `run_web_tests.py --child-processes=1 --order=none --test-list=path/to/file/from/step/3`
2. If the test doesn't fail here, then the test itself is probably just flaky.
   If it does, remove some lines from the file and repeat step 1. Continue
   repeating until you've found the dependency. If the test fails when run by
   itself, but passes on the bots, that means that it depends on another test to
   pass. In this case, you need to generate the list of tests run by
   `run_web_tests.py --order=natural` and repeat this process to find which test
   causes the test in question to *pass* (e.g.
   [crbug.com/262793](https://crbug.com/262793)).
3. File a bug and give it the
   [LayoutTestOrdering](https://crbug.com/?q=label:LayoutTestOrdering) label,
   e.g. [crbug.com/262787](https://crbug.com/262787) or
   [crbug.com/262791](https://crbug.com/262791).

### Finding test ordering flakiness

#### Run tests in a random order and diagnose failures

1. Run `run_web_tests.py --order=random --no-retry`
2. Run `./tools/print_web_test_ordering.py` and save the output to a file. This
   outputs the tests run in the order they were run on each content_shell
   instance.
3. Run the diagnosing steps from above to figure out which tests

Run `run_web_tests.py --run-singly --no-retry`. This starts up a new
content_shell instance for each test. Tests that fail when run in isolation but
pass when run as part of the full test suite represent some state that we're not
properly resetting between test runs or some state that we're not properly
setting when starting up content_shell. You might want to run with
`--timeout-ms=60000` to weed out tests that timeout due to waiting on
content_shell startup time.

#### Diagnose especially flaky tests

1. Load
   https://test-results.appspot.com/dashboards/overview.html#group=%40ToT%20Blink&flipCount=12
2. Tweak the flakiness threshold to the desired level of flakiness.
3. Click on *webkit_tests* to get that list of flaky tests.
4. Diagnose the source of flakiness for that test.

repository: chromium/chromium

repo_name: chromium/chromium


text:
[![Stories in Ready](https://badge.waffle.io/yoo2001818/shellscripts.png?label=ready&title=Ready)](https://waffle.io/yoo2001818/shellscripts)
# shellscripts
A shell script snippets repository website

Please do note that I'm experimenting with various web frameworks with this.

I'm kinda interested in sever-side rendering, so I think I'm gonna implement it,
but I can't find any applicable framework for that. Please let me know by
sending mail<EMAIL_ADDRESS>if you know one!

I'll use Redux for framework, and implement server-side rendering later.

repository: GrooshBene/shellscripts

repo_name: GrooshBene/shellscripts


text:
# 网页授权

发起授权:

```
$response = $bear->oauth->redirect();
$response->send();
```

获取已授权用户:

```text
$user = $bear->oauth->user();
```


text:
# Customize Error Pages

WSO2 Identity Server display errors, exceptions, and HTTP status codes in full detail. These are known as verbose error messages. These error messages contain technical details such as stack traces. There may also disclose other sensitive details. Attackers may fingerprint the server, based on the information disclosed in error messages. Alternatively, attackers may attempt to trigger specific error messages to obtain technical information about the server. You can avoid these situations by configuring the server to display generic, non-detailed error messages in Apache Tomcat.

The pages that should be displayed on a certain throwable exception, error or an HTTP status code are specified in the
`<IS_HOME>repository/conf/tomcat/carbon/WEB-INF/web.xml` file. You can customize those error pages as preferred. For example, if you try to access a resource that is not available in the Carbon server (e.g., https://localhost:9443/carbon/abc), you will see the "Error 404 - Not Found" page (be sure to log in as admin to have access to that URL).

You can customize the above error message by following the instructions given below.

1.  [Download and install Apache Maven](https://maven.apache.org/install.html).

2.  [Create a Maven project using your IDE.](https://maven.apache.org/guides/getting-started/index.html#How_do_I_make_my_first_Maven_project)

3.  Create a directory named "resources" inside the `<PROJECT_HOME>/src/main/` directory, and then create another directory named "web" inside it.

    !!! tip
        `<PROJECT_HOME>` denotes the top-level
        directory of your Maven project.

4.  Create a new HTML error page (e.g. `new_error_404.html` file) as shown below. This contains the customized error page.

    ``` xml
    <html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
            <title>404 - Error not found</title>
        </head>
        <body>
            <h1>Sorry, this resource is not found.</h1>
        </body>
    </html>
    ```

5.  Add the `new_error_404.html` file inside the `<PROJECT_HOME>/src/main/resources/web` directory.

6.  Add the following property below the `<version>` element in the `<PROJECT_HOME>/pom.xml` file.

    ``` xml
    <packaging>bundle</packaging>
    ```

7.  Add the following configurations inside the `<plugins>` element in the `<PROJECT_HOME>/pom.xml` file.

    ``` xml
    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
            <instructions>
                <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                <Bundle-Name>${project.artifactId}</Bundle-Name>
                <Import-Package>
                    org.osgi.framework,
                    org.osgi.service.http,
                    org.wso2.carbon.ui,
                    javax.servlet.*;version="2.4.0",
                    *;resolution:=optional
                </Import-Package>
                <Fragment-Host>org.wso2.carbon.ui</Fragment-Host>
                <Carbon-Component>UIBundle</Carbon-Component>
            </instructions>
        </configuration>
    </plugin>
    ```

8.  Add the following configurations inside the `<dependencies>` element in the `<PROJECT_HOME>/pom.xml` file.

    ``` xml
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.framework</artifactId>
        <version>1.0.3</version>
    </dependency>
    ```

9.  Build the Maven project by executing the following command.

    ```bash
    mvn clean install
    ```

10. Once the project is built, copy the JAR file (from the `<PROJECT_HOME>/target/` directory) to the `<IS_HOME>/repository/components/dropins/`
    directory.

11. Change the following configurations in the `<IS_HOME>/repository/conf/tomcat/carbon/WEB-INF/web.xml` file.

    ``` xml
    <error-page>
        <error-code>404</error-code>
        <location>/carbon/new_error_404.html</location>
    </error-page>
    ```

    !!! tip
        You need to replicate this configuration, and change the values of the `<error-code>` and `<location>` elements accordingly for each
        new HTML error page you add.

12. Restart WSO2 Identity Server.

13. Access the following URL again to test the error page you customized: `https://localhost:9443/carbon/abc`.
    Be sure to log in as admin to have access to the URL.

    You will view the new error page with the following content: "Sorry, this resource is not found."

gha_language: CSS


text:
## Demonstrating the BOSH lifecycle for releases
See [bosh.io documentation](http://bosh.io/docs/job-lifecycle.html) for additional details.

Containing examples for the following scripts:
* drain
* pre-start
* post-start
* post-deploy

## How to use
* Build your own release with `bosh create release`
* Upload the release to your BOSH Director with `bosh upload release`
* Start with the [manifest example](#manifest/lifecycle-demo.yml) or build your own
* `bosh deploy`

repository: voelzmo/lifecycle-demo-release

repo_name: voelzmo/lifecycle-demo-release


text:
---
layout: post
title:      "Quickly Set Up Multer For Node File Parsing"
date:       2021-07-10 23:29:00 +0000
permalink:  quickly_set_up_multer_for_node_file_parsing
---

Starting with plain HTML we use an input with `type='file'`

```html
<input type="file" name="image" id="image" />
```

However, files can not be parsed into `url-encoded` format directly from HTML so we need a middleware that will be able to handle the parsing of files. For that we’ll use `multer` and change the encoding type of the form to use `multipart/form-data` like so:

```HTML
<form
      class="product-form"
      action="/product"
      method="POST"
      enctype="multipart/form-data"
      >
      	<label for="title">Title</label>
        <input type="text" name="title" id="title">

    	  <label for="image">Image</label>
        <input type="file" name="image" id="image">
      </div>
</form>
```

Now we can tell express to use the `multer` middleware and configure it like so:

```js
// app.js
const multer = require("multer");

app.use(multer().single("image"));
```

When `multer` parses a file it will return it as a Buffer stream with no where to go, so if we give it somewhere to go, `multer` will store the the Buffer as binary in a specified folder.

```js
// app.js
const multer = require("multer");

app.use(multer({ dest: "images" }).single("image"));
```

This will create a directory named `images` and create a file with a long hashed string.

Adding a `.jpg` to the end of the given file name will allow you to view the binary data as an image.

In order to customize how `multer `handles file storages we can pass additional arguments or configurations for `multer `to use:

```js
// app.js
const multer = require("multer");

const fileStorage = multer.diskStorage({
  destination: (req, file, cb) => {
    cb(null, "images");
  },
  filename: (req, file, cb) => {
    cb(null, file.originalname);
  },
});

app.use(multer({ storage: fileStorage }).single("image"));
```

Its common to add something unique to the file name in cases where you have a plethora of files so you could add something like

```js
filename: (req, file, cb) => {
    cb(null, new Date().toISOString() + file.originalname);
  },
```

We can also filter by mime type to only allow specific types of images

```js
const fileFilter = (req, file, cb) => {
  if (["image/png", "image/jpg", "image/jpeg"].includes(file.mimetype)) {
    cb(null, true);
  } else {
    cb(null, false);
  }
};

app.use(
  multer({ storage: fileStorage, fileFilter: fileFilter }).single("image")
);
```

To save on memory we can send files to the browser in streams for the browser to download and reduce server load time and other potential errors.
It also would be worth looking into creating a pdf doc on-the-fly, with a package called `pdfkit` to dynamically create documents and send it as a stream to the browser to be downloaded or shown ‘inline’ on the same page.

extension: markdown


text:
# http: HTTP Trigger

The HTTP trigger is the only trigger created by default if not configured (by default, it has 1 worker). This trigger handles incoming HTTP requests at container port 8080, assigning workers to incoming requests. If a worker is not available, a `503` error is returned.

## Attributes

| **Path** | **Type** | **Description** |
| :--- | :--- | :--- |
| port | int | The NodePort (or equivalent) on which the function will serve HTTP requests. If empty, chooses a random port within the platform range. |
| ingresses.(name).host | string | The host to which the ingress maps. |
| ingresses.(name).paths | list of strings | The paths that the ingress handles. Variables of the form `{{.<NAME>}}` can be specified using `.Name`, `.Namespace`, and `.Version`. For example, `/{{.Namespace}}-{{.Name}}/{{.Version}}` will result in a default ingress of `/namespace-name/version`. |

### Examples

Without ingresseses -

```yaml
triggers:
  myHttpTrigger:
    maxWorkers: 4
    kind: "http"
    attributes:
      port: 32001
```

With ingresseses -

```yaml
triggers:
  myHttpTrigger:
    maxWorkers: 4
    kind: "http"
    attributes:
      port: 32001

      # See "Invoking Functions By Name With Kubernetes Ingresses" for more details
      # on configuring ingresses
      ingresses:
        http:
          host: "host.nuclio"
          paths:
          - "/first/path"
          - "/second/path"
        http2:
          paths:
          - "MyFunctions/{{.Name}}/{{.Version}}"
```

repository: onesolpark/nuclio

gha_language: Go

repo_name: onesolpark/nuclio


text:
+++
# Experience widget.
widget = "experience"  # See https://sourcethemes.com/academic/docs/page-builder/
headless = true  # This file represents a page section.
active = true  # Activate this widget? true/false
weight = 40  # Order that this section will appear.

title = "Experience"
subtitle = ""

# Date format for experience
#   Refer to https://sourcethemes.com/academic/docs/customization/#date-format
date_format = "Jan 2006"

# Experiences.
#   Add/remove as many `[[experience]]` blocks below as you like.
#   Required fields are `title`, `company`, and `date_start`.
#   Leave `date_end` empty if it's your current employer.
#   Begin/end multi-line descriptions with 3 quotes `"""`.

[[experience]]
  title = "Director of Education"
  company = "Ironhack"
  company_url = ""
  location = "Paris, France"
  date_start = "2021-09-01"
  date_end = ""
  description = """
  Responsibilities include:

  * Product development
  * Education strategy
  * Team Management
  * Learning Experience Design
  * Innovation
  * Learning analytics

  """

[[experience]]
  title = "Director of Digital Learning"
  company = "INSEEC U"
  company_url = ""
  location = "Paris, France"
  date_start = "2019-10-01"
  date_end = ""
  description = """
  Responsibilities include:

  * Learning analytics
  * Product development
  * Content creation
  * Team Management
  * Online assessment
  * Learning design
  """

[[experience]]
  title = "Head of learning and innovation"
  company = "YESNYOU"
  company_url = ""
  location = "Paris, France"
  date_start = "2015-01-01"
  date_end = "2019-09-30"
  description = """
  Responsibilities include:

  * Learning analytics
  * Product development
  * Business development
  * Talent Management
  * International certification
  * Learning design
  """

[[experience]]
  title = "Director of teaching and learning"
  company = "YESNYOU"
  company_url = ""
  location = "Paris, France"
  date_start = "2008-01-01"
  date_end = "2014-12-31"
  description = """Created a blended learning programme for adults learning English, German, French & Spanish as a Foreign Language from Common European Framework of Reference for Languages (CEFR) levels A1-C1 used by ≈10,000 learners per year in Spain, Germany, Russia and France. Established a teaching and learning team of 60 people) present in France, Germany, Russia, and Spain. Led the domestic certification and quality assurance programme."""

+++

repository: ocaoimh/okeeffe-site

repo_name: ocaoimh/okeeffe-site


text:
---
layout: note
tags:
  - tech
  - computer-science
  - learning
---

# Git

Git is a version control system (VCS) initially created for programmers, but it is currently being used by many other professionals such as researchers and writers to track the revision history of their text files.

Is it created by [[Linus Torvalds]], the same person who created [[Linux]].

Some of the interesting things git can do are:

- Track changes to text files over time
- Revert to a past/future version of a particular file, or the entire repository (project).
- Create multiple branches with separate revision history.
- Collaborate with multiple colleagues to work on the same project or files, from distant location.
- Upload, download and merge repositories from code hosting platforms such as GitHub, GitLab etc.

Similar version control systems are:

- SVN
- Mercurial

## Learn

### An open source game about learning Git!

https://ohmygit.org/

### Flight rules for git

https://github.com/k88hudson/git-flight-rules

---

Also See:

- https://github.com/dictcp/awesome-git
- Distributed, offline-first bug tracker embedded in git, with bridges:
  https://github.com/MichaelMure/git-bug


text:
---
title: "More Than Outcomes: The Role of Self-Image in Other-Regarding Behavior"
date: 2015-01-01
publishDate: 2020-06-18T09:59:44.156892Z
authors: ["Astrid Matthey", "Tobias Regner"]
publication_types: ["2"]
abstract: "We conduct a modified dictator game in order to analyze the role self-image concerns play in other-regarding behavior. While we generally follow Konow (2000), a cognitive dissonance-based model of other-regarding behavior in dictator games, we relax one of its assumptions as we allow for individual heterogeneity among individuals’ standards of behavior. Subjects’ self-image, their belief regarding the average socially appropriate behavior of others and our proxies for the cognitive dissonance costs are positively correlated with the dictator game choices.We also find that subjects whose choices involve two psychologically inconsistent cognitions indeed report higher levels of experienced conflict and take more time for their decisions (our proxies for cognitive dissonance)."
featured: false
publication: "*Review of Behavioral Economics*"
doi: "10.1561/105.00000038"
---

repository: TobReg/academic-kickstart

repo_name: TobReg/academic-kickstart


text:
---
title: "Best Practices"
date: 2018-03-17T05:35:36-04:00
description: ""
categories: []
keywords: []
aliases: []
toc: false
draft: false
reviewed: true
---

Light is an ecosystem with many components. It is very complex and has a very steep learning curve as
it is designed for enterprise scale. While working with customers and developers, we have collected some tips and tricks
over the years. Hopefully, these best practices help new users to get started quickly and avoid unnecessary mistakes.

### Specification

- [Swagger 2.0 Best Practices](/development/best-practices/swagger2/)
- [OpenAPI 3.0 Best Practices](/development/best-practices/openapi3/)

### light-rest-4j

### light-eventuate-4j
- [Set up permanent IP on Mac](/development/best-practices/mac-perm-ip/)
- [Troubleshooting Best Practices](/development/best-practices/eventuate-troubleshooting/)

### Debugging

- [Debug Logging Level](/development/best-practices/debug-log/)

repository: networknt/light-doc

repo_name: networknt/light-doc


text:
# Publishing and Sending Messages

[Publish/Subscribe](https://docs.microsoft.com/en-us/azure/architecture/patterns/publisher-subscriber) is a messaging pattern where the senders of messages do not need to specifically know what the specific subscribers are for a given message. In this case, some kind of middleware or infrastructure is responsible for either allowing subscribers to express interest in what messages they need to receive or apply routing rules to send the published messages to the right places. Jasper's messaging support was largely built to support the publish/subscibe messaging patterm.

To send a message with Jasper, use the `IMessagePublisher` interface or the bigger `IMessageContext` interface that
are registered in your application's IoC container. The sample below shows the most common usage:

```cs
public ValueTask SendMessage(IMessageContext bus)
{
    // In this case, we're sending an "InvoiceCreated"
    // message
    var @event = new InvoiceCreated
    {
        Time = DateTimeOffset.Now,
        Purchaser = "Guy Fieri",
        Amount = 112.34,
        Item = "Cookbook"
    };

    return bus.SendAsync(@event);
}
```
snippet source | anchor

That by itself will send the `InvoiceCreated` message to whatever subscribers are interested in
that message. The `SendAsync()` method will throw an exception if Jasper doesn't know where to send the message. In other words,
there has to be a subscriber of some sort for that message.

On the other hand, the `PublishAsync()` method will send a message if there is a known subscriber and ignore the message if there is
no subscriber:

```cs
public ValueTask PublishMessage(IMessageContext bus)
{
    // In this case, we're sending an "InvoiceCreated"
    // message
    var @event = new InvoiceCreated
    {
        Time = DateTimeOffset.Now,
        Purchaser = "Guy Fieri",
        Amount = 112.34,
        Item = "Cookbook"
    };

    return bus.PublishAsync(@event);
}
```
snippet source | anchor

## Send Messages to a Specific Endpoint

You can also explicitly send any message to a named endpoint in the system. You might
do this to programmatically distribute work in your system, or when you need to do more
programmatic routing as to what downstream system should handle the outgoing message.

Regardless, that usage is shown below. Just note that you can give a name to any type
of Jasper endpoint:

```cs
using var host = await Host.CreateDefaultBuilder()
    .UseJasper(opts =>
    {
        opts.PublishAllMessages().ToPort(5555)
            .Named("One");

        opts.PublishAllMessages().ToPort(5555)
            .Named("Two");
    }).StartAsync();

var publisher = host.Services
    .GetRequiredService<IMessagePublisher>();

// Explicitly send a message to a named endpoint
await publisher.SendToEndpointAsync("One", new SomeMessage());
```
snippet source | anchor

TODO -- link to endpoint configuration. Make sure it explains how to

## Send Messages to a Specific Topic

If you're using a transport endpoint that supports publishing messages by topic
such as this example using Rabbit MQ from the Jasper tests:

```cs
theSender = Host.CreateDefaultBuilder()
    .UseJasper(opts =>
    {
        opts.UseRabbitMq().AutoProvision();
        opts.PublishAllMessages().ToRabbitTopics("jasper.topics", exchange =>
        {
            exchange.BindTopic("color.green").ToQueue("green");
            exchange.BindTopic("color.blue").ToQueue("blue");
            exchange.BindTopic("color.*").ToQueue("all");
        });
    }).Start();
```
snippet source | anchor

You can explicitly publish a message to a topic through this syntax:

```cs
var publisher = theSender.Services
    .GetRequiredService<IMessagePublisher>();

await publisher.SendToTopicAsync("color.purple", new Message1());
```
snippet source | anchor

## Customizing Message Delivery

TODO -- more text here

```cs
public static async Task SendMessagesWithDeliveryOptions(IMessagePublisher publisher)
{
    await publisher.PublishAsync(new Message1(), new DeliveryOptions
    {
        AckRequested = true,
        ContentType = "text/xml", // you can do this, but I'm not sure why you'd want to override this
        DeliverBy = DateTimeOffset.Now.AddHours(1), // set a message expiration date
        DeliverWithin = 1.Hours(), // convenience method to set the deliver-by expiration date
        ScheduleDelay = 1.Hours(), // Send this in one hour, or...
        ScheduledTime = DateTimeOffset.Now.AddHours(1),
        ResponseType = typeof(Message2) // ask the receiver to send this message back to you if it can
    }
        // There's a chained fluent interface for adding header values too
        .WithHeader("tenant", "one"));

}
```
snippet source | anchor

repository: JasperFx/jasper

gha_language: C#

repo_name: JasperFx/jasper


text:
## GitLab CI is an open-source continuous integration server

[![build status](https://ci.gitlab.org/projects/2/status.png?ref=master)](https://ci.gitlab.org/projects/2?ref=master)
[![Code Climate](https://codeclimate.com/github/gitlabhq/gitlab-ci.png)](https://codeclimate.com/github/gitlabhq/gitlab-ci)
[![Dependency Status](https://gemnasium.com/gitlabhq/gitlab-ci.png)](https://gemnasium.com/gitlabhq/gitlab-ci)
[![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlab-ci/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlab-ci)

![Screen](https://gitlab.com/gitlab-org/gitlab-ci/raw/master/public/gitlab-ci-screenshot.png)

### Requirements

GitLab CI officially supports (recent versions of) these Linux distributions:

* Ubuntu Linux
* Debian/GNU Linux

Additionally GitLab CI requires:

* GitLab 6.3+ (to host the repositories you test)
* ruby 1.9.3
* MySQL or PostgreSQL

Hardware requirements:

* 1GB of memory or more is recommended, 512MB works
* 2 CPU cores or more are recommended, 1 CPU core works
* A little disk space, 100MB or less

## Features

* Single Sign On: use the same login and password as on your GitLab instance
* Quick project setup: add your project in a single click, all setup automatic via the GitLab API
* Elegant and flexible: build scripts are written in bash, test projects in any programming language
* Merge request integration: see the status of the feature branch build within the Merge Request
* Distributed by default: GitLab CI and build runners can run on separate machines providing more stability
* Realtime logging: the current build log scrolls and updates every few seconds

### Roadmap

The following features are not yet in GitLab CI but merge requests are very welcome:

* [Build artifacts access](http://feedback.gitlab.com/forums/176466-general/suggestions/4522830-allow-access-to-build-artifacts-of-gitlab-ci)
* For parallel builds, deployments, branch specific builds and build metrics there is a [blog article with implementation steps](http://blog.gitlab.org/gitlab-ci-with-parallel-builds-and-deployments/)

### Runners

To perform the actual build you need a CI runner (also see the Architecture section below):

* [Official CI runner for Linux](https://gitlab.com/gitlab-org/gitlab-ci-runner)
* [Unofficial CI runner for Windows](https://github.com/virtualmarc/gitlab-ci-runner-win)
* [Unofficial CI runner for Scala/Java](https://github.com/nafg/gitlab-ci-runner-scala)
* [Unofficial CI runner for Node](https://www.npmjs.org/package/gcr)

### Architecture

__GitLab CI__ is a web application with an API that stores its state in a databse.
It manages projects/builds and provides a nice user interface.
It uses the GitLab application API to authenticate users.

[GitLab CI Runner](https://github.com/gitlabhq/gitlab-ci-runner) is a pure ruby application which processes builds.
It can be deployed separately and works with GitLab CI through an API.

In order to run tests you need at least 1 __GitLab CI__ instance and 1 __GitLab CI Runner__.
However, for running several builds at the same time you may want to setup more than one __GitLab CI Runner__.

Possible Cases:

* 1 __GitLab CI__ and N __GitLab CI Runner__ instances on same machine
* 1 __GitLab CI__ and N __GitLab CI Runner__ instances on different machines
* 1 __GitLab CI__ and N __GitLab CI Runner__ instances on local machines

![screen](https://gitlab.com/gitlab-org/gitlab-ci/raw/master/app/assets/images/arch.jpg)

For more information see:
[Announcing GitLab CI 3.0](http://blog.gitlab.org/announcing-gitlab-ci-3.0/)
and
[Integrating GitLab CI With GitLab to Enable Distributed Builds](http://blog.gitlab.org/integrating-gitlab-ci-with-gitlab/)

### Installation

* [Installation guide](doc/install/installation.md)

### How to add a new project to GitLab CI

1. Log in the GitLab CI web interface
1. Press the 'Sync now' button
1. Select your project with the 'Add' button
1. Go to the settings page of the project and add a build script (example given below)
1. A new build should become visible on the project page of GitLab CI
1. If the build fails then adjust the build script and press the 'Retry' button on the build page
1. If the build is green you are done, all new commits will be tested and you see the status of merge requests builds within GitLab

### Build script

For your information, the runner runs the line below before it runs the commands in your build script:

    cd /gitlab-ci-runner/tmp/builds && git clone git@gitlab_server_fqdn:group/project.git project-1 && cd project-1 && git checkout master

Build script example:

    bundle install
    bundle exec rake db:create RAILS_ENV=test
    bundle exec rake db:migrate RAILS_ENV=test
    script/run_all_tests

The build command is run from [GitlabCi::Build#command](https://gitlab.com/gitlab-org/gitlab-ci-runner/blob/master/lib/build.rb#L96) and contains the following environmental variables:

    CI_SERVER, CI_SERVER_NAME, CI_SERVER_VERSION, CI_SERVER_REVISION
    CI_BUILD_REF, CI_BUILD_BEFORE_SHA, CI_BUILD_REF_NAME (branch), CI_BUILD_ID

### Documentation

All documentation can be found on [doc.gitlab.com/ci/](http://doc.gitlab.com/ci/).

### Getting help

Please see [Getting help for GitLab](https://www.gitlab.com/getting-help/) on our website for the many options to get help.

repository: mfittko/gitlab-ci

repo_name: mfittko/gitlab-ci


text:
## A/B Testing

A/B testing allows to introduce a change to the website, and understand what impact it is going to have, measured in terms of increased or decreased conversion rate or the rate of reaching a certain touchpoint in the user journey. To be able to tell with certainty that the impact was due to that change, a statistical significance measure is used, which requires quite a lot of data.

### Meta-Lists

[A/B Testing: What are the alternatives to Optimizely?](https://www.quora.com/A-B-Testing-What-are-the-alternatives-to-Optimizely)

### Companies

%TABLE-MACRO Company
![$1 Logo](images/logos/$3), $4, $5
%

```table Company
[
  ["Company", "Tag Line", "Evaluation"],
  [
    "VWO", "https://vwo.com", "vwo.png",
    "**A/B Testing and Conversion Optimization Platform™**<br/>VWO is the all-in-one platform that helps you conduct visitor research, build an optimization roadmap, and run continuous experimentation.",
    "$10m"
  ]
]
```

%~%

repository: demimonde/research

repo_name: demimonde/research


text:
# next-express-example

Next.js with Express website example.

## Usage

### devlop

```bash
$ npm run develop
```

### build

```bash
$ npm run build
```

## License

this repo is released under the [MIT License][licensed-url].

[licensed-image]: https://img.shields.io/badge/license-MIT-blue.svg
[licensed-url]: https://github.com/kenote/next-express-example/blob/master/LICENSE

repository: kenote/next-express-example

repo_name: kenote/next-express-example


text:
---
layout: post
title: "Understanding Closures"
date: "2015-9-2 09:12"
---
Like most things in Javascript, closures can appear more difficult to grok than they actually are.  At its root, a closure is a function within another function. Lets demonstrate this with code.

```
function foo(name) {
    var greeting = "sup";

    return function bar(place){
       console.log(name + " says " + greeting + " " + place);
    };
}

```

Voila! That's a closure. But what makes a closure so special, let alone one of Javascript's most powerful features? The magic lies in the access afforded to the inner bar function.  Not only does the inner function bar have access to its own scope chain (all the variables within its curly bracket), but it also has access to both outer function foo and the global's scope chain.  Whenever you use variables outside your immediate lexical scope you are creating closures.

Again, you may be asking yourself "why is this even important?" What makes closures interesting is that you can use the variables of your outer function even after that outer function has returned. Lets go back to our above code and assign foo to the variable me.

```
var me = foo("Frankie");

me("Earth"); // This will return "Frankie says sup Earth"

```
The Javascript engine knows that in order for the bar function to run at a future time that it will need both the greeting variable and the name parameter within the foo function.  So it allows bar to inspect its environment and closes over the variables that it needs to remember for future use.  The references to these variables are closed in a special data structure that can only be accessed by the Javascript runtime itself.

As one begins to understand closures you may make the mistake in assuming that closures store copies of its outer function's variables. When in fact, they only maintain references to the outer functions variables. The cool factor behind this feature becomes more apparent when the value of the outer function's variable changes before the closure is called. Lets look at some more code to hone in this point.

```
function feelings() {
    var mood = "sad";
    // In this function we are returning an object with some inner functions
    // The inner functions have references to the outer function variables

    return {
        getMood: function() {
            // This function will return the current variable mood even after setMood
            //  function changes it
            return mood;
         },
         setMood: function(feeling) {
             // This function will change the outer variable anytime it is invoked
             mood = feeling;
         }
    }
}

var myMood = feelings(); // the feelings outer function has returned

myMood.getMood() ; // "Sad"
myMood.setMood("Happy"); //Changes the outer function's variable
myMood.getMood(); // "Happy"

```

Closures are one of Javascript's most powerful features. Being able to store references to outer functions that have already returned has many use cases. They can be a convenient way of reducing the the number of parameters passed to a function.  Another practical use case comes from the fact that because only the closure and only the closure has access to the variables within its outer environment you can use closures to achieve private variables and encapsulation in Javascript.  Mostly, it "just works" and functions transparently remember any variables needed for future execution in a convenient way.