text:
# Exception Hierarchy

- [1. Exception Classes - Throwable, Error, Exception & RuntimeException](#1-exception-classes---throwable-error-exception--runtimeexception)
- [2. Checked Exceptions](#2-checked-exceptions)
- [3. Unchecked Exceptions](#3-unchecked-exceptions)
- [4. Errors](#4-errors)

## 1. Exception Classes - Throwable, Error, Exception & RuntimeException

The figure below shows the hierarchy of the Exception classes. The base class for all Exception objects is `java.lang.Throwable`, together with its two subclasses `java.lang.Exception` and `java.lang.Error`.

![](images/Exception_Classes.png)

- The `Error` class describes internal system errors (e.g., `VirtualMachineError`, `LinkageError`) that rarely occur. If such an error occurs, there is little that you can do and the program will be terminated by the Java runtime.
- The `Exception` class describes the error caused by your program (e.g. `FileNotFoundException`, `IOException`). These errors could be caught and handled by your program (e.g., perform an alternate action or do a graceful exit by closing all the files, network and database connections).

As illustrated, the subclasses of `Error` and `RuntimeException` are known as **unchecked exceptions**. These exceptions are not checked by the compiler, and hence, need not be caught or declared to be thrown in your program. This is because there is not much you can do with these exceptions. For example, a "divide by 0" triggers an `ArithmeticException`, array index out-of-bound triggers an `ArrayIndexOutOfBoundException`, which are really **programming logical errors** that shall be been fixed in compiled-time, rather than leaving it to runtime exception handling.

All the other exception are called **checked exceptions**. They are checked by the compiler and must be caught or declared to be thrown.

下面的说法，我觉得很不错：

- An `Error` is a **serious error** that was caused by a **logic error** in the program; for example, running out of memory. Programs should usually not catch Errors. Rather, if an Error occurs, the programmer should find the cause and fix the program.
- An `Exception` is typically an error caused by **circumstances outside the program's control**. For example, if the program tries to read from a file, and the file does not exist, a `FileNotFoundException` will be thrown. These are called **checked exceptions**, because Java requires the program to catch or otherwise deal with them.
- A `RuntimeException` is typically caused by a **logic error in the program**, such as referencing a nonexistent object (a `NullPointerException`) or using an illegal index into an array (an `ArrayIndexOutOfBounds`). Although `RuntimeException` is a subclass of `Exception`, runtime exceptions are **unchecked exceptions**; no special code is required to deal with them.

下面是比较Error和RuntimeException两者之间的区别：

Both `Error` and `RuntimeException` are **unchecked exceptions**, meaning that it indicate **a flaw with the program**, and usually should not be caught. (`NullPointerException`, `IndexOutOfBoundsException`, etc.)

I think the main difference between the two is that `RuntimeException` indicate there is a error with the program, and an `Error` is something that is fatal but out of the program's control. (`OutOfMemorryError`, `ThreadDeath`, etc.)

Therefore **subclassing an `Error` is bad practice** because an error is usually not something that could be fixed by your program at runtime. In your program, should you need to throw something, use an Exception.

---

You've already mentioned the main differences. The Java Language Specification says the same thing in different terms. For `Error`, it states

- `Error` is the superclass of all the exceptions from which ordinary programs are **not ordinarily expected to recover**.

For `RuntimeException`, it states

- The class `RuntimeException` is a direct subclass of `Exception`. `RuntimeException` is the superclass of all the exceptions which may be thrown for many reasons during expression evaluation, but from which **recovery may still be possible**.

---

Throwable is at the top off all exceptions. Underneath Throwable you have Error and Exception. Underneath Exception you have RuntimeException.

Java has two types of exceptions - checked and unchecked. Checked exceptions are enforced by the compiler (you have to declare them in the throws clause and catch them eventually). Unchecked exceptions are not enforced for catching or declaring in throws clause.

(Controversial part of the answer)

Throwable exists so that there is a parent for all exception types. You should never declare that you throw Throwable and never catch it (unless you really really really know what you are doing).

`Error` exists to indicate **issues with the runtime environment**, things that your program probably cannot recover from, such as a badly formatted class file or the VM running out of memory. You should not catch an Error unless you really know what you are doing.

`Exception` exists as the root for **all non-programmer errors** (see `RuntimeException` for the "exception" to this) , such as a file cannot be created because the disk is full. You should not throw, throws, or catch Exception. If you have to catch Exception make sure you know what you are doing.

`RuntimeException` exists to indicate all programmer error, such as going past the end of an array or calling a method on a null object. These are things that you should fix so that they do not throw exceptions - the indicate that **you, the programmer, screwed up the code**. Again, you should not catch these unless you know what you are doing.

---

Why these many types? Instead Java may simply follow a simple design(just try/catch all types) to handle an abnormal condition in a program?

Why? Because they are necessary! Without those 4 classes, handling exceptions by broad category would be impractical.

- How would you catch "all fatal JVM errors" without the Error class?
- How would you catch "all exceptions that are not JVM fatal errors" without the Exception class?
- How would you catch "all unchecked exceptions" without the RuntimeException class?

Why are these many types?

In addition to Stephen C's answer I want to say: **exception handling is a relatively expensive operation in Java**. We should not put all exceptional situation in a try/catch block. **Excessive use of try/catchs may hamper program performance**.

In conclusion, `Exception`s should be handled programmatically whenever possible. On the other hand, we cannot handle `Error`s, so these might be some logical reasons why there are many types of exceptions.

## 2. Checked Exceptions

Checked Exceptions are the exceptions that we can typically foresee and plan ahead in our application. These are also exceptions that the Java Compiler requires us to either **handle-or-declare** when writing code.

The **handle-or-declare** rule refers to our responsibility to either **declare that a method throws an exception up the call stack** - without doing much to prevent it or **handle the exception with our own code**, which typically leads to the recovery of the program from the exceptional condition.

This is the reason why they're called **checked exceptions**. The compiler can detect them before runtime, and you're aware of their potential existence while writing code.

## 3. Unchecked Exceptions

Unchecked Exceptions are the exceptions that typically occur due to human, rather than an environmental error. These exceptions are not checked during compile-time, but at runtime, which is the reason they're also called **Runtime Exceptions**.

They can often be countered by implementing **simple checks** before a segment of code that could potentially be used in a way that forms a runtime exception.处理Exception的最好的办法就是：写代码，要事前多检查，避免事后出异常

## 4. Errors

Errors are the most serious exceptional conditions that you can run into. They are often irrecoverable from and there's no real way to handle them. The only thing we, as developers, can do is optimize the code in hopes that the errors never occur.

Errors can occur due to human and environmental errors. Creating an infinitely recurring method can lead to a `StackOverflowError`, or a memory leak can lead to an `OutOfMemoryError`.


text:
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# C Compiler

Lightweight modular C compiler with code optimization build to support [this](https://github.com/jelic98/c_compiler/blob/master/grammar.txt) context free grammar. Extracted notebooks with detailed code explanation are available [here](https://github.com/jelic98/raf_pp_materials).

## Usage

1. Compile and run example C code
```bash
python3 main.py res/testX.c gen/testX.py
```
where X is chosen from [1-10]

2. Generated code and AST are stored in _out_ directory

## Future work

* Error handling
* Multidimensional arrays
* Unary increment/decrement operators
* Switch statement
* Additional stdlib functions

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
## Description of changes

## Motivation and Context

## Testing

### Testing Environment:
- OS: **[Insert OS]**
- Python: **[Insert Python Version]**
- IDE: **[Insert IDE]**

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
- [ ] My code follows the code style of this project.
- [ ] I have tested this code on real hardware.
- [ ] I have updated the documentation accordingly.

license: MIT

gha_language: Python

gha_license_id: MIT


text:
# `midot` basic dotfiles
By [Jason Yao](https://github.com/JasonYao)

## Description
This is a set of basic dotfiles built using
[midot](https://github.com/JasonYao/midot)'s
api, and is in compliance with `midot`'s
interface.

This repo's primary purpose is to showcase
how you can quickly build your own set of
dotfiles, both from using `midot`'s API,
and by conforming to `midot`'s interface.

## Overview
```
/
└── bin/
    ├── uninstall (dotfiles cleanup script)
    └── upgrade (dotfiles upgrade script)
```

## Setup
You can download this base set of dotfiles
via `midot generate`

## Notes
In this repo, we highlight using
`midot`'s API whenever possible
so show how to leverage it to build
your dotfiles faster and (subjectively)
better.

## License
This repo is licensed under the terms of the MIT license,
a copy of which may be found [here](LICENSE)

repository: JasonYao/midot-basic

repo_name: JasonYao/midot-basic


text:
# NamogooIBPSDK

[![CI Status](https://img.shields.io/travis/mngKali/NamogooIBPSDK.svg?style=flat)](https://travis-ci.org/mngKali/NamogooIBPSDK)
[![Version](https://img.shields.io/cocoapods/v/NamogooIBPSDK.svg?style=flat)](https://cocoapods.org/pods/NamogooIBPSDK)
[![License](https://img.shields.io/cocoapods/l/NamogooIBPSDK.svg?style=flat)](https://cocoapods.org/pods/NamogooIBPSDK)
[![Platform](https://img.shields.io/cocoapods/p/NamogooIBPSDK.svg?style=flat)](https://cocoapods.org/pods/NamogooIBPSDK)

## Example

To run the example project, download or clone the repo, and run the IBPTestStoreApp.xcodeproj file.

## Requirements
Swift 5.1+
Xcode 11+
Full Objective C support.

## Installation

NamogooIBPSDK is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod 'NamogooIBPSDK'
```
Don't forget to run  `pod install` in your parent directory.

## Author

Namogoo Platform<EMAIL_ADDRESS>
## License

NamogooIBPSDK is available under the MIT license. See the LICENSE file for more info.

repository: namogoo/namogoo-ibp-ios-sdk

repo_name: namogoo/namogoo-ibp-ios-sdk


text:
#The nature, certainty and evidence of true Christianity. In a letter from a gentlewoman in New-England, to another her dear friend, in great darkness, doubt and concern of a religious nature. : I Cor. 1. 26--31. : N.B. Tho' this letter was wrote in great privacy from one friend to another; yet on representing that by allowing it to be printed, it wou'd probably reach to many others in the like afflicted case, and by the grace of God be very helpful to them; the writer was at length prevailed on to suffer it--provided her name and place of abode remain concealed.#

##Osborn, Sarah, 1714-1796.##
The nature, certainty and evidence of true Christianity. In a letter from a gentlewoman in New-England, to another her dear friend, in great darkness, doubt and concern of a religious nature. : I Cor. 1. 26--31. : N.B. Tho' this letter was wrote in great privacy from one friend to another; yet on representing that by allowing it to be printed, it wou'd probably reach to many others in the like afflicted case, and by the grace of God be very helpful to them; the writer was at length prevailed on to suffer it--provided her name and place of abode remain concealed.
Osborn, Sarah, 1714-1796.

##General Summary##

**Links**

[TCP catalogue](http://www.ota.ox.ac.uk/tcp/)  •
[HTML](http://tei.it.ox.ac.uk/tcp/Texts-HTML/free/N05/N05930.html)  •
[EPUB](http://tei.it.ox.ac.uk/tcp/Texts-EPUB/free/N05/N05930.epub)

**Availability**

This keyboarded and encoded edition of the
	       work described above is co-owned by the institutions
	       providing financial support to the Early English Books
	       Online Text Creation Partnership. This Phase I text is
	       available for reuse, according to the terms of Creative
	       Commons 0 1.0 Universal. The text can be copied,
	       modified, distributed and performed, even for
	       commercial purposes, all without asking permission.

**Major revisions**

1. __2007-03__ __TCP__ *Assigned for keying and markup*
1. __2007-03__ __SPi Global (Manila)__ *Keyed and coded from Readex/Newsbank page images*
1. __2007-10__ __Alexis Jakobson__ *Sampled and proofread*
1. __2007-10__ __Alexis Jakobson__ *Text and markup reviewed and edited*
1. __2008-02__ __pfs.__ *Batch review (QC) and XML conversion*

##Content Summary##

#####Front#####

#####Body#####

1. COPY of a LETTER from a Gentlewoman in NEW-ENGLAND to another Gentlewoman her Friend, great Concern of Soul.

**Types of content**

  * Oh, Mr. Jourdain, there is **prose** in there!

There are 15 **ommitted** fragments!
 @__reason__ (15) : illegible (15)  •  @__resp__ (15) : #PDCC (15)  •  @__extent__ (15) : 1 word (9), 3 letters (2), 2 letters (2), 1 letter (1), 4 letters (1)

**Character listing**

|Text|string(s)|codepoint(s)|
|---|---|---|
|Latin Extended-A|ſ|383|
|General Punctuation|—•|8212 8226|
|Geometric Shapes|◊▪|9674 9642|
|CJKSymbolsandPunctuation|〈〉|12296 12297|

##Tag Usage Summary##

###Header Tag Usage###

|No|element name|occ|attributes|
|---|---|---|---|
|1.|__author__|2||
|2.|__availability__|1||
|3.|__biblFull__|1||
|4.|__change__|5||
|5.|__date__|7| @__when__ (1) : 2008-09 (1)|
|6.|__editorialDecl__|1||
|7.|__extent__|2||
|8.|__idno__|6| @__type__ (6) : DLPS (1), TCP (1), STC (1), NOTIS (1), IMAGE-SET (1), EVANS-CITATION (1)|
|9.|__keywords__|1| @__scheme__ (1) : http://authorities.loc.gov/ (1)|
|10.|__label__|5||
|11.|__langUsage__|1||
|12.|__language__|1| @__ident__ (1) : eng (1)|
|13.|__listPrefixDef__|1||
|14.|__note__|6||
|15.|__notesStmt__|2||
|16.|__p__|11||
|17.|__prefixDef__|2| @__ident__ (2) : tcp (1), char (1)  •  @__matchPattern__ (2) : ([0-9\-]+):([0-9IVX]+) (1), (.+) (1)  •  @__replacementPattern__ (2) : http://eebo.chadwyck.com/downloadtiff?vid=$1&page=$2 (1), https://raw.githubusercontent.com/textcreationpartnership/Texts/master/tcpchars.xml#$1 (1)|
|18.|__projectDesc__|1||
|19.|__pubPlace__|2||
|20.|__publicationStmt__|2||
|21.|__publisher__|2||
|22.|__ref__|2| @__target__ (2) : https://creativecommons.org/publicdomain/zero/1.0/ (1), http://www.textcreationpartnership.org/docs/. (1)|
|23.|__seriesStmt__|1||
|24.|__sourceDesc__|1||
|25.|__term__|1||
|26.|__textClass__|1||
|27.|__title__|3||
|28.|__titleStmt__|2||

###Text Tag Usage###

|No|element name|occ|attributes|
|---|---|---|---|
|1.|__date__|1||
|2.|__dateline__|1||
|3.|__desc__|15||
|4.|__div__|2| @__type__ (2) : title_page (1), letter (1)|
|5.|__g__|63| @__ref__ (63) : char:EOLunhyphen (1), char:EOLhyphen (60), char:punc (2)|
|6.|__gap__|15| @__reason__ (15) : illegible (15)  •  @__resp__ (15) : #PDCC (15)  •  @__extent__ (15) : 1 word (9), 3 letters (2), 2 letters (2), 1 letter (1), 4 letters (1)|
|7.|__head__|1||
|8.|__hi__|279||
|9.|__opener__|1||
|10.|__p__|23||
|11.|__pb__|15| @__facs__ (15) : tcp:007523_0001_102BA01CB2549138 (1), tcp:007523_0002_102BA01EEB9D2558 (1), tcp:007523_0003_102BA02111D88AE0 (1), tcp:007523_0004_102BA022FA304D20 (1), tcp:007523_0005_102BA0250619D808 (1), tcp:007523_0006_102BA026F107C5E8 (1), tcp:007523_0007_102BA02913E1B8C0 (1), tcp:007523_0008_102BA02ADF376CB0 (1), tcp:007523_0009_102BA02E20104080 (1), tcp:007523_0010_102BA02FB3E72BA0 (1), tcp:007523_0011_102BA032996CBE48 (1), tcp:007523_0012_102BA034B3834950 (1), tcp:007523_0013_102BA0378F0BF1A8 (1), tcp:007523_0014_102BA03AE71704E0 (1), tcp:007523_0015_102BA03D977E4458 (1)  •  @__rendition__ (2) : simple:additions (2)  •  @__n__ (14) : 2 (1), 3 (1), 4 (1), 5 (1), 6 (1), 7 (1), 8 (1), 9 (1), 10 (1), 11 (1), 12 (1), 13 (1), 14 (1), 15 (1)|
|12.|__salute__|1||


text:
## Hi, I'm Tweet Monkey

Tweet Monkey is a hilariously simple maker project.

Many of the maker projects you'll find online are intended to flex the muscles of a given maker or technology and end up being rather complicated and difficult to replicate.

Tweet Monkey is an attempt to create a project that crosses a number of maker disciplines while remaining conceptually simple. It's easy to acquire the needed materials, and hopefully when you've built a Tweet Monkey, you'll have a good grasp on a number of concepts.

Tweet Monkey monitors Twitter for tweets that contain the hashtag #tweetmonkey. When someone (anyone in the world) tweets with #tweetmonkey, your Tweet Monkey will animate (clang his symbols, nod his head, and squawk) for a couple of seconds.

This project takes advantage of Node.js which makes accessing Twitter a breeze. It's designed such that the work of looking for tweets is offloaded to Twitter - afterall, they know quite well how to search for tweets and they have a few servers to do the work. Tweet Monkey just hangs out waiting for Twitter to push down notification.

The entirety of the code for Tweet Monkey easily fits on a single page. It's very short. I like short code that expresses the essence of what I'm trying to do.

I encourage you to make a Tweet Monkey yourself. The effort is small and you'll get a fun introduction to maker projects that use software and electronics together.

[Read the docs](docs/readme.md) to get started.

repository: codefoster/tweetmonkey

repo_name: codefoster/tweetmonkey


text:
---
layout: post
title:  "Grain Growth Questionable Results"
subtitle: "What I would like to propose"
author: David Brough
categories: post
---
{% include latex.html %}

# Grain Growth Questionable Results

This is an update on the grain growth project for the data challenge submission.

Recall we have four classes:

1. Banded
2. Rolling
3. Random
4. Uniform

While attempting to the build the process-structure linkage between the input (autocorrelation of pins to pins) and output (chord length distributions) we noticed that two classes were clustering well (banded and random), whereas the other two do not show any discernible trend the current available data (rolling and uniform).

## Recovering Chord Length Distribution from PCA
We can recover chord length distributions from our model using an inverse transform on the PCA data. This works for "normal" looking distributions as well as classes with "non-normal" chord length distributions.

**Original.**

![](https://farm2.staticflickr.com/1447/26013245615_3a9fdc7b60_o_d.png)

**Recover.**

![](https://farm2.staticflickr.com/1654/25712687770_f28a51751f_o_d.png)

## Scree Plots of PCA
The scree plots for both the input and output of our model capture much of the variance in a reasonable amount of PC values.

**Input.**

![](https://farm2.staticflickr.com/1481/25918360941_5a2d2e155a_o_d.png)

**Output.**

![](https://farm2.staticflickr.com/1579/25380523784_3060fddf44_o_d.png)

## PCA of All Samples
Here are the plots of PCA of all four classes color coordinated.

**Input.**

![](https://farm2.staticflickr.com/1664/25712687660_e450c9c391_o_d.png)

**Output.**

![](https://farm2.staticflickr.com/1530/25384486213_2663536f8c_o_d.png)

Since the green and blue paths above are hard to see we can just plot them to zoom in and get a better spatial representation. Note: the green and orange have no relation to the green orange above, the two colors are simply to show class separation.

**Input.**

![](https://farm2.staticflickr.com/1490/25712687350_2b518a2875_o_d.png)

**Output.**

![](https://farm2.staticflickr.com/1515/25987325076_d7b976a610_o_d.png)

# PCA of Only Banded and Random

We tried to build a model with these two PCA spaces but were having a hard time obtaining any reasonable results. We tried to throw out rolling and uniform classes and recomputing PCA to see if they were affecting the model.

Notice the more clear/distinct paths and wider separation in the new PCA basis when the rolling and uniform data is not present.

**Input.**

![](https://farm2.staticflickr.com/1593/25892452272_c7bcda2125_o_d.png)
![](https://farm2.staticflickr.com/1716/25892452222_cca10a75da_o_d.png)

**Output.**

![](https://farm2.staticflickr.com/1537/25987325296_4fdd1eaebb_o_d.png)
![](https://farm2.staticflickr.com/1481/25380523294_d570511c58_o_d.png)

## Best Model
We obtained our best model from training on banded and random only in the master PCA model. We used standard 80%/20% test/train split.

```
Order of Polynomial: 3
Number of Components: 2
MSE: -5.18890555335e-05
R^2: 0.571955314915
```

Here is just one example of a chord length distribution in the test data and its corresponding predication from our model. We expect the curve to be smoother and retain a similar shape, but are unhappy with the peak magnitude discrepancy.

**Original.**

![](https://farm2.staticflickr.com/1544/25892451732_8beb39aa2c_o_d.png)

**Prediction.**

![](https://farm2.staticflickr.com/1682/25892451662_ab70e7bfeb_o_d.png)

branch_name: refs/heads/gh-pages

extension: markdown

gha_language: JavaScript


text:
(Very) WIP spell finder/manager for Pathfinder 2e.

Desktop and web versions:

* Web uses React for frontend, Ktor + Postgres w/ Exposed for backend.
* Desktop uses JetBrains Compose for UI, H2 w/ Exposed for DB

Database access, buisness logic, and data structures is shared using Kotlin multiplatform and multi-module projects.

Web is currently non-functional due to non-updated compiler plugins.

Desktop works if you have the DB. It will eventually update itself from the web version's hosted DB, but atm you have to build it yourself using
[Load.kt](common/src/jvmMain/kotlin/com/rnett/spellbook/load/Load.kt).

repository: rnett/spellbook

branch_name: refs/heads/main

repo_name: rnett/spellbook


text:
@typedef {function()} can-symbol/symbols/getOwnKeys can.getOwnKeys
@parent can-symbol/symbols/shape
@description List which keys an object has of its own (not other objects on the prototype chain).

@signature `@@can.getOwnKeys()`

Return all string keys on an object, including those whose corresponding properties are defined not to be enumerable.

```
var shapeless = {};

// Nothing enumerable in a shapeless object
shapeless[canSymbol.for('can.getOwnKeys')] = function() { return []; }

var thingsInMyEar = {};
Object.setPrototypeOf(thingsInMyEar, {
	"banana": {
		peeled: false
	}
});

thingsInMyEar[canSymbol('can.getOwnEnumerableKeys')] = function() {
	return Object.getOwnPropertyNames(this)
		.concat(["banana"]);  // There's always a banana in my ear
};

```

@this {Object} an object with named properties
@return {Array} an array of Strings representing the object's string keys.

repository: canjs/can-symbol

repo_name: canjs/can-symbol


text:
# Dimerospora Th. Fr. GENUS

#### Status
SYNONYM

#### According to
Index Fungorum

#### Published in
Lich. Arctoi 97 (1860)

#### Original name
Dimerospora Th. Fr.

### Remarks
null

repository: mdoering/backbone

repo_name: mdoering/backbone


text:
# Dynamic Metric Alerts

## Static Alerts
You pick a metric (or more), set the threshold(s) to specific values and alert will trigger based on operator checked.

## Dynamic Alert
You pick a metric (or more), set "lookback" periods, set number of violations and set operator.  The alert will trigger if the number of violations is met.  (Pretty Cool)

## Multiple Dimensions
You can monitor multiple instances with same alert rule.  In this case you can define each instance individually OR you can define instance as *

## Alerts at Scale
You can set up one alert that can be attached to multiple resources (of the same type)

repository: Mykrowave/azure-architect-playbook

repo_name: Mykrowave/azure-architect-playbook


text:
# Curse scraper

This utility provides near real-time updates to a specified discord channel.
Before running the program, install discord.py through pip3 (sudo apt-get install pip3/sudo yum install python3 python3-wheel)

### Setup
#### Bot
The first time that the program is run, it will generate a blank config file and exit.
You must fill in both the discord token and the channel ID before the program will function correctly.
Also, if there is no svinfo file detected, it will automatically create one that watches over FTB Infinity Evolved.

#### Packs to watch
In order to tell the program what to look for, you must edit your svinfo.txt file accordingly. The current way of modifying this file is to
find the ID (if it has one), latest file version and curse identifier.

##### Obtaining details for the svinfo file
Go to the curseforge project page and take the last part of the URL. From there, go to https://api.cfwidget.com/ and append the URL you took
to the end of the link. (for example, with ATM3 you take /minecraft/modpacks/all-the-mods-3 from
https://www.curseforge.com/minecraft/modpacks/all-the-mods-3 and add it onto the end of the URL).
**IF THE URL REDIRECTS, USE THE NEW ONE!**

From there, you will be presented with a JSON output. Depending on how the URL is presented to you at the top of the output, you will need
to take certain steps.

If your URL redirects to a project page (like ATM3):
- Disregard the ID and take the last part of the URL (all-the-mods-3).
- Find the first name value in files (this is your current version of the pack) and note down the **exact** value.
From there, you can edit your svinfo file.

If your URL redirects to either a modpacks/minecraft or minecraft/modpacks page (this will be most FTB owned packs):
- Take note of the ID at the top of the page
- Find the first name value in files (this is your current version of the pack) and note down the **exact** value.
- Look at the URL on the second line and take note of the very last part of the URL (the same you used to get to the API page)
From there, you can edit your svinfo file.

##### Editing your svinfo file
- WIP -


text:
MIDIM - MIDI Markov
===================

MIDIM follows in the footsteps of dozens of other projects crossing MIDI music
with Markov Chain-based MIDI output.

But this one... is in C#!

Eventually I hope to wrap this as a Unity plugin so others can generate music
on the fly, but first things first.

Currently, this makes use of UnitySynth, found here:
http://forum.unity3d.com/threads/unitysynth-full-xplatform-midi-synth.130104/

For this to work in Unity, PlayerSettings>Other Settings>Api Compatibility Level
must be set to .NET 2.0, as opposed to .NET 2.0 Subset.

MIT License

Credits:
http://forum.unity3d.com/threads/unitysynth-full-xplatform-midi-synth.130104/
I believe that UnitySynth is itself MIT License, but have so far not been able
to confirm.

And via that, further credits:
http://csharpsynthproject.codeplex.com/license

repository: sonicviz/MIDIM

repo_name: sonicviz/MIDIM


text:
# Scripts to get contribution scores from ChromBPNet models

The scripts in this folder are used to do get sequence contribution scores for the chrombpnet models. These scripts require the `shap` installation. Chrombpnet models have two heads - (1) profile head (to predict the shape of a profile) and (2) counts head  (to predict the total counts in a profile). The scripts can provide sequence contribution scores for both the heads.

## Usage

```
chrombpne_deepshap -g [genome_fasta] -r [regions] -m [model_h5] -o [output_prefix] -d [debug_chr] -p [profile_or_counts]
```

## Example Usage

```
chrombpnet_deepshap -g /path/to/genome.fasta -r /path/to/regions.bed -m /path/to/model.h5 -o /path/to/output_dir/output_prefix -p counts profiles
```

## Input Format
- genome_fasta: Reference geneome fasta.
- regions: Must be a narrowPeak file, and must have 10 columns, with values minimally for chr, start, end and summit (10th column). Every region is centered at start + summit internally, across all regions.
- model_h5: Model in hdf5 format.
- output_prefix: Output prefix path and name to use. See Output format section below to understand how this is used.
- profile_or_counts: Provide either only `profile` or `counts` or both with space speration. The default setting for this uses both `profile` and `counts`. This argument is used to indicate the output head (counts/profiles or both) to use for getting contribution scores.
- debug_chr: This argument is optional and can be used for debugging if needed. Mention a chromsome name to get contribution scores only for regions in that chromosome. The chromsome name should be present in the first column of the `regions` bed.

## Output Format

The following two files are created using the `output_prefix` as prefix for the output when both `profile_or_counts` includes both `profile` and `counts`. If only one of the option is used, only one of the files is generated. Note that prefix can include a directory path and name for the output file.

- `output_prefix`.profile_scores.h5: A h5 file containing a dictionary with contribution scores for the profile head of the chrombpnet model. The dictionary consists of the following keys `raw`, `shap` and `projected_shap`. The values of each of these keys are explained below. All the values have the shape `(L,4,inputlen)` where  L is the number of inputs given in `regions` bed file and `inputlen` is inferred from the input length of the `model_h5`.
    - `raw` key consists of  one hot encoding of a sequence from the `regions` bed file.
    - `shap` key consists of hypothetical contribution scores obtained from doing deepshap. These values will be used in the MODISCO pipeline (for de-novo motif discovery) next.
    - `projected_shap` key consists of values obtained by multiplying `shap` values with `raw` values. These values will be used in building browser tracks.

- `output_prefix`.count_scores.h5: A h5 file containing a dictionary with contribution scores for the count head of the chrombpnet model. Has similar structure as the `output_prefix`.profile_scores.h5.

- `output_prefix`.interpreted_regions.bed: A bed file with regions used for interpretations. The script filters regions whose resulting sequences dont have the same length as `input_len` inferred from the model.  This bed file might have regions fewer than `regions` provided as input.

repository: kundajelab/chrombpnet

gha_language: Jupyter Notebook

repo_name: kundajelab/chrombpnet


text:
---
layout: default
---

# 1997-06-10 - Macht frei or make fries?

## Header Data

From: Tim May<EMAIL_ADDRESS>To<EMAIL_ADDRESS>Message Hash: 4de5705de921ad545b944dde23846159b7eed65553c024a513f12b08664a222e

Message ID<EMAIL_ADDRESS>Reply To<EMAIL_ADDRESS>UTC Datetime: 1997-06-10 17:13:09 UTC

Raw Date: Wed, 11 Jun 1997 01:13:09 +0800

## Raw message

```
{% raw  %}From: Tim May<EMAIL_ADDRESS>Date: Wed, 11 Jun 1997 01:13:09 +0800
To<EMAIL_ADDRESS>Subject: Macht frei or make fries?
In-Reply-To<EMAIL_ADDRESS>Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

At 9:34 AM -0700 6/10/97, Alan wrote:
>On Tue, 10 Jun 1997, Anonymous wrote:
>
>> The possibility of Microsoft killing their competition's engineers is
>> somewhat more realistic, although lately they've been hiring a lot of
>> them instead, so maybe they don't want to kill them. :)
>
>"Ve have veys ov making you vork for us!"
>
>Adds a new twist to hiring practices...  Work for us or not at all.
>
>"Microsoft Mach Frie!"

I don't think MS is using the Mach kernel...

Maybe you meant "Microsoft macht frei!"

Or "McDonald's Makes Fries!"

Or, speaking of the Mach kernel,

Kernel Jerry Sanders finger-lickin' good tasty bytes.

--Klaus! von Future Prime

There's something wrong when I'm a felon under an increasing number of laws.
Only one response to the key grabbers is warranted: "Death to Tyrants!"
---------:---------:---------:---------:---------:---------:---------:----
Timothy C. May              | Crypto Anarchy: encryption, digital money,
<EMAIL_ADDRESS>408-728-0152 | anonymous networks, digital pseudonyms, zero
W.A.S.T.E.: Corralitos, CA  | knowledge, reputations, information markets,
Higher Power: 2^1398269     | black markets, collapse of governments.
"National borders aren't even speed bumps on the information superhighway."

{% endraw %}
```

## Thread

+ Return to [June 1997](/archive/1997/06)

+ Return to "[Alan <alano@teleport.com>](/authors/alan_alano_at_teleport_com_)"
+ Return to "[Bill Stewart <stewarts@ix.netcom.com>](/authors/bill_stewart_stewarts_at_ix_netcom_com_)"
+ Return to "[Declan McCullagh <declan@pathfinder.com>](/authors/declan_mccullagh_declan_at_pathfinder_com_)"
+ Return to "[Declan McCullagh <declan@well.com>](/authors/declan_mccullagh_declan_at_well_com_)"
+ Return to "[jamesd@echeque.com](/authors/jamesd_at_echeque_com)"
+ Return to "["Mark M." <markm@voicenet.com>](/authors/mark_m__markm_at_voicenet_com_)"
+ Return to<EMAIL_ADDRESS>(Anonymous)](/authors/nobody_at_replay_com_anonymous_)"
+ Return to "[Secret Squirrel <nobody@secret.squirrel.owl.de>](/authors/secret_squirrel_nobody_at_secret_squirrel_owl_de_)"
+ Return to "[Tim May <tcmay@got.net>](/authors/tim_may_tcmay_at_got_net_)"
+ Return to "["Vladimir Z. Nuri" <vznuri@netcom.com>](/authors/vladimir_z_nuri_vznuri_at_netcom_com_)"
+ Return to "[Wei Dai <weidai@eskimo.com>](/authors/wei_dai_weidai_at_eskimo_com_)"
+ Return to "["William H. Geiger III" <whgiii@amaranth.com>](/authors/william_h_geiger_iii_whgiii_at_amaranth_com_)"

+ 1997-06-08 (Mon, 9 Jun 1997 02:15:42 +0800) - [Re: FCPUNX:McVeigh](/archive/1997/06/441a9b95f490dfa7f62eee79d7fb0188b430f138ecd8fb22849a04d2a6219213) -<EMAIL_ADDRESS>  + 1997-06-09 (Mon, 9 Jun 1997 23:43:00 +0800) - [Assassination Politics as revenge fantasy (Re: FCPUNX:McVeigh)](/archive/1997/06/1e3913460cdc22d6267c55891ecfaa2e9a35db02c51d0f355ba4ec18349619b2) - _Declan McCullagh<EMAIL_ADDRESS>    + 1997-06-09 (Tue, 10 Jun 1997 00:49:36 +0800) - [Re: Assassination Politics as revenge fantasy (Re: FCPUNX:McVeigh)](/archive/1997/06/38675c46581339486714a6a0181f252bb69ebfe7ed7226cc4cdcf2881a425145) - _Alan<EMAIL_ADDRESS>    + 1997-06-09 (Tue, 10 Jun 1997 05:41:10 +0800) - [Re: Assassination Politics as revenge fantasy (Re: FCPUNX:McVeigh)](/archive/1997/06/80bce44dd4486d8e4dc18c25409fbc91042d2db5cf3c1cfdacc678eff95bce33) - _Declan McCullagh<EMAIL_ADDRESS>    + 1997-06-10 (Tue, 10 Jun 1997 19:09:33 +0800) - [NoneRe: Assassination Politics as revenge fantasy (Re: FCPUNX:McVeigh)](/archive/1997/06/e63343ccfec2bdec90c77377ec56437eaba8bae2e7ada39b90d5c78897224a65) -<EMAIL_ADDRESS>(Anonymous)_
      + 1997-06-10 (Wed, 11 Jun 1997 00:43:58 +0800) - [Re: None](/archive/1997/06/24ef3a90eeb795cbafd0b228fe47401eec4058c374a8bdc94d9db0ec426699bb) - _Alan<EMAIL_ADDRESS>      + 1997-06-10 (Wed, 11 Jun 1997 01:13:09 +0800) - Macht frei or make fries? - _Tim May<EMAIL_ADDRESS>      + 1997-06-10 (Wed, 11 Jun 1997 07:55:16 +0800) - [Re: None](/archive/1997/06/eecf1bd3d7e77745a60d5097ca0d5dc84951d47074b4e772882d59e713238558) - _"William H. Geiger III"<EMAIL_ADDRESS>    + 1997-06-10 (Wed, 11 Jun 1997 00:52:24 +0800) - [Untraceable Contract Killings](/archive/1997/06/ac3c52f51748df9f188045c8e15997d9dc79e85f82da9fec750aaaa9bbb4a445) - _Tim May<EMAIL_ADDRESS>      + 1997-06-11 (Wed, 11 Jun 1997 08:54:38 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/6b79d548d4143324250f5bdc28e7f66dfea77bb10240e07befe20fa1cde1ace2) - _"Vladimir Z. Nuri"<EMAIL_ADDRESS>      + 1997-06-11 (Wed, 11 Jun 1997 08:57:11 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/d9c76b7ac28d3d8fffbd74953a5e899fd15b6602bac8e724df718ffdf8781c59) - _Wei Dai<EMAIL_ADDRESS>        + 1997-06-13 (Sat, 14 Jun 1997 01:37:29 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/4c4515434645794fd049bd057e0fd268733022ace4ecf4ec639a2930b8aeb41c) - _Tim May<EMAIL_ADDRESS>      + 1997-06-11 (Wed, 11 Jun 1997 22:57:56 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/f958605d677475703af380778bdc37d4155a41799b83526afbee9159127541a8) - _Secret Squirrel<EMAIL_ADDRESS>      + 1997-06-11 (Thu, 12 Jun 1997 01:04:19 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/7444fdf494a3f295f4e59354753eaaed6ed1147d19d4faa64aafc9df1ebd41bf) - _Bill Stewart<EMAIL_ADDRESS>        + 1997-06-11 (Thu, 12 Jun 1997 06:11:44 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/4790f7d161d42df0089c8283079e06cf97b24ef6240af3d2639f2a39ce16eaf6) - _"Mark M."<EMAIL_ADDRESS>    + 1997-06-10 (Wed, 11 Jun 1997 05:49:26 +0800) - [Re: Untraceable Contract Killings](/archive/1997/06/406e8c02e860ccfd46b76c4b00309e86c472a48b6b1f6130a530d63aff0b7002) -<EMAIL_ADDRESS>(Anonymous)_


text:
# React Router Hash Link

***Note that this is for React Router v4/5, for v2/3 see [this solution](https://github.com/rafgraph/react-router-hash-link/tree/react-router-v2/3).***

![npm](https://img.shields.io/npm/dm/react-router-hash-link?label=npm)

[Demo website](https://react-router-hash-link.rafgraph.dev/) (code on the [`gh-pages` branch](https://github.com/rafgraph/react-router-hash-link/tree/gh-pages))

---

This is a solution to [React Router's issue of not scrolling to `#hash-fragments`](https://github.com/reactjs/react-router/issues/394#issuecomment-220221604) when using the `<Link>` component to navigate.

When you click on a link created with `react-router-hash-link` it will scroll to the element on the page with the `id` that matches the `#hash-fragment` in the link. This will also work for elements that are created after an asynchronous data load. Note that you must use React Router's `BrowserRouter` for this to work.

```shell
$ yarn add react-router-hash-link
# OR
$ npm install --save react-router-hash-link
```

### `<HashLink>`
```javascript
// In YourComponent.js
...
import { HashLink } from 'react-router-hash-link';
...
// Use it just like a RRv4/5 <Link> (to can be a string or an object, see RRv4/5 api for details)
<HashLink to="/some/path#with-hash-fragment">Link to Hash Fragment</HashLink>
```

### `<NavHashLink>`
```javascript
// In YourComponent.js
...
import { NavHashLink } from 'react-router-hash-link';
...
// Use it just like a RRv4/5 <NavLink> (see RRv4/5 api for details)
// It will be active only if both the path and hash fragment match
<NavHashLink
  to="/some/path#with-hash-fragment"
  activeClassName="selected"
  activeStyle={{ color: 'red' }}
  // etc...
>Link to Hash Fragment</NavHashLink>
```

## Scrolling API
### `smooth: boolean`
- Smooth scroll to the element
- React Router Hash Link uses the native Element method `element.scrollIntoView()` for scrolling, and when the `smooth` prop is present it will call it with the smooth option, `element.scrollIntoView({ behavior: 'smooth' })`
- Note that not all browsers have implemented options for `scrollIntoView` - see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) and [Can I Use](https://caniuse.com/#feat=scrollintoview) - there is also a browser [polyfill for smooth scrolling](https://github.com/iamdustan/smoothscroll) which you can install separately so `smooth` will work in all browsers
```js
import { HashLink } from 'react-router-hash-link';
<HashLink smooth to="/path#hash">Link to Hash Fragment</HashLink>
```

### `scroll: function`
- Custom scroll function called with the element to scroll to, e.g. `const myScrollFn = element => {...}`
- This allows you to do things like scroll with offset, use a specific smooth scrolling library, or pass in your own options to `scrollIntoView`
```js
import { HashLink } from 'react-router-hash-link';
<HashLink
    to="/path#hash"
    scroll={el => el.scrollIntoView({ behavior: 'instant', block: 'end' })}
>Link to Hash Fragment</HashLink>
```

### Scroll to top of page
- To scroll to the top of the page set the hash fragment to `#` (empty) or `#top`
- This is inline with the [HTML spec](https://html.spec.whatwg.org/multipage/browsing-the-web.html#target-element), also see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Linking_to_an_element_on_the_same_page)
```js
import { HashLink } from 'react-router-hash-link';
<HashLink to="/path#top">Link to Top of Page</HashLink>
// or
<HashLink to="#top">Link to Top of Page</HashLink>
```

### Scroll with offset
- To scroll with offset use a custom scroll function, one way of doing this can be found [here](https://github.com/rafgraph/react-router-hash-link/issues/25#issuecomment-536688104)

### `elementId: string`
- Scroll to the element with matching id
- Used instead of providing a hash fragment as part of the `to` prop, if both are present then the `elementId` will override the `to` prop's hash fragment
- Note that it is generally recommended to use the `to` prop's hash fragment instead of the `elementId`

## Custom `Link`

The exported components are wrapped versions of the `Link` and `NavLink` exports of react-router-dom. In some cases you may need to provide a custom `Link` implementation.

For example, the gatsby static site generator requires you to use its implementation of `Link`. You can wrap it with the `genericHashLink` function of this package.

```jsx
import { genericHashLink } from 'react-router-hash-link';
import GatsbyLink from 'gatsby-link';

const MyHashLink = genericHashLink(GatsbyLink);

const MyComponent = () => (
  <div>
    The default wont work for you?
    <MyHashLink to="/faq#how-to-use-custom-link">No problem!</MyHashLink>
  </div>
);
```


text:
# editorconfig-textadept
[EditorConfig](http://editorconfig.org/) plugin for [Textadept](http://foicica.com/textadept/).

# THIS PROJECT IS NO LONGER MAINTAINED

Use https://github.com/editorconfig/editorconfig-textadept instead.

### Installation
* Clone this repository.
* Copy or symlink the editorconfig.lua file into your ".textadept" folder.
* add ```require "editorconfig"``` to your ".textadept/init.lua" file.

### What works
* *, **, ?, [], and [!] style section headers
* Tests
	* indentation tests
	* end\_of\_line tests
* Properties
	* indent\_style
	* indent\_size
	* tab\_width
	* end\_of\_line
	* root

### What doesn't work
* {}-style section headers
* Tests
	* insert\_final\_newline tests
	* trim\_trailing\_whitespace tests
	* charset tests
* Properties
	* trim\_trailing\_whitespace
	* charset
	* insert\_final\_newline

repository: Hackerpilot/editorconfig-textadept

repo_name: Hackerpilot/editorconfig-textadept


text:
# Symlink Resolver
This tool allows to replace symbolic links by real files in given directory and revert the changes back to symlinks. All the magic in a simple cli command!

### Installation
```
npm install symlink-resolver --save-dev
```
[Node.js](https://nodejs.org/) v6.4+ and [POSIX](https://en.wikipedia.org/wiki/POSIX#POSIX-certified)-standarized operating system are required.

To your `package.json` `scripts` section add the following rule:
```
"scripts": {
    "symlink-resolver": "symlink-resolver",
}
```

## Basic Usage
For fast usage you can simply run:
+ `npm run symlink-resolver build ./symlinks/path` to **replace** symlinks by real files in ./symlinks/path
+ `npm run symlink-resolver clear ./symlinks/path` to **restore** all symlinks

First command will create `./symlinks/path/.symlinks.json` file which contains changes that have been made in this directory. It will be removed by the second command, however you can still add to your `.gitignore` the following rule: `.symlinks.json`

##### How to create a symlink?
Use `ln -s target source` command, i.e.:
```
ln -s ../../source/path/linked-dir ./project/src/linked-dir
```

### Advanced usage
If you need this feature to make a build, then I strongly recommend to automatize your building process:
```
"scripts": {
        "symlink-resolver": "symlink-resolver",
        "prebuild": "npm run symlink-resolver build ./symlinks/path",
        "postbuild": "npm run symlink-resolver clear ./symlinks/path",
        "build": "your build command should be under this name"
}
```
This way you will be able to make a build and edit your files without worries.

However, in some cases like emulating a device, the "post" script will not be executed. If this is also your case then take a look at example workaround for NativeScript:
```
  "scripts": {
    "symlink-resolver": "symlink-resolver",
    "prens-bundle": "npm run symlink-resolver build ./symlinks/path",
    "delay-clear": "sleep 22 && npm run symlink-resolver clear ./symlinks/path",
    "ns-bundle": "npm run delay-clear | ns-bundle",
    "start-android-bundle": "npm run ns-bundle --android --start-app",
    "start-ios-bundle": "npm run ns-bundle --ios --start-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  },
```

#### Advanced configuration
You can adjust `Config` to your needs.
- Want to use custom symlinks file name? No problem, just set `Config.symlinksFile` to whatever you want.
- Need some custom behavior? Simply extend `SymlinkHelper` class and set `Config.helperClass` to yours.
```
export interface ConfigInterface {
    rootDir: string;
    symlinksFile: string;
    helperClass: typeof SymlinkHelper;
}
```

##### Happy developing!

repository: DanielKucal/symlink-resolver

repo_name: DanielKucal/symlink-resolver


text:
# Assignment

This file contains all the assignments for this particular class. Students are required to solve each problem with Python and submit the code.

## Class Assignments

* [ ] Ask a user to input a number 10 times and calculate the sum of the 10 numbers which are inputted. Do so with both a``for`` and``while`` loop.
* [ ] Make a loop which keeps asking for input from the user. The loop terminates only if the number inputted =``-1``.

### Solutions

#### Question 1

```python
# for loop
total = 0
for i in range(10):
    num = int(input("Enter number: "))
    total += num

print("The sum of all 10 numbers is", total)

# while loop
total = 0
count = 0
while count < 10:
    num = int(input("Enter number: "))
    total += num
    count += 1 # to count iterations

print("The sum of all 10 numbers is", total)
```

#### Question 2

```python
numm = ""
while num != "-1": # runs as long as the number is not -1
    num = input("Enter a number")

# this code is executed when the program exits the while loop
print("You entered -1!")
```

## Home Assignments

* [ ] Make a loop that keeps asking for a number from the user. The loop terminates only if the number inputted is greater than 50 or less than 0 (negative).
* [ ] Imagine you work for a firm with 5 employees. Write a program which allows all 5 employees to input their name and print it.
* [ ] Write a loop which prints all multiples of 4 until 100

## Other Details

path: /Python/2021/Class 3/Assignment.md


text:
# Questioner
Crowd-source questions for a meet up.
Questioner helps the meet up organizer prioritize questions to be answered. Other users can vote on asked questions and they bubble to the top or bottom of the log.

[![BCH compliance](https://bettercodehub.com/edge/badge/Bakley/Questioner-UI?branch=gh-pages)](https://bettercodehub.com/)

# Required Features
1. Admin can create meet ups.
2. Users can create an account and log in.
3. Users can post questions to a specific meet up.
4. Users can up vote or down vote a question.
5. Questions are sorted based on the number of up votes a question has, which helps the meet up organizer(s) to prioritize questions most users are interested in.
6. Users can post comments to a specific question.

# Optional Features
1. Admin can add images to a meet up record.
2. Admin can add tags to a meet up record.
3. User can reset password.

# Built With

- HTML5
- CSS3
- JavaScript

# Github pages link
https://bakley.github.io/Questioner/UI/landing.html

# Author:
Barclay K Koin

repository: Bakley/Questioner-UI

gha_language: HTML

repo_name: Bakley/Questioner-UI


text:
# CS144 Introduction to Computer Networking

This repository contains my course work regarding to Introduction to Computer Networking taught at Stanford University.

## Course
[Stanford University's self-paced introduction to networking course](https://lagunita.stanford.edu/courses/Engineering/Networking-SP/SelfPaced/about)

## Assignment:
[Assignment based off of Princeton University's Lab assignment](https://github.com/PrincetonUniversity/COS461-Public)

## Optional Lab:
[Wireshark Lab](https://www-net.cs.umass.edu/wireshark-labs/)

## Book
[Computer Networking: A Top Down Network Approach(7th ed.)](https://www.goodreads.com/book/show/83847.Computer_Networking)

## Lecture Content:
1. The Internet and IP
2. Transport


text:
# CombinedCasts theme for VS Code

A theme in the _spirit_ of the [CombinedCasts](https://github.com/hiltmon/textmate-theme-csv) TextMate theme by [Hilton Lipschitz](http://hiltmon.com/) for use in [Visual Studio Code](https://code.visualstudio.com/).

## Installation

Open the Quick Open menu (`⌘+P`, `cmd+P`, or `ctrl+P`). Then enter...

```
ext install combinedcasts
```

## Screenshots

![JavaScript Screenshot](./screenshots/js.png "JavaScript")

repository: eoneill/vscode-combinedcasts

repo_name: eoneill/vscode-combinedcasts


text:
# dita lce specialization

Defines a DITA-OT 2.x plugin containing the LCE DITA 1.3 specializations.

## Installation

1. Checkout this repository in ```{DITA_OT2.x_PATH}/plugins/dita13.lc.extra-interactions```
2. From ```{DITA_OT2.x_PATH}``` run ```ant -f integrator.xml```

## Global information

The dita13.lc.extra-interactions has been developed from XStructuring with support of Fonto XML and ThiemeMeulenhoff
using their experience with and knowledge of educational content.

## Schema documentation

See map "documentation"

## Schema roadmap

Some more interactions: upload, crossword, graphicGapTextEntry

## License

Copyright 2016 Birgit Strackenbrock (XStructuring) and contributors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.


text:
---
#See https://github.com/HTTPArchive/almanac.httparchive.org/wiki/Authors'-Guide#metadata-to-add-at-the-top-of-your-chapters
title: Caching
description: Caching chapter of the 2019 Web Almanac covering cache-control, expires, TTLs, validitaty, vary, set-cookies, AppCache, Service Workers and opportunities.
authors: [paulcalvano]
reviewers: [foxdavidj, bkardell]
analysts: [paulcalvano, foxdavidj]
editors: [tunetheweb]
translators: []
discuss: 1771
results: https://docs.google.com/spreadsheets/d/1mnq03DqrRBwxfDV05uEFETK0_hPbYOynWxZkV3tFgNk/
paulcalvano_bio: Paul Calvano is a Web Performance Architect at Akamai, where he helps businesses improve the performance of their websites. He's also a co-maintainer of the HTTP Archive project. You can find him tweeting at @paulcalvano, blogging at http://paulcalvano.com and sharing HTTP Archive research at https://discuss.httparchive.org.
featured_quote: Caching is a technique that enables the reuse of previously downloaded content. It provides a significant performance benefit by avoiding costly network requests and it also helps scale an application by reducing the traffic to a website's origin infrastructure. There's an old saying, "the fastest request is the one that you don't have to make" and caching is one of the key ways to avoid having to make requests.
featured_stat_1: 27%
featured_stat_label_1: Responses not using any caching headers
featured_stat_2: 39%
featured_stat_label_2: Responses using the `Vary` header
featured_stat_3: 82%
featured_stat_label_3: Sites that could save 1 MB by optimizing caching better
---

## Introduction

Caching is a technique that enables the reuse of previously downloaded content. It provides a significant [performance](./performance) benefit by avoiding costly network requests and it also helps scale an application by reducing the traffic to a website's origin infrastructure. There's an old saying, "the fastest request is the one that you don't have to make," and caching is one of the key ways to avoid having to make requests.

There are three guiding principles to caching web content: cache as much as you can, for as long as you can, as close as you can to end users.

**Cache as much as you can.** When considering how much can be cached, it is important to understand whether a response is static or dynamic. Requests that are served as a static response are typically cacheable, as they have a one-to-many relationship between the resource and the users requesting it. Dynamically generated content can be more nuanced and require careful consideration.

**Cache for as long as you can.** The length of time you would cache a resource is highly dependent on the sensitivity of the content being cached. A versioned JavaScript resource could be cached for a very long time, while a non-versioned resource may need a shorter cache duration to ensure users get a fresh version.

**Cache as close to end users as you can.** Caching content close to the end user reduces download times by removing latency. For example, if a resource is cached on an end user's browser, then the request never goes out to the network and the download time is as fast as the machine's I/O. For first time visitors, or visitors that don't have entries in their cache, a CDN would typically be the next place a cached resource is returned from. In most cases, it will be faster to fetch a resource from a local cache or a CDN compared to an origin server.

Web architectures typically involve multiple tiers of caching. For example, an HTTP request may have the opportunity to be cached in:

* An end user's browser
* A service worker cache in the user's browser
* A shared gateway
* CDNs, which offer the ability to cache at the edge, close to end users
* A caching proxy in front of the application, to reduce the backend workload
* The application and database layers

This chapter will explore how resources are cached within web browsers.

## Overview of HTTP caching

For an HTTP client to cache a resource, it needs to understand two pieces of information:

* "How long am I allowed to cache this for?"
* "How do I validate that the content is still fresh?"

When a web browser sends a response to a client, it typically includes headers that indicate whether the resource is cacheable, how long to cache it for, and how old the resource is. RFC 7234 covers this in more detail in section 4.2 (Freshness) and 4.3 (Validation).

The HTTP response headers typically used for conveying freshness lifetime are:

* `Cache-Control` allows you to configure a cache lifetime duration (i.e. how long this is valid for).
* `Expires` provides an expiration date or time (i.e. when exactly this expires).

`Cache-Control` takes priority if both are present. These are [discussed in more detail below](#cache-control-vs-expires).

The HTTP response headers for validating the responses stored within the cache, i.e. giving conditional requests something to compare to on the server side, are:

* `Last-Modified` indicates when the object was last changed.
* Entity Tag (`ETag`) provides a unique identifier for the content.

`ETag` takes priority if both are present. These are [discussed in more detail below](#validating-freshness).

The example below contains an excerpt of a request/response header from HTTP Archive's main.js file. These headers indicate that the resource can be cached for 43,200 seconds (12 hours), and it was last modified more than two months ago (difference between the `Last-Modified` and `Date` headers).

```
> GET /static/js/main.js HTTP/1.1
> Host: httparchive.org
> User-agent: curl/7.54.0
> Accept: */*

< HTTP/1.1 200
< Date: Sun, 13 Oct 2019 19:36:57 GMT
< Content-Type: application/javascript; charset=utf-8
< Content-Length: 3052
< Vary: Accept-Encoding
< Server: gunicorn/19.7.1
< Last-Modified: Sun, 25 Aug 2019 16:00:30 GMT
< Cache-Control: public, max-age=43200
< Expires: Mon, 14 Oct 2019 07:36:57 GMT
< ETag: "1566748830.0-3052-3932359948"
```

The tool RedBot.org allows you to input a URL and see a detailed explanation of how the response would be cached based on these headers. For example, a test for the URL above would output the following:

{{ figure_markup(
  image="ch16_fig1_redbot_example.jpg",
  caption="Cache-Control information from RedBot.",
  description="Redbot example response showing detailed information about when the resource was changed, whether caches can store it, how long it can be considered fresh for and warnings.",
  width=600,
  height=138
  )
}}

If no caching headers are present in a response, then the client is permitted to heuristically cache the response. Most clients implement a variation of the RFC's suggested heuristic, which is 10% of the time since `Last-Modified`. However, some may cache the response indefinitely. So, it is important to set specific caching rules to ensure that you are in control of the cacheability.

72% of responses are served with a `Cache-Control` header, and 56% of responses are served with an `Expires` header. However, 27% of responses did not use either header, and therefore are subject to heuristic caching. This is consistent across both desktop and mobile sites.

{{ figure_markup(
  image="fig2.png",
  caption="Presence of HTTP Cache-Control and Expires headers.",
  description="Two identical bar charts for mobile and desktop showing 72% of requests use Cache-Control headers, 56% use Expires and the 27% use neither.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1611664016&format=interactive"
  )
}}

## What type of content are we caching?

A cacheable resource is stored by the client for a period of time and available for reuse on a subsequent request. Across all HTTP requests, 80% of responses are considered cacheable, meaning that a cache is permitted to store them. Out of these,

* 6% of requests have a time to live (TTL) of 0 seconds, which immediately invalidates a cached entry.
* 27% are cached heuristically because of a missing `Cache-Control` header.
* 47% are cached for more than 0 seconds.

The remaining responses are not permitted to be stored in browser caches.

{{ figure_markup(
  image="fig3.png",
  caption="Distribution of cacheable responses.",
  description="A stacked bar chart showing 20% of desktop responses are not cacheable, 47% have a cache greater than zero, 27% are heuristically cached and 6% have a TTL of 0. The stats for mobile are very similar (19%, 47%, 27% and 7%)",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1868559586&format=interactive"
  )
}}

The table below details the cache TTL values for desktop requests by type. Most content types are being cached however CSS resources appear to be consistently cached at high TTLs.

        Desktop Cache TTL Percentiles (Hours)

        10
        25
        50
        75
        90

        Audio
        12
        24
        720
        8,760
        8,760

        CSS
        720
        8,760
        8,760
        8,760
        8,760

        Font
        < 1
        3
        336
        8,760
        87,600

        HTML
        < 1
        168
        720
        8,760
        8,766

        Image
        < 1
        1
        28
        48
        8,760

        Other
        < 1
        2
        336
        8,760
        8,760

        Script
        < 1
        < 1
        1
        6
        720

        Text
        21
        336
        7,902
        8,357
        8,740

        Video
        < 1
        4
        24
        24
        336

        XML
        < 1
        < 1
        < 1
        < 1
        < 1

{{ figure_link(caption="Desktop cache TTL percentiles by resource type.") }}

While most of the median TTLs are high, the lower percentiles highlight some of the missed caching opportunities. For example, the median TTL for images is 28 hours, however the 25th percentile is just one-two hours and the 10th percentile indicates that 10% of cacheable image content is cached for less than one hour.

By exploring the cacheability by content type in more detail in Figure 16.5 below, we can see that approximately half of all HTML responses are considered non-cacheable. Additionally, 16% of images and scripts are non-cacheable.

{{ figure_markup(
  image="fig5.png",
  caption="Distribution of cacheability by content type for desktop.",
  description="A stacked bar chart showing the split of not cacheable, cached more than 0 seconds and cached for only 0 seconds by type for desktop. A small, but significant proportion are not cacheable and this goes up to 50% for HTML, most have caching greater than 0 and a smaller amount has a 0 TTL",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1493610744&format=interactive"
  )
}}

The same data for mobile is shown below. As can be seen, the cacheability of content types is consistent between desktop and mobile.

{{ figure_markup(
  image="fig6.png",
  caption="Distribution of cacheability by content type for mobile.",
  description="A stacked bar chart showing the split of not cacheable, cached more than 0 seconds and cached for only 0 seconds by type for mobile. A small, but significant proportion are not cacheable and this goes up to 50% for HTML, most have caching greater than 0 and a smaller amount has a 0 TTL",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1713903788&format=interactive"
  )
}}

## `Cache-Control` vs `Expires`

In HTTP/1.0, the `Expires` header was used to indicate the date/time after which the response is considered stale. Its value is a date timestamp, such as:

`Expires: Thu, 01 Dec 1994 16:00:00 GMT`

HTTP/1.1 introduced the `Cache-Control` header, and most modern clients support both headers. This header provides much more extensibility via caching directives. For example:

* `no-store` can be used to indicate that a resource should not be cached.
* `max-age` can be used to indicate a freshness lifetime.
* `must-revalidate` tells the client a cached entry must be validated with a conditional request prior to its use.
* `private` indicates a response should only be cached by a browser, and not by an intermediary that would serve multiple clients.

53% of HTTP responses include a `Cache-Control` header with the `max-age` directive, and 54% include the Expires header. However, only 41% of these responses use both headers, which means that 13% of responses are caching solely based on the older `Expires` header.

{{ figure_markup(
  image="fig7.png",
  caption="Usage of Cache-Control versus Expires headers.",
  description="A bar chart showing 53% of responses have a `Cache-Control: max-age`, 54%-55% use `Expires`, 41%-42% use both, and 34% use neither. The figures are given for both desktop and mobile but the figures are near identical with mobile having a percentage point higher in use of expires.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1909701542&format=interactive"
  )
}}

## `Cache-Control` directives

The HTTP/1.1 specification includes multiple directives that can be used in the `Cache-Control` response header and are detailed below. Note that multiple can be used in a single response.

      Directive
      Description

      max-age
      Indicates the number of seconds that a resource can be cached for.

      public
      Any cache may store the response.

      no-cache
      A cached entry must be revalidated prior to its use.

      must-revalidate
      A stale cached entry must be revalidated prior to its use.

      no-store
      Indicates that a response is not cacheable.

      private
      The response is intended for a specific user and should not be stored by shared caches.

      no-transform
      No transformations or conversions should be made to this resource.

      proxy-revalidate
      Same as must-revalidate but applies to shared caches.

      s-maxage
      Same as max age but applies to shared caches only.

      immutable
      Indicates that the cached entry will never change, and that revalidation is not necessary.

      stale-while-revalidate
      Indicates that the client is willing to accept a stale response while asynchronously checking in the background for a fresh one.

      stale-if-error
      Indicates that the client is willing to accept a stale response if the check for a fresh one fails.

{{ figure_link(caption="Cache-Control directives.") }}

For example, `cache-control: public, max-age=43200` indicates that a cached entry should be stored for 43,200 seconds and it can be stored by all caches.

{{ figure_markup(
  image="fig9.png",
  caption="Usage of Cache-Control directives on mobile.",
  description="A bar chart of 15 cache control directives and their usage ranging from 74.8% for max-age, 37.8% for public, 27.8% for no-cache, 18% for no-store, 14.3% for private, 3.4% for immutable, 3.3% for no-transform, 2.4% for stale-while-revalidate, 2.2% for pre-check, 2.2% for post-check, 1.9% for s-maxage, 1.6% for proxy-revalidate, 0.3% for set-cookie and 0.2% for stale-if-error. The stats are near identical for desktop and mobile.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1054108345&format=interactive",
  width=600,
  height=662,
  data_width=600,
  data_height=662
  )
}}

Figure 16.9 above illustrates the top 15 `Cache-Control` directives in use on mobile websites. The results for desktop and mobile are very similar. There are a few interesting observations about the popularity of these cache directives:

* `max-age` is used by almost 75% of `Cache-Control` headers, and `no-store` is used by 18%.
* `public` is rarely necessary since cached entries are assumed `public` unless `private` is specified. Approximately 38% of responses include `public`.
* The `immutable` directive is relatively new, introduced in 2017 and is [supported on Firefox and Safari](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#Browser_compatibility). Its usage has grown to 3.4%, and it is widely used in Facebook and Google third-party responses.

Another interesting set of directives to show up in this list are `pre-check` and `post-check`, which are used in 2.2% of `Cache-Control` response headers (approximately 7.8 million responses). This pair of headers was introduced in Internet Explorer 5 to provide a background validation and was rarely implemented correctly by websites. 99.2% of responses using these headers had used the combination of `pre-check=0` and `post-check=0`. When both of these directives are set to 0, then both directives are ignored. So, it seems these directives were never used correctly!

In the long tail, there are more than 1,500 erroneous directives in use across 0.28% of responses. These are ignored by clients, and include misspellings such as "nocache", "s-max-age", "smax-age", and "maxage". There are also numerous non-existent directives such as "max-stale", "proxy-public", "surrogate-control", etc.

## `Cache-Control`: `no-store`, `no-cache` and `max-age=0`

When a response is not cacheable, the `Cache-Control` `no-store` directive should be used. If this directive is not used, then the response is cacheable.

There are a few common errors that are made when attempting to configure a response to be non-cacheable:

* Setting `Cache-Control: no-cache` may sound like the resource will not be cacheable. However, the `no-cache` directive requires the cached entry to be revalidated prior to use and is not the same as being non-cacheable.
* Setting `Cache-Control: max-age=0` sets the TTL to 0 seconds, but that is not the same as being non-cacheable. When `max-age` is set to 0, the resource is stored in the browser cache and immediately invalidated. This results in the browser having to perform a conditional request to validate the resource's freshness.

Functionally, `no-cache` and `max-age=0` are similar, since they both require revalidation of a cached resource. The `no-cache` directive can also be used alongside a `max-age` directive that is greater than 0.

Over 3 million responses include the combination of `no-store`, `no-cache`, and `max-age=0`. Of these directives `no-store` takes precedence and the other directives are merely redundant

18% of responses include `no-store` and 16.6% of responses include both `no-store` and `no-cache`. Since `no-store` takes precedence, the resource is ultimately non-cacheable.

The `max-age=0` directive is present on 1.1% of responses (more than four million responses) where `no-store` is not present. These resources will be cached in the browser but will require revalidation as they are immediately expired.

## How do cache TTLs compare to resource age?

So far we've talked about how web servers tell a client what is cacheable, and how long it has been cached for. When designing cache rules, it is also important to understand how old the content you are serving is.

When you are selecting a cache TTL, ask yourself: "how often are you updating these assets?" and "what is their content sensitivity?". For example, if a hero image is going to be modified infrequently, then cache it with a very long TTL. If you expect a JavaScript resource to change frequently, then version it and cache it with a long TTL or cache it with a shorter TTL.

The graph below illustrates the relative age of resources by content type, and you can read a more detailed analysis here. HTML tends to be the content type with the shortest age, and a very large % of traditionally cacheable resources ([scripts](./javascript), [CSS](./css), and [fonts](./fonts)) are older than one year!

{{ figure_markup(
  image="ch16_fig8_resource_age.jpg",
  caption="Resource age distribution by content type.",
  description="A stack bar chart showing the age of content, split into weeks 0-52, > one year and > two years with null and negative figures shown too. The stats are split into first-party and third-party. The value 0 is used most particularly for first-party HTML, text and xml, and for up to 50% of third-party requests across all assets types. There is a mix using intermediary years and then considerable usage for one year and two year.",
  width=600,
  height=325
  )
}}

By comparing a resources cacheability to its age, we can determine if the TTL is appropriate or too low. For example, the resource served by the response below was last modified on 25 Aug 2019, which means that it was 49 days old at the time of delivery. The `Cache-Control` header says that we can cache it for 43,200 seconds, which is 12 hours. It is definitely old enough to merit investigating whether a longer TTL would be appropriate.

```
< HTTP/1.1 200
< Date: Sun, 13 Oct 2019 19:36:57 GMT
< Content-Type: application/javascript; charset=utf-8
< Content-Length: 3052
< Vary: Accept-Encoding
< Server: gunicorn/19.7.1
< Last-Modified: Sun, 25 Aug 2019 16:00:30 GMT
< Cache-Control: public, max-age=43200
< Expires: Mon, 14 Oct 2019 07:36:57 GMT
< ETag: "1566748830.0-3052-3932359948"
```

Overall, 59% of resources served on the web have a cache TTL that is too short compared to its content age. Furthermore, the median delta between the TTL and age is 25 days.

When we break this out by first vs third-party, we can also see that 70% of first-party resources can benefit from a longer TTL. This clearly highlights a need to spend extra attention focusing on what is cacheable, and then ensuring caching is configured correctly.

      Client
      1st Party
      3rd Party
      Overall

      Desktop
      70.7%
      47.9%
      59.2%

      Mobile
      71.4%
      46.8%
      59.6%

{{ figure_link(caption="Percent of requests with short TTLs.") }}

## Validating freshness

The HTTP response headers used for validating the responses stored within a cache are `Last-Modified` and `ETag`. The `Last-Modified` header does exactly what its name implies and provides the time that the object was last modified. The `ETag` header provides a unique identifier for the content.

For example, the response below was last modified on 25 Aug 2019 and it has an `ETag` value of `"1566748830.0-3052-3932359948"`

```
< HTTP/1.1 200
< Date: Sun, 13 Oct 2019 19:36:57 GMT
< Content-Type: application/javascript; charset=utf-8
< Content-Length: 3052
< Vary: Accept-Encoding
< Server: gunicorn/19.7.1
< Last-Modified: Sun, 25 Aug 2019 16:00:30 GMT
< Cache-Control: public, max-age=43200
< Expires: Mon, 14 Oct 2019 07:36:57 GMT
< ETag: "1566748830.0-3052-3932359948"
```

A client could send a conditional request to validate a cached entry by using the `Last-Modified` value in a request header named `If-Modified-Since`. Similarly, it could also validate the resource with an `If-None-Match` request header, which validates against the `ETag` value the client has for the resource in its cache.

In the example below, the cache entry is still valid, and an `HTTP 304` was returned with no content. This saves the download of the resource itself. If the cache entry was no longer fresh, then the server would have responded with a `200` and the updated resource which would have to be downloaded again.

```
> GET /static/js/main.js HTTP/1.1
> Host: www.httparchive.org
> User-Agent: curl/7.54.0
> Accept: */*
> If-Modified-Since: Sun, 25 Aug 2019 16:00:30 GMT

< HTTP/1.1 304
< Date: Thu, 17 Oct 2019 02:31:08 GMT
< Server: gunicorn/19.7.1
< Cache-Control: public, max-age=43200
< Expires: Thu, 17 Oct 2019 14:31:08 GMT
< ETag: "1566748830.0-3052-3932359948"
< Accept-Ranges: bytes
```

Overall, 65% of responses are served with a `Last-Modified` header, 42% are served with an `ETag`, and 38% use both. However, 30% of responses include neither a `Last-Modified` or `ETag` header.

{{ figure_markup(
  image="fig12.png",
  caption="Adoption of validating freshness via Last-Modified and ETag headers for desktop websites.",
  description="A bar chart showing 64.4% of desktop requests have a last modified, 42.8% have an ETag, 37.9% have both and 30.7% have neither. The stats for mobile are almost identical at 65.3% for Last Modified, 42.8% for ETag, 38.0% for both and 29.9% for neither.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=20297100&format=interactive"
  )
}}

## Validity of date strings

There are a few HTTP headers used to convey timestamps, and the format for these are very important. The `Date` response header indicates when the resource was served to a client. The `Last-Modified` response header indicates when a resource was last changed on the server. And the `Expires` header is used to indicate how long a resource is cacheable until (unless a `Cache-Control` header is present).

All three of these HTTP headers use a date formatted string to represent timestamps.

For example:

```
> GET /static/js/main.js HTTP/1.1
> Host: httparchive.org
> User-Agent: curl/7.54.0
> Accept: */*

< HTTP/1.1 200
< Date: Sun, 13 Oct 2019 19:36:57 GMT
< Content-Type: application/javascript; charset=utf-8
< Content-Length: 3052
< Vary: Accept-Encoding
< Server: gunicorn/19.7.1
< Last-modified: Sun, 25 Aug 2019 16:00:30 GMT
< Cache-Control: public, max-age=43200
< Expires: Mon, 14 Oct 2019 07:36:57 GMT
< ETag: "1566748830.0-3052-3932359948"
```

Most clients will ignore invalid date strings, which render them ineffective for the response they are served on. This can have consequences on cacheability, since an erroneous `Last-Modified` header will be cached without a Last-Modified timestamp resulting in the inability to perform a conditional request.

The `Date` HTTP response header is usually generated by the web server or CDN serving the response to a client. Because the header is typically generated automatically by the server, it tends to be less prone to error, which is reflected by the very low percentage of invalid `Date` headers. `Last-Modified` headers were very similar, with only 0.67% of them being invalid. What was very surprising to see though, was that 3.64% `Expires` headers used an invalid date format!

{{ figure_markup(
  image="fig13.png",
  caption="Invalid date formats in response headers.",
  description="A bar chart showing 0.10% of desktop responses have an invalid date, 0.67% have an invalid Last-Modified and 3.64% have an invalid Expires. The stats for mobile are very similar with 0.06% of responses have an invalid date, 0.68% have an invalid Last-Modified and 3.50% have an invalid Expires.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1500819114&format=interactive"
  )
}}

Examples of some of the invalid uses of the `Expires` header are:

* Valid date formats, but using a time zone other than GMT
* Numerical values such as 0 or -1
* Values that would be valid in a `Cache-Control` header

The largest source of invalid `Expires` headers is from assets served from a popular third-party, in which a date/time uses the EST time zone, for example `Expires: Tue, 27 Apr 1971 19:44:06 EST`.

## `Vary` header

One of the most important steps in caching is determining if the resource being requested is cached or not. While this may seem simple, many times the URL alone is not enough to determine this. For example, requests with the same URL could vary in what [compression](./compression) they used (Gzip, Brotli, etc.) or be modified and tailored for mobile visitors.

To solve this problem, clients give each cached resource a unique identifier (a cache key). By default, this cache key is simply the URL of the resource, but developers can add other elements (like compression method) by using the Vary header.

A Vary header instructs a client to add the value of one or more request header values to the cache key. The most common example of this is `Vary: Accept-Encoding`, which will result in different cached entries for `Accept-Encoding` request header values (i.e. `gzip`, `br`, `deflate`).

Another common value is `Vary: Accept-Encoding, User-Agent`, which instructs the client to vary the cached entry by both the Accept-Encoding values and the `User-Agent` string. When dealing with shared proxies and CDNs, using values other than `Accept-Encoding` can be problematic as it dilutes the cache keys and can reduce the amount of traffic served from cache.

In general, you should only vary the cache if you are serving alternate content to clients based on that header.

The `Vary` header is used on 39% of HTTP responses, and 45% of responses that include a `Cache-Control` header.

The graph below details the popularity for the top 10 `Vary` header values. `Accept-Encoding` accounts for 90% of `Vary`'s use, with `User-Agent` (11%), `Origin` (9%), and `Accept` (3%) making up much of the rest.

{{ figure_markup(
  image="fig14.png",
  caption="Vary header usage.",
  description="A bar chart showing 90% use of accept-encoding, much smaller values for the rest with 10%-11% for user-agent, approximately 7%-8% for origin and less so for accept, almost not usage for cookie, x-forward-proto, accept-language, host, x-origin, access-control-request-method, and access-control-request-headers",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=384675253&format=interactive",
  width=600,
  height=655,
  data_width=600,
  data_height=655
  )
}}

## Setting cookies on cacheable responses

When a response is cached, its entire headers are swapped into the cache as well. This is why you can see the response headers when inspecting a cached response via DevTools.

{{ figure_markup(
  image="ch16_fig12_header_example_with_cookie.jpg",
  caption="Chrome Dev Tools for a cached resource.",
  description="A screenshot of Chrome Developer Tools showing HTTP response headers for a cached response.",
  width=600,
  height=359
  )
}}

But what happens if you have a `Set-Cookie` on a response? According to RFC 7234 Section 8, the presence of a `Set-Cookie` response header does not inhibit caching. This means that a cached entry might contain a `Set-Cookie` if it was cached with one. The RFC goes on to recommend that you should configure appropriate `Cache-Control` headers to control how responses are cached.

One of the risks of caching responses with `Set-Cookie` is that the cookie values can be stored and served to subsequent requests. Depending on the cookie's purpose, this could have worrying results. For example, if a login cookie or a session cookie is present in a shared cache, then that cookie might be reused by another client. One way to avoid this is to use the `Cache-Control` `private` directive, which only permits the response to be cached by the client browser.

3% of cacheable responses contain a `Set-Cookie header`. Of those responses, only 18% use the `private` directive. The remaining 82% include 5.3 million HTTP responses that include a `Set-Cookie` which can be cached by public and private cache servers.

{{ figure_markup(
  image="ch16_fig16_cacheable_responses_set_cookie.jpg",
  caption="Cacheable responses of Set-Cookie responses.",
  description="A bar chart showing 97% of responses do not use Set-Cookie, and 3% do. This 3% is zoomed into for another bar chart showing the split of 15.3% private, 84.7% public for desktop and similar for mobile at 18.4% public and 81.6% private.",
  width=600,
  height=567
  )
}}

## AppCache and service workers

The Application Cache or AppCache is a feature of HTML5 that allows developers to specify resources the browser should cache and make available to offline users. This feature was deprecated and removed from web standards, and browser support has been diminishing. In fact, when its use is detected, [Firefox v44+ recommends that developers should use service workers instead](https://developer.mozilla.org/docs/Web/API/Service_Worker_API/Using_Service_Workers). Chrome 70 restricts the Application Cache to secure context only. The industry has moved more towards implementing this type of functionality with service workers - and browser support has been rapidly growing for it.

In fact, one of the HTTP Archive trend reports shows the adoption of service workers shown below:

{{ figure_markup(
  image="ch16_fig14_service_worker_adoption.jpg",
  caption='Timeseries of service worker controlled pages. (Source: HTTP Archive)',
  description="A time series chart showing service worker controlled site usage from October 2016 until July 2019. Usage has been steadily growing throughout the years for both mobile and desktop but is still less than 0.6% for both.",
  width=600,
  height=311
  )
}}

Adoption is still below 1% of websites, but it has been steadily increasing since January 2017. The [Progressive Web App](./pwa) chapter discusses this more, including the fact that it is used a lot more than this graph suggests due to its usage on popular sites, which are only counted once in above graph.

In the table below, you can see a summary of AppCache vs service worker usage. 32,292 websites have implemented a service worker, while 1,867 sites are still utilizing the deprecated AppCache feature.

        Does Not Use Server Worker
        Uses Service Worker
        Total

        Does Not Use AppCache
        5,045,337
        32,241
        5,077,578

        Uses AppCache
        1,816
        51
        1,867

        Total
        5,047,153
        32,292
        5,079,445

{{ figure_link(caption="Number of websites using AppCache versus service worker.") }}

If we break this out by HTTP vs HTTPS, then this gets even more interesting. 581 of the AppCache enabled sites are served over HTTP, which means that Chrome is likely disabling the feature. HTTPS is a requirement for using service workers, but 907 of the sites using them are served over HTTP.

        Does Not Use Service Worker
        Uses Service Worker

        HTTP
        Does Not Use AppCache
        1,968,736
        907

        Uses AppCache
        580
        1

        HTTPS
        Does Not Use AppCache
        3,076,601
        31,334

        Uses AppCache
        1,236
        50

{{ figure_link(caption="Number of websites using AppCache versus service worker usage by HTTP/HTTPS.") }}

## Identifying caching opportunities

Google's Lighthouse tool enables users to run a series of audits against web pages, and the cache policy audit evaluates whether a site can benefit from additional caching. It does this by comparing the content age (via the `Last-Modified` header) to the cache TTL and estimating the probability that the resource would be served from cache. Depending on the score, you may see a caching recommendation in the results, with a list of specific resources that could be cached.

{{ figure_markup(
  image="ch16_fig15_lighthouse_example.jpg",
  caption="Lighthouse report highlighting potential cache policy improvements.",
  description="A screenshot of part of a report from the Google Lighthouse tool, with the 'Serve static assets with an efficient cache policy' section open where it lists a number of resources, who's names have been redacted, and the Cache TTL versus the size.",
  width=600,
  height=459
  )
}}

Lighthouse computes a score for each audit, ranging from 0% to 100%, and those scores are then factored into the overall scores. The caching score is based on potential byte savings. When we examine the Lighthouse results, we can get a perspective of how many sites are doing well with their cache policies.

{{ figure_markup(
  image="fig21.png",
  caption='Distribution of Lighthouse scores for the "Uses Long Cache TTL" audit for mobile web pages.',
  description="A stacked bar chart 38.2% of websites get a score of < 10%, 29.0% of websites get a score between 10% and 39%, 18.7% of websites get a score of 40%-79%, 10.7% of websites get a score of 80% - 99%, and 3.4% of websites get a score of 100%.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=827424070&format=interactive"
  )
}}

Only 3.4% of sites scored a 100%, meaning that most sites can benefit from some cache optimizations. A vast majority of sites sore below 40%, with 38% scoring less than 10%. Based on this, there is a significant amount of caching opportunities on the web.

Lighthouse also indicates how many bytes could be saved on repeat views by enabling a longer cache policy. Of the sites that could benefit from additional caching, 82% of them can reduce their page weight by up to a whole Mb!

{{ figure_markup(
  image="fig22.png",
  caption="Distribution of potential byte savings from the Lighthouse caching audit.",
  description="A stacked bar chart showing 56.8% of websites have potential byte savings of less than one MB, 22.1% could have savings of one to two MB, 8.3% could save two to three MB. 4.3% could save three to four MB and 6.0% could save more than four MB.",
  chart_url="https://docs.google.com/spreadsheets/d/e/2PACX-1vT3GWCs19Wq0mu0zgIlKRc8zcXgmVEk2xFHuzZACiWVtqOv8FO5gfHwBxa0mhU6O9TBY8ODdN4Zjd_O/pubchart?oid=1698914500&format=interactive"
  )
}}

## Conclusion

Caching is an incredibly powerful feature that allows browsers, proxies and other intermediaries (such as CDNs) to store web content and serve it to end users. The performance benefits of this are significant, since it reduces round trip times and minimizes costly network requests.

Caching is also a very complex topic. There are numerous HTTP response headers that can convey freshness as well as validate cached entries, and `Cache-Control` directives provide a tremendous amount of flexibility and control. However, developers should be cautious about the additional opportunities for mistakes that it comes with. Regularly auditing your site to ensure that cacheable resources are cached appropriately is recommended, and tools like Lighthouse and REDbot do an excellent job of helping to simplify the analysis.


text:
---
name: Xamarin.Mac - FileCards
description: Demonstrates the use of NSPageController. App are displayed for the contents of the user's Documents folder. You can swipe, click the arrow buttons...
page_type: sample
languages:
- csharp
products:
- xamarin
urlFragment: yosemite-filecards
---
# FileCards

Demonstrates the use of `NSPageController`.
App are displayed for the contents of the user's `Documents` folder.
You can swipe, click the arrow buttons or click on the entry in the table to switch between cards.

`AppDelegate`:
Implements the NSPageControllerDelegate methods.
There are few interesting advanced techniques shown in this file:
- How to programmatically change the `PageController.SelectedIndex`.
- The use of more than 1 identifier so that we can have 2 card styles.

`FileObject`:
Simple wrapper around NSUrl to make binding to file properties in IB easier.

`CardBackgroundView`:
Draws the rounded edge background of the file cards.

![FileCards application screenshot](Screenshots/Screen.png "FileCards application screenshot")

## Build Requirements

Xcode 6.0, OS X 10.10

## Runtime Requirements

OS X 10.8 or later

## License

Xamarin port changes are released under the MIT license

repository: xamarin/mac-samples

gha_language: C#

repo_name: xamarin/mac-samples


text:
# Neighborhood Shopping
### Project Overview
Current project represents a single page ReactJS application which uses Google Maps API to display neighborhood shops and detailed information about them which comes from Foursquare.
### 3rd party dependencies
* [Bootstrap css](https://getbootstrap.com/)
* [ReactJS](https://reactjs.org/)
* [Google maps](https://developers.google.com/products/)
* [Foursquare](https://foursquare.com/developers/)
### Running the application
* [Clone](https://github.com/svvik/neighborhood-shopping) or [Download](https://github.com/svvik/neighborhood-shopping) the repository
* Run `npm install` to install dependencies
* Run `npm start` to start the server

repository: svvik/neighborhood-shopping

repo_name: svvik/neighborhood-shopping


text:
# Converting this to [`jupyter-book`](https://jupyter.org/jupyter-book/intro.html)

1. Run [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/) on notebooks to generate output.
2. Change filenames to
    + replace periods with dash except for the one before file extension.
    + replace parentheses with nothing
4. Move renamed notebooks to `content` folder in `ccd-as-book` with
5. Update TOC in `ccd-as-book` if needed.


text:
---
section: api
title: bucket.setJSON
---

```js
bucket.setJSON(path, object)
```

`setJSON` JSON-encodes a provided object, and stores the result in a file at `path`.

Like [setFile](#docs-bucket-setfile), this function only changes the content of the bucket locally. You have to call [bucket.upload](#docs-bucket-upload) to upload the new contents of the bucket when you are ready to save it.

It's a good idea to end files with `.json` when they are storing JSON data. It isn't required, though.

gha_language: CSS


text:
# A10 Networks Openstack LBaaS v1/v2 Driver
=================

A10 Networks, Openstack Neutron LBaaS Driver for Juno

This package enables LBaaS v1/v2 support for A10 appliances.

A10 github repos:

- [a10-openstack-lbaas](https://github.com/a10networks/a10-openstack-lbaas) - OpenStack LBaaS driver,
identical to the files that are currently merged into Juno.  Also supports Icehouse.  Pypi package
'a10-openstack-lbaas'.
- [a10-openstack-lbaas, havana branch](https://github.com/a10networks/a10-openstack-lbaas/tree/havana) - OpenStack
LBaaS driver, for the Havana release.  Pypi package 'a10-openstack-lbaas-havana'.
- [a10-neutron-lbaas](https://github.com/a10networks/a10-neutron-lbaas) - Middleware sitting between the
openstack driver and our API client, mapping openstack constructs to A10's AxAPI.
- [acos-client](https://github.com/a10networks/acos-client) - AxAPI client used by A10's OpenStack driver.
- [neutron-thirdparty-ci](https://github.com/a10networks/neutron-thirdparty-ci) - Scripts used by
our Jenkins/Zuul/Devstack-Gate setup, used to test every openstack code review submission against
A10 appliances and our drivers.

## Installation

Installation of A10's LBaaS implementation for Neutron is simple.  Install, configure, and restart affected services.  The latest release version of a10-neutron-lbaas is available via standard pypi repositories and the current development version is available here.

##### Installation from pypi
```sh
sudo pip install a10-neutron-lbaas
```

##### Installation from cloned git repository.
```sh
git clone https://github.com/a10networks/a10-neutron-lbaas.git
cd a10-neutron-lbaas
sudo pip install -e .
```

## Configuration

Post-installation configuration requires modification of your neutron.conf or neutron_lbaas.conf (neutron_lbaas.conf is only present in LBaaSv2) typically located in `/etc/neutron`.

##### LBaaS v1 configuration
Open `/etc/neutron/neutron.conf` in your preferred text editor.
Under the `service_plugins` setting, ensure `neutron.services.loadbalancer.plugin.LoadBalancerPlugin` is listed.

In the list of `service_provider` settings, ensure there is only a single entry for LOADBALANCER (you can comment out existing entries) enabled:
`service_provider = LOADBALANCER:A10Networks:neutron_lbaas.services.loadbalancer.drivers.a10networks.driver_v1.ThunderDriver:default`

Save and close neutron.conf

##### LBaaS v2 configuration
Open `/etc/neutron/neutron.conf` in your preferred text editor.
Under the `service_plugins` setting, ensure `neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2` is listed.
Save and close neutron.conf.

Open `/etc/neutron/neutron_lbaas.conf` in your preferred text editor.

In the list of `service_provider` settings, ensure there is only a single entry for LOADBALANCERV2 (you can comment out existing entries) enabled:
`service_provider = LOADBALANCERV2:A10Networks:neutron_lbaas.drivers.a10networks.driver_v2.ThunderDriver:default`

##### Device configuration

After installation, you will need to provide configuration for the driver so the driver is aware of the appliances you have configured.  The configuration is a standard JSON structure stored in `/etc/a10/config.py`.  Below is a sample to show options and formatting:
```python
devices = {
    "ax1": {
        "name": "ax1",
        "host": "<IP_ADDRESS>",
        "port": 443,
        "username": "admin",
        "password": "a10",
        "status": True,
        "default_virtual_server_vrid": 1,
        "autosnat": False,
        "api_version": "3.0",
        "v_method": "ADP",
        "max_instance": 5000,
        "use_float": False,
        "method": "hash",
        "max_partitions": 10,
        "per_partition_lif_max": 10,
        "peer_mgmt_ip": "",
        "peer_mgmt_port": "",
        "vlan": 0,
        "gateway_mode": 1,
    },
    "ax4": {
        "host": "<IP_ADDRESS>",
        "username": "admin",
        "password": "a10",
    },
}
```

##### Essential device configuration

###### `host` (required)

The ip address or host name of the A10 appliance. For a virtual chassis configuration, this should be the floating host or ip address of the master.

###### `port` (default `443`)

Port that the AXAPI is exposed on

###### `username` and `password` (required)

Authentication credentials to control the A10 appliance via the AXAPI.

###### `api_version` (default `"2.1"`)

Version of the A10 appliance's AXAPI. `"2.1"` for 2.X.X series ACOS versions, `"3.0"` for 4.X versions.

##### Virtual server configuration

###### `autosnat`

Set to `True` to use the automatic source NAT pool. Corresponds to configuring `virtual-server` `port`s with `source-nat auto`. This functionality is only supported on devices with ACOS version 2.7.2 P3 or newer.

###### `default_virtual_server_vrid`

Virtual router number for new virtual servers. Setting it to a number `X` corresponds to configuring `vitual-server`s with `vrid X`.

## Install database migrations

Run

```
a10-neutron-lbaas-db-manage install
```

The `core` migration and the migration for the lbaas version you are using should both be `UPGRADED`. For example, the following is a successful installation of the database migrations for lbaas version 1.

```
Summary
core     UPGRADED  At 28a984ff83e1
lbaasv1  UPGRADED  At 4657b284f454
lbaasv2  ERROR     'LOADBALANCERV2'
```

## Restart necessary services
Restart the `q-svc` and `q-lbaas2` services after configuration updates.