text:
# Authentiq

[![license_badge](https://img.shields.io/github/license/SayidHosseini/authentiq.svg)](https://github.com/SayidHosseini/authentiq/blob/master/LICENSE)
[![build_status_badge](https://img.shields.io/docker/cloud/build/sayid/authentiq.svg)](https://hub.docker.com/r/sayid/authentiq/)
[![docker_build_badge](https://img.shields.io/docker/cloud/automated/sayid/authentiq.svg)](https://hub.docker.com/r/sayid/authentiq/)
[![docker_image_badge](https://images.microbadger.com/badges/image/sayid/authentiq.svg)](https://hub.docker.com/r/sayid/authentiq/)
[![docker_pulls_badge](https://img.shields.io/docker/pulls/sayid/authentiq.svg)](https://hub.docker.com/r/sayid/authentiq/)

This is a RESTful Authentication Service written in Node.js on express.js framework powered by MongoDB. It is intended that the developer use this as a module (microservice) in a project; rather than a standalone service since it is only a mean of authentication. That being said, if you plan to develop a service that includes authentication, it might be a good idea to have a head start and build on top of this project instead of starting one from scratch.

API Reference is provided in the [wiki](https://github.com/SayidHosseini/authentiq/wiki) pages.

        :information_source:
        A set of environment variables have been introduced to control some configuration and parameters in the application. Feel free to explore them in the .env and docker-compose.yml files. Note that environment variables take precedence over config parameters in config/config.js file. Also, note that you only need to modify the .env file for the cases of docker-compose and docker stack deploy (no need to change the docker-compose.yml file)

         :warning: 	 Authentiq provides JWT for authentication and session management. Currently, we do not generate unique key pairs for each new environment (this feature will be available soon). If you'd like to deploy this project in a production environment, it is very important to generate your own public / private key pair. The generated key pair should be placed in src/jwt/ with the names public.key and private.key.

## Setting up As a Service

In order to run this as a service and probably develop on top of it, you'll need to do the followings:

- Install https://nodejs.org/en/[node.js] and https://www.mongodb.com/[mongoDB].
- Clone the repository and `cd` to the cloned repository.
- Set proper environment variables for your Mongo database (alternatively, you may modify relevant parameters in `config/config.json`).
- Optionally, to enable *Verify User* and *Forgot Password* capabilities, set proper environment variables.
- To install dependency packages, run `npm install`.
- To run the application for development purposes, run `npm run dev` or `nodemon`.
- To run for production set `NODE_ENV` to `production` and run `npm start` (alternatively, you may use `docker-compose`; explained later on)

        :triangular_flag_on_post:
        Running npm start will only run your application; it will not relaunch it in the case that it crashes. To do that, you may use PM2 or Forever or any other package that provides this feature, in order to sustain availability.

## Setting up As a Microservice

If you want to run the module as a containerize microservice, you'll need to do the followings:

- Install [Docker](https://www.docker.com).
- The application is built [automatically](https://docs.docker.com/docker-hub/builds/) by _DockerHub_ for the following architectures: `x86_64`, `arm32v6`, `arm32v7`, `arm64v8` (aka `aarch64`) on **alpine**. Images are available on [_DockerHub repository_](https://hub.docker.com/r/sayid/authentiq) and can be pulled with `sayid/authentiq`. They are tested on normal `x86_64` machines as well as `RaspberryPi zero w`, `RaspberryPi 2B`, `RaspberryPi 3B`, `RaspberryPi 4B` and the `ASUS Tinkerboard`.
- If you want to make your own copy of the image, clone it and `cd` to the cloned repository. Then run `docker build -t $DOCKER_ACC/$DOCKER_REPO:$IMG_TAG .` to build the image locally. Another option is to fork the repo and enable [autobuild](https://docs.docker.com/docker-hub/builds/) on DockerHub.
- Since there might be other versions in the future and latest would point to those new versions, we recommend that you use version explicit tags (for example `alpine-1` tag, which is currently the same as `latest`) to keep consistency.
- In order to use this as a microservice in your project, you'll need a MongoDB container with the name `authentiq-db`. This is the name that should be resolved to the IP address of the MongoDB container. If you'd like to change that, you'll need to modify the proper environment variables.
- We provide a `docker-compose.yml` file that includes everything needed to launch the system. You may use either of `docker-compose` or `docker stack deploy` to setup the system for production easily! Override the default parameters by setting *environment variables* in the `.env` file.
- If you are planning to use this microservice in a production environment, generate your own key pair, as noted above. Probably, you'll need to create your own image, as well.
- If you need to store extra information e.g. name or any other user related info, it is advised to store those information in another module (microservice) of your system and keep this container intact and solely for the purpose of authentication and session management.

        :information_source:
        The Super Admin user of the system is created after the application is started with the following credentials (admin@authentiq.com:admin1234). Override it by setting proper environment variables. Note that the Super Admin user is verified by default!

## License

Developed by **_S. Saeed Hosseini_** and **_Mohammad Moradi_**, released under **MIT** License.

repository: SayidHosseini/authentiq

repo_name: SayidHosseini/authentiq


text:
# universalTuringMachine
  This is an universal turing machine that we wrote for our final project for Computational Mathematics.
It is coded in python, it is bounded by the MIT License, so you are free to use it in your projects with proper attribution.
Created by SegFaultACM (Esteban, Joel and Daniel)

## Input
Input is passed through eval(), so it has to be valid python syntax.

turing initial like 1010001

initial state

accepting states

rejecting states

transitions

```python
  10101
  "q0"
  ["qa"]
  ["qr"]
  {("q0","0"):("q0","0","R"),("q0","1"):("q0","1","R"),("q0"," "):("q1"," ","L"),("q1","0"):("q2"," ","L"),("q1","1"):("q3"," ","L"),("q1"," "):("qr"," ","L"),("q2","0"):("qa"," ","L"),("q2","1"):("qr"," ","L"),("q2"," "):("qr"," ","L"),("q3","0"):("qr"," ","L"),("q3","1"):("qr"," ","L"),("q3"," "):("qr"," ","L")}
```

An universal turing machine emulator with defined states.

license: MIT

repository: SegFaultACM/universalTuringMachine

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: SegFaultACM/universalTuringMachine


text:
SwiftCV
=======

Swift bindings for OpenCV

Work in currently progress

## Overview

This library provide a bridge to OpenCV functions making it possible to use with Swift programming language.

## Supported platforms

SwiftCV was made for both iOS and OSX platforms. You will need the appropriate OpenCV framework in order to build your project.

- [OpenCV for iOS](http://sourceforge.net/projects/opencvlibrary/files/opencv-ios/3.0.0-alpha/opencv2.framework.zip/download)
- [OpenCV for OSX](https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip)

## Contact & Support

Technical support and general questions:

 *<EMAIL_ADDRESS> * http://computer-vision-talks.com

repository: BloodAxe/SwiftCV

repo_name: BloodAxe/SwiftCV


text:
# G.2. Server Applications

This section covers PostgreSQL server-related applications in `contrib`. They are typically run on the host where the database server resides. See also [PostgreSQL Server Applications](https://www.postgresql.org/docs/10/static/reference-server.html) for information about server applications that part of the core PostgreSQL distribution.

repository: pgsql-tw/gitbook-docs

gha_language: HTML

gha_license_id: MIT

repo_name: pgsql-tw/gitbook-docs


text:
metalsmith-jslint
=================
[![Build Status](https://travis-ci.org/stevenschobert/metalsmith-jslint.png?branch=master)](https://travis-ci.org/stevenschobert/metalsmith-jslint)

A JSLint plugin for [Metalsmith](https://github.com/segmentio/metalsmith).

## Getting Started

If you haven't checked out [Metalsmith](http://www.metalsmith.io/) before, head over to their
website and check out the documentation.

## Installation

Metalsmith-jslint is available via npm. Simply install it and require it in your application.

```sh
npm install --save metalsmith-jslint
```

## Usage

To use jslint inside your Metalsmith application, you just add the function to your build steps via
the `use` method.

```js
var Metalsmith = require('metalsmith'),
    jslint = require('metalsmith-jslint');

Metalsmith(__dirname)
  .use(jslint()) // <-- boom!
  .build();
```

Notice that you need to actually invoke the function inside the `.use` method. This is because you
can also pass options to JSLint to customize it!

## Options

You can also pass a configuration object into the `jslint` function to change it's behavior. A full
list of options is available below:

```js
Metalsmith(__dirname)
  .use(jslint({
    failOnError: true
  })
  .build();
```

#### failOnError

Throw an exception if any lint is found. You can either have this halt your build process, or handle
the error more directly inside the Metalsmith's `.build` callback.

## Linter Options

The best way to control the linter settings for your project, is by adding a `.jslintrc` file at the
root of your project. JSLint will automatically detect that file and parse the options when linting
your code.

__For a list of options and command-line flags, check
[JSLint.com](http://www.jslint.com/lint.html#options).__

Here is an example `.jslintrc` file:

```json
{
  "color": true,
  "indent": 2
}
```

You may also options via the command-line, when you run your Metalsmith file:

```sh
node --color --indent=2 ./build.js
```

## Credits

Thanks to [Segment.io](http://github.com/segmentio) for creating and open-sourcing
[Metalsmith](https://github.com/segmentio/metalsmith)!

Also thanks to [Reid Burke](https://github.com/reid) for his library,
[node-jslint](https://github.com/reid/node-jslint), on which this library is built.

repository: stevenschobert/metalsmith-jslint

repo_name: stevenschobert/metalsmith-jslint


text:
# Colorize

## Contents

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

## Introduction

This is a program for dealing with palette-mapped images.
The base image is specified as a PGM specifying palette indices.
A second image contains the palatte information:
each individual palette occupies its own row,
and there is no limit to how many exist.
Finally a third, optional, image specifies per-region palette information.
This map need not be the same size as the base image;
smaller maps automatically result in larger regions using the same palette.

## Installation

Requires a C compiler, the [Netpbm][netpbm] library,
BSD make and `pkg-config`.
Installation is as simple as:

    bmake colorize
    PREFIX=/usr/local
    install -dm0755 "${PREFIX}/bin"
    install -dm0755 "${PREFIX}/share/man/man1"
    install -m0755 colorize "${PREFIX}/bin"
    install -m0644 colorize.1 "${PREFIX}/share/man/man1"

`PREFIX` should be set to the desired installation prefix.
The `install` commands may need to be run as root,
depending on permissions in the target directories.

[netpbm]: http://netpbm.sourceforge.net

## Usage

The only required option is the collection of palettes.

    colorize -p palettes.ppm -m map.pgm base.pgm

Both the `-m map.pgm` option and the `base.pgm` image are optional.
If the map file is not specified,
then there is a single region set to the first palette only.
If the base image is not specified,
then it is read from the standard input.
Output images are written to the standard output.

In terms of memory requirments,
the entire collection of palettes is loaded into memory at once,
but only one row each of the map and base image are processed at a time.
This allows larger images to be processed.

branch_name: refs/heads/main


text:
# WinDocker

A standalone application that enables hiding windows to the sides of a monitor to save screen space.\
https://youtu.be/MNLP9cXlU_o

## How to install

Download release, unzip, and run

## How to use

Has three hotkeys:
- Win + Backspace | Exit application
- Win + 0 | Remap dock hotkey
- Win + Enter | Toggle active window dock

With the remap hotkey you can change the Win + Enter hotkey to Win + [something].\
After pressing Win + Enter to start window dock, press WASD or an arrow key to choose the dock direction.\
To reset the dock key remap, delete the 'dockkey.txt' from the executable's directory.

To peek at a window, hold the mouse at the edge of the screen where you have a window docked.\
To show a docked window, do a flick-like movement at the edge of the docked window. So hit the edge with the mouse and immediately move the mouse away. No clicking required.

### [Releases](https://github.com/SirVeggie/WinDocker/releases)

repository: SirVeggie/WinDocker

repo_name: SirVeggie/WinDocker


text:
ColabTurtleClass

Description
----
Class implementation of ColabTurtle by Tolga Atam. This library allows for multiple instances of turtles on one display.

Installation for Google Colab:
----
Create an empty code cell and type:

    !pip3 install ColabTurtleClass

Run the code cell. Google Colab will install the library.

Usage
----
In any code cell, import the Window and Turtle classes:

    from ColabTurtleClass.Turtle import Turtle, Window

Create a Window object and turtle objects:

    window = Window()
    bob = Turtle(window)
    joe = Turtle(window)

Note that the constructor for the Window class takes one keyword argument `window_size : tuple` and the constructor for the Turtle class takes one required argument `window : Window` and two keyword arguments `speed : int` and `position : tuple`. To have all turtles drawn on the same display, pass in the same Window object to each new Turtle object.

Example
----

The following code illustrates some usages of the library. For all functions available in this library, please check the API documentation below.

```
from ColabTurtleClass.Turtle import Turtle, Window

window = Window()
bob = Turtle(window)
joe = Turtle(window)
bob.color("blue")
joe.color("red")

for x in range(4):
  bob.forward(100)
  bob.right(90)

joe.penup()
joe.face(180)
joe.forward(150)
joe.pendown()
for x in range(3):
  joe.forward(100)
  joe.right(120)
```

This code ends up with the following drawing:

![Example of two turtles](https://github.com/Abstrqt/ColabTurtleClass/blob/main/example.PNG)

API
----
This module's API is mostly identical to the [ColabTurtle API](https://github.com/tolgaatam/ColabTurtle). Since the code was refactored into classes, some methods can only be called through their respective classes. The methods of the two classes are shown below:

##### Window Class

`bgcolor(colorstring)`
`window_width()`
`window_height()`

##### Turtle Class

`forward(units) | fd(units)`
`backward(units) | bk(units) | back(units)`
`right(degrees) | rt(degrees)`
`face(degrees) | heading(degrees) | setheading(degrees)`
`left(degrees) | lt(degrees)`
`penup() | pu() | up()`
`pendown() | pd()`
`isdown()`
`speed(s)`
`setx(x)`
`sety(y)`
`home()`
`getx() | xcor()`
`gety() | ycor()`
`position() | pos()`
`heading() | getheading()`
`goto(x,y) | setpos(x,y) | setposition(x,y)`
`showturtle() | st()`
`hideturtle() | ht()`
`isvisible()`
`color(colorstring) | pencolor(colorstring)`
`width(w) | pensize(w)`
`distance(x,y)`
`clear()`
`write(obj, align=, font=)`
`shape(sh)`

Credits
----
Tolga Atam - ColabTurtle


text:
---
name: Bug Report
about: Create a report to help us improve

---

Thank you for creating an issue to improve this library! Please check Please check [the current issues](https://github.com/isuPatches/WiseFy/issues) to make sure that the improvement isn't already being worked on.

It will be _EXTREMELY_ helpful if you also take a look at the [sample app](/wisefysample) to see how it behaves and if you can reproduce there.

**Description**
A clear and concise description of the bug.

**Additional context**
Add any other context about the bug here.

**Screenshots**
If applicable, add screenshots to help explain.

**To Reproduce**
Steps to reproduce the behavior:
1. Create WiseFy instance
2. Call '...' method with '...' as params (please include if it's the synchronous or asynchronous API)
3. Witness unexpected behavior

**Expected behavior**
A description of what you expected to happen.

**Actual behavior**
A description of what actually happened

**Additional Information**
 - Device (i.e. Nexus 5x):
 - OS Version (i.e. Android 8.1):
 - Rooted:
 - Using legacy connection logic?:
 - Using legacy search logic?:
 - Reproducible with sample app?:

**Logs**
Please include logs from WiseFy if at all possible.  They can be found with `logging(true)` set on the WiseFy instance and by filtering on 'WiseFy'

repository: project-kotinos/WiseFy

repo_name: project-kotinos/WiseFy


text:
django-yamlfield
================

A Django database field for storing [YAML](http://en.wikipedia.org/wiki/YAML) data

Getting started
---------------

Install this module

```bash
$ pip install django-yamlfield
```

Add it to one of your models.

```python
from django.db import models
from yamlfield.fields import YAMLField

class YourModel(models.Model):
    yaml = YAMLField()
```

That's it! You can now start storing YAML data.

Credits
-------

This module was developed by Ben Welsh, based on Brad Jasper's [django-jsonfield](https://github.com/bradjasper/django-jsonfield).

Other resources
---------------

[![Build Status](https://travis-ci.org/datadesk/django-yamlfield.png?branch=master)](https://travis-ci.org/datadesk/django-yamlfield)
[![PyPI version](https://badge.fury.io/py/django-yamlfield.png)](http://badge.fury.io/py/django-yamlfield)
[![Coverage Status](https://coveralls.io/repos/datadesk/django-yamlfield/badge.png?branch=master)](https://coveralls.io/r/datadesk/django-yamlfield?branch=master)

* Repo: [https://github.com/datadesk/django-yamlfield](https://github.com/datadesk/django-yamlfield)
* Issues: [https://github.com/datadesk/django-yamlfield/issues](https://github.com/datadesk/django-yamlfield/issues)
* Packaging: [https://pypi.python.org/pypi/django-yamlfield](https://pypi.python.org/pypi/django-yamlfield)
* Testing: [https://travis-ci.org/datadesk/django-yamlfield](https://travis-ci.org/datadesk/django-yamlfield)
* Coverage: [https://coveralls.io/r/datadesk/django-yamlfield](https://coveralls.io/r/datadesk/django-yamlfield)

repository: bakatrouble/django-yamlfield

repo_name: bakatrouble/django-yamlfield


text:
# Course Rep Meeting

## WiFi issue

- Whatever problem gather these 3 information:
  - The time
  - The location (exact room)
  - your student ID
  - the issue (brief)

and submit to<EMAIL_ADDRESS>
## Block K smelly

- Urine smell, near the stairs
- Reply given: will investigate further

## Bus open late

- Will be taken into consideration

## Malay guys collecting money from the students in carpark

- Reported to DBKL and Police, people hit and run.

## Carpark, multistorey carpark

- Do not have enough carparks

## Cybercenter PC full

- CyberCenter not enough computers
- Solution: our Dean mentioned that we can use the lab, go to the lab assistant, and ask if there are any empty rooms.

## TARUC Devices

- Increase to 3/4, is it possible to improve it

## TARUC Bus

- Will improve, because TARUC last month short of 7 bus drivers due to injuries, will be improving soon.

## Screen resolution of TARUC DKB

- Will be improved

## Plugs

- management will consider adding more.

## SRC

- President: Ms Althony
- VP: Jia Ern
- Everything: Jun Rong

## General

- Remember to check your email and intranet for announcements, exam times, and so on.
- Exam dates :6-18 Septeber, 9 days
- Examination: Chinese new year, until 4th day. Fifth day will be the exam.


text:
---
title: What cleaning products should I use to protect against COVID-19?
category: keeping-home-safe
layout: post
date: March 20, 2020
source: CDC
promoted: false
source_url: https://www.cdc.gov/coronavirus/2019-ncov/faq.html#anchor_1584388242595
excerpt: Keeping your home safe
---

Clean and disinfect frequently touched surfaces such as tables, doorknobs, light switches, countertops, handles, desks, phones, keyboards, toilets, faucets, and sinks. If surfaces are dirty, clean them using detergent or soap and water prior to disinfection. To disinfect, most common EPA-registered household disinfectants will work. See CDC's [recommendations for household cleaning and disinfection](https://www.cdc.gov/coronavirus/2019-ncov/community/home/cleaning-disinfection.html).

repository: mayonissen/coronavirus-answers

repo_name: mayonissen/coronavirus-answers


text:
# WP-Iconics

##### Use 1800 MaterialDesign Font-Icons in WordPress.

## Info

WP-Iconics provides an easy access to 1800 MaterialDesign Font-Icons. Insert them in your page with simple short codes.

Our code is minified and doesn't impact your site's performance.

## Credits

* [Austin Andrews](https://github.com/Templarian/MaterialDesign) for maintaining Material Design Icons on GitHub

* [Ian Lunn](https://github.com/IanLunn/Hover), the author of Hover, a fantastic css-library to apply the beautiful animations

## License

Copyright 2017 Martin Pfeffer

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.

repository: celoxio/wp-iconics

repo_name: celoxio/wp-iconics


text:
# Options_Calculator_with_Black_Scholes_model
In order to know more information about a stock option, this options calculator with Black-Scholes Model, the first widely used model for option pricing, can provide the call/put option price, d1, d2, and Greek letters. It can assist investors in establishing an option trading strategy.    Certain assumptions must be made due to this calculator is modeled by Black-Scholes model.  * It works on European options that can only be exercised at expiration. * No dividends are paid out during the option’s life. * Stock markets are efficient. The movement of the markets cannot be predicted, and there is continuous trading * There are no transaction and commissions costs in buying the option. * The risk-free rate and volatility of the underlying are known and constant. * The returns on the underlying are normally distributed.

Input variables:

Underlying price (per share)

Strike price of the option (per share)

Time to maturity (years)

Continuously compounding risk-free interest rate (%)

Volatility (%)

Output Variables:

* d1: N(d2), the cumulative density function of normal distribution, is the risk-adjusted probability that the option will be exercised.
* d2: N(d1), the cumulative density function of normal distribution, is the probability of receiving the stock at expiration of the option.

* The Greek letters, including delta, gamma, vega, rho, and theta, represent the sensitivities of the option price to a single –unit change in the value of either a state variable or a parameter.
  - The delta of an option is defined as the rate of change of the option price respected to the rate of the change of underlying asset price.
  -	The gamma is defined as the rate of change of delta respected to the rate of change of underlying asset price.
  -	The vega of an option is defined as the rate of change of the option price respected to the volatility of the underlying asset.
  -	The rho of an option is defined as the rate of the option price respected to the interest rate.
  -	The theta of an option is defined as the rate of change of the option price respected to the passage of time.

Python Resources:

* Pandas: Pandas is a Python package for data analysis. In particular, it offers data structures and operations for manipulating numerical tables and time series.

* Numpy: Numpy is a fundamental package to support for multi-dimensional arrays and matrices. It is not only used for scientific computing, but also for multi-dimensional container of generic data.

* Math: Math provides access to the mathematical functions, such as pi, log, exp, sqrt, and other mathematical functions.

* Statistics: Statistics provides access to the statistics functions, such as norm_pdf, norm_cdf, mean, stdev, and other statistics functions.

* matplotlib.pyplot

* datetime


text:
# PSP (Personal Software Process)
#
#### ¿What is PSP?

> PSP is a structured software development process that is designed to help software engineers better understand and improve their performance by bringing discipline to the way they develop software and tracking their predicted and actual development of the code.
* [More details about PSP]

### Dependencies
- Python > 3.0
- Django >= 3.0
- Database: PostgreSQL

### Installation

Remember to create and configure the parameters of access to the database in the file ```varlocal.py```:

```sh
DB_NAME = ""
DB_USER = ""
DB_PASSWORD = ""
DB_HOST = ""
DB_PORT = ""
```

#### Linux:
```sh
1. python3 -m venv .env
2. source .env/bin/activate
3. pip install -r requirements.txt
4. python manage.py migrate
5. python manage.py runserver
```
#### Windows:
```sh
1. python -m venv .env
2. cd .env/Scripts/
3. activate
4. pip install -r requirements.txt
5. python manage.py migrate
6. python manage.py runserver
```
#
Verify the deployment by navigating to your server address in your preferred browser.

```sh
<IP_ADDRESS>:8000
```

   [More details about PSP]: <https://en.wikipedia.org/wiki/Personal_software_process>

repository: crisboleda/psp

repo_name: crisboleda/psp


text:
---
layout: post
comments: true
title:  "Getting Started with ION-DTN 3.4.0 on FreeBSD"
date:   2016-02-08 03:34:50 +0900
categories: freebsd ion dtn
---
I was reading Wikipedia articles about things like the [interplanetary internet][wikipedia-interplanetary],
[InterPlaNet][wikipedia-ipn] and [delay-tolerant networking][wikipedia-dtn].
After writing a [post on serving web content with tor][freebsd-tor], I wanted to try to serve a web page over ION-DTN.
This post covers installing [ION-DTN][ion-dtn] 3.4.0 on FreeBSD.

After the installation instructions, there are a few usage examples, including a very crude scripted web server.
The original goal was to take an outside web request, send it over ION-DTN to a server on the other side and return the response.
That example deserves a separate post.

Special thanks to Scott C Burleigh for helping me work through some setup problems.

The following are follow ups to this post:

- [ION DTN as a Service on FreeBSD](https://sgeos.github.io/freebsd/ion/dtn/2016/02/15/ion-dtn-as-a-service-on-freebsd.html)
- [Almost Serving a Web Page with ION-DTN bpchat](https://sgeos.github.io/freebsd/ion/dtn/2016/02/12/almost-serving-a-web-page-with-ion-dtn-bpchat.html)
- [Serving a Web Page with ION-DTN bpsendfile and bprecvfile](https://sgeos.github.io/freebsd/ion/dtn/2016/02/17/serving-a-web-page-with-ion-dtn-bpsendfile-and-bprecvfile.html)

## Software Versions
{% highlight sh %}
$ date
February  8, 2016 at 03:34:50 PM JST
$ uname -vm
FreeBSD 11.0-CURRENT #0 r287598: Thu Sep 10 14:45:48 JST 2015     root@:/usr/obj/usr/src/sys/MIRAGE_KERNEL  amd64
$ ionadmin
: v
ION OPEN SOURCE 3.4.0
{% endhighlight %}

## Instructions
First, download and extract the source code.
{% highlight sh %}
wget 'http://downloads.sourceforge.net/project/ion-dtn/ion-3.4.0b.tar.gz'
tar -zxvf ion-3.4.0b.tar.gz
cd ion-open-source/
{% endhighlight %}

Note that ION-DTN requires **gmake** and **bash**.
**autotools** are not required but useful.
{% highlight sh %}
portmaster devel/gmake shells/bash devel/autotools
{% endhighlight %}

The **sysctl_script.sh** script needs to be patched to build IOT-DTN run on FreeBSD.
A number of other files also need to be patched work properly.
These scripts appear to be written for Linux and use **#!/bin/bash** instad of **#!/usr/bin/env bash**.
{% highlight sh %}
sed -i '' 's:#!/bin/bash:#!/usr/bin/env bash:' sysctl_script.sh
find ./ -type f -print0 | xargs -0 sed -i '' 's:#!/bin/bash:#!/usr/bin/env bash:'
{% endhighlight %}

Some of the shared memory values suggested by **sysctl_script.sh** are too low on FreeBSD.
Copy the following lines into **/boot/loader.conf**.
These values are read only tunable and must be set before the
system enters multi-user mode.
{% highlight sh %}
kern.ipc.shmmni=192
kern.ipc.shmseg=128
kern.ipc.semmns=32000
kern.ipc.semmni=128
{% endhighlight %}

Copy the following lines into your choice of  **/boot/loader.conf** or **/etc/sysctl.conf**.
These values are tunable in multi-user mode.
See the chapter in the [FreeBSD Handbook][freebsd-sysctl] for more information.
{% highlight sh %}
kern.ipc.shmmax=536870912
kern.ipc.shmmin=1
kern.ipc.shmall=131072
net.inet.udp.maxdgram=32000
kern.ipc.shm_use_phys=0
kern.ipc.shm_allow_removed=0
{% endhighlight %}

Note that the above tunable values can be changed by root at runtime.
{% highlight sh %}
su
sysctl kern.ipc.shmmax=536870912
{% endhighlight %}

Reboot the system so the new shared memory values will take effect.
{% highlight sh %}
su
shutdown -r now
{% endhighlight %}

Read **README.txt**.
Optionally run **./config -h**.
When you know what you are doing, configure and build.

# System Wide Install

A system wide installation needs to be performed by root.
I also run the build as root because I ultimately
want root to be the owner of the installed files.
Note that by default the man pages are installed in the wrong place on FreeBSD.

{% highlight sh %}
su
./configure --mandir=/usr/local/man
gmake clean
gmake
{% endhighlight %}

Test the build.
**gmake test** should work, but it is configured to test the original Bundle Security Protocol.
The depreciated bsp tests are skipped, so running **gmake test** is pointless.
Instead, Run the following command.
It tests the new not yet standardized Streamlined Bundle Security Protocol.
{% highlight sh %}
(cd tests/; ./runtests sbsp/)
{% endhighlight %}

If the tests pass, perform a system wide install as root.
{% highlight sh %}
gmake install
ldconfig
{% endhighlight %}

# Single User Install

A single user install can be performed by passing the --prefix flag to **configure**.

{% highlight sh %}
./configure --prefix="$HOME/ion" --mandir="$HOME/ion/man"
gmake clean
gmake
(cd tests/; ./runtests sbsp/)
gmake install
{% endhighlight %}

Appended **ion/bin** to **PATH**.
If **ion/bin** is in **$PATH** then **manpath** will look for manpages in **ion/man**.

**~/.profile**
{% highlight sh %}
export "PATH=$HOME/ion/bin:$PATH"
{% endhighlight %}

The ion library path could be added to **LD_LIBRARY_PATH**, but running **ldconfig**
requires root privileges, so this does not make sense for a single user install.
See [this link][freebsd-ld-library-path] for details.

# Documentation

Serve **tutorial.html** and [open](http://localhost:8080/) it in your favorite browser.
Read through the tutorial.
{% highlight sh %}
FILE="tutorial.html"; { printf "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <"$FILE")\r\n\r\n"; cat "$FILE"; } | nc -N -l <IP_ADDRESS> 8080
{% endhighlight %}

Also look at **ION Deployment Guide.pdf** and **ION.pdf**.
Note the **AMS programmer's guide v2.2.pdf** and the Windows related PDFs.

Finally, **man ion**.
{% highlight sh %}
FILE="ION Deployment Guide.pdf"; { printf "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <"$FILE")\r\n\r\n"; cat "$FILE"; } | nc -N -l <IP_ADDRESS> 8080
FILE="ION.pdf"; { printf "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <"$FILE")\r\n\r\n"; cat "$FILE"; } | nc -N -l <IP_ADDRESS> 8080
ls /usr/local/share/ion/
man ion
{% endhighlight %}

# Starting ION

A number of configuration files are required to start ION.
Add the following lines to the specified files.
It is probably a good idea to move to a different directory first.

**host1.ionrc**
{% highlight sh %}
1 1 ''
s
a contact +1 +3600 1 1 100000
a range +1 +3600 1 1 1
m production 1000000
m consumption 1000000
{% endhighlight %}

**host1.ltprc**
{% highlight sh %}
1 32
a span 1 32 32 1400 10000 1 'udplso localhost:1113'
s 'udplsi localhost:1113'
{% endhighlight %}

**host1.bprc**
{% highlight sh %}
1
a scheme ipn 'ipnfw' 'ipnadminep'
a endpoint ipn:1.0 q
a endpoint ipn:1.1 q
a endpoint ipn:1.2 q
a protocol ltp 1400 100
a induct ltp 1 ltpcli
a outduct ltp 1 ltpclo
s
{% endhighlight %}

**host1.ipnrc**
{% highlight sh %}
a plan 1 ltp/1
{% endhighlight %}

**host1.ionsecrc** is not required, but it keeps "Can't find ION security database." from being logged in **ion.log**.
{% highlight sh %}
1
{% endhighlight %}

Create **host1.rc** with the following command.
{% highlight sh %}
ionscript -i host1.ionrc -s host1.ionsecrc -l host1.ltprc -b host1.bprc -p host1.ipnrc -O host1.rc
{% endhighlight %}

Start ION with either of the following commands.
{% highlight sh %}
ionstart -I host1.rc
ionstart -i host1.ionrc -s host1.ionsecrc -l host1.ltprc -b host1.bprc -p host1.ipnrc
{% endhighlight %}

ION can be stopped with the following command.
{% highlight sh %}
ionstop
{% endhighlight %}

## Examples

The following examples can be used to get started.

# Hello World

Enter the follow lines into the terminal.
Hit ^C to exit **bpsink** after verifying the payload has been delivered.
{% highlight sh %}
echo "Hello, World!" | bpsource ipn:1.1
bpsink ipn:1.1
# ^C to exit bpsink
{% endhighlight %}

A slightly unreliable single line hello world example is below.
{% highlight sh %}
{ echo "Hello, World!"; sleep 1; } | bpchat ipn:1.1 ipn:1.1
{% endhighlight %}

# Chat

Use two terminals to enter the following commands.
Enter text and hit enter to transfer the line to the other terminal.
Hit ^C to exit.

{% highlight sh %}
# α terminal
bpchat ipn:1.1 ipn:1.2
# ^C to exit bpchat

# β terminal
bpchat ipn:1.2 ipn:1.1
# ^C to exit bpchat
{% endhighlight %}

# Echo Loop

This modified chat example sets up an echo server.
The server echoes lines back to the client until it receives EOT on a single line.
EOT is piped into the connection after the client is closed with ^C.
The server closes automatically without any manual intervention.

{% highlight sh %}
# α terminal
mkfifo fifo
bpchat ipn:1.1 ipn:1.2 <fifo | sed -u -n "/^$(printf "\4")$/q; p" | tee fifo

# β terminal
bpchat ipn:1.2 ipn:1.1; printf "\4\n" | bpchat ipn:1.2 ipn:1.1
# ^C to exit bpchat
{% endhighlight %}

# Scripted Request-Response: Serving a Web Page Over BP

This is a crude example of using **bpsendfile** and **bprecvfile** to serve a web page over BP.
First, create **index.html**.
Alternatively, use **tutorial.html** or another file.
{% highlight html %}
<!DOCTYPE html>

    <meta charset="utf-8" />
    <title>Hello World!</title>

Hello World!

{% endhighlight %}

Add the following to **server.sh**.
The request is written to **testfile1**.
It also moonlights as the file to be sent.
{% highlight sh %}
#/bin/sh

SOURCE=ipn:1.1
DESTINATION=ipn:1.2
SERVICE_CLASS=0.1
FILE=index.html
CONTENT_TYPE=text/html

while true; do
echo "<<<$((X=X+1))<<<"
bprecvfile $SOURCE 1
REQUEST=$(cat testfile1)
echo "$REQUEST"
# in a real server, do something with the request
echo ">>>${X}>>>"
BODY=$(cat $FILE)
RESPONSE=$(cat <<EOF
HTTP/1.0 200 OK
Content-Type: ${CONTENT_TYPE}
Content-Length: $((${#BODY}+1))
Connection: close

${BODY}
EOF
)
echo "$RESPONSE"
echo "$RESPONSE" > testfile1
bpsendfile $SOURCE $DESTINATION testfile1 $SERVICE_CLASS
done
{% endhighlight %}

Add the following to **request.sh**.
This script is much like **server.sh**, but without the loop.
{% highlight sh %}
#/bin/sh

SOURCE=ipn:1.2
DESTINATION=ipn:1.1
SERVICE_CLASS=0.1

echo "<<<$((X=X+1))<<<"
REQUEST=$(cat <<EOF
GET / HTTP/1.1
Host: www.host.com
Connection: close

EOF
)
echo "$REQUEST"
echo "$REQUEST" > testfile1
bpsendfile $SOURCE $DESTINATION testfile1 $SERVICE_CLASS
echo ">>>${X}>>>"
bprecvfile $SOURCE 1
RESPONSE=$(cat testfile1)
echo "$RESPONSE"
{% endhighlight %}

From different terminals, start the server and make a request.
Note that **request.sh** is run in the current shell so that the request number increases if the command is executed multiple times.
{% highlight sh %}
chmod +x server.sh request.sh

# α terminal
./server.sh

# β terminal
. ./request.sh
{% endhighlight %}

## Unresponsive ION

If ION becomes unresponsive, restart it.
This example abuses ION.
Enter the following in **badserver.sh**.

{% highlight sh %}
#/bin/sh

SOURCE=ipn:1.1
DESTINATION=ipn:1.2
FILE=index.html
CONTENT_TYPE=text/html

while true; do
BODY=$(cat $FILE)
RESPONSE=$(cat <<EOF
HTTP/1.0 200 OK
Content-Type: ${CONTENT_TYPE}
Content-Length: $((${#BODY}+1))
Connection: close

${BODY}
EOF
)
echo "---$((X=X+1))---"
echo "$RESPONSE" | bpchat $SOURCE $DESTINATION
done
{% endhighlight %}

Let **badserver.sh** run until the hello world example stops working.

{% highlight sh %}
# α terminal
chmod +x badserver.sh
./badserver.sh

# β terminal
echo "Hello, World!" | bpsource ipn:1.3
bpsink ipn:1.3
# ^C to exit bpsink
{% endhighlight %}

Receive the data sent from **badserver.sh**.
{% highlight sh %}
bpsink ipn:1.2
# ^C to exit bpsink
{% endhighlight %}

Hold ^C to kill the **badserver.sh** script.
Stopping ION may help **badserver.sh** die faster.
Restart ION and the hello world example should work agian.
{% highlight sh %}
ionstop
ionstart -I host1.rc
echo "Hello, World!" | bpsource ipn:1.3
bpsink ipn:1.3
# ^C to exit bpsink
{% endhighlight %}

If **ionstart** or **ionstop** hangs, run **killm** directly and restart ion.
{% highlight sh %}
killm
ionstart -I host1.rc
{% endhighlight %}

## write failed, filesystem is full

Congratulations!
**ion.log** probably ate up all of your disk space.
Delete it.
{% highlight sh %}
rm ion.log
{% endhighlight %}

## References:
- [ION-DTN, SourceForge, ION-DTN][ion-dtn]
- [ION-DTN, SourceForge, Source Code Download][ion-dtn-download]
- [ION-DTN, SourceForge, Support][ion-dtn-support]
- [ION-DTN, Introduction to DTN][ion-dtn-intro]
- [ION-DTN, RFC 5050 Bundle Protocol Specification][ion-dtn-rfc5050]
- [ION-DTN, dtn-interest Mailing List Archives][ion-dtn-interest]
- [ION-DTN, Re: (dtn-interest) DTN2 manual or tutorials?][ion-dtn-interest-manuals]
- [ION-DTN, Web Archive, DTN Train - Berkeley Open House, October 15, 2004][ion-dtn-train]
- [ION-DTN, ion and dtn2 interoperability configuration][ion-dtn-config]
- [ION-DTN, NASA Astronaut Email - MS-RPC Over HTTP - ION-DTN Module Architecture][ion-dtn-nasa-email]
- [ION-DTN, GitHub ION 2.2.1][ion-dtn-github221]
- [ION-DTN, Interplanetary Overlay Network (ION) Design and Operation V1.12 PDF][ion-dtn-github221-pdf]
- [ION-DTN, Man ion][ion-dtn-man-ion]
- [ION-DTN, Man bp][ion-dtn-man-bp]
- [ION-DTN, Man bpsource][ion-dtn-man-bpsource]
- [ION-DTN, Man bpsink][ion-dtn-man-bpsink]
- [ION-DTN, Man bpchat][ion-dtn-man-bpchat]
- [ION-DTN, Man bpsendfile][ion-dtn-man-bpsendfile]
- [ION-DTN, Man bprecvfile][ion-dtn-man-bprecvfile]
- [ION-DTN, Man bptrace][ion-dtn-man-bptrace]
- [ION-DTN, Man ionsecadmin][ion-dtn-man-ionsecadmin]
- [ION-DTN, Man ionsecrc][ion-dtn-man-ionsecrc]
- [FreeBSD, freebsd server limits question][freebsd-limits]
- [FreeBSD, sysctl options loader.conf or sysctl.conf][freebsd-sysctl-options]
- [FreeBSD, man pages not installed correctly on FreeBSD][freebsd-bad-man]
- [FreeBSD, On FreeBSD, what is the best practice for adding to manpath?][freebsd-manpath]
- [FreeBSD, man manpath][freebsd-man-manpath]
- [FreeBSD, LD_LIBRARY_PATH][freebsd-ld-library-path]
- [FreeBSD Forums, sed not working with -i?][freebsd-sed]
- [FreeBSD Handbook, Tuning with sysctl(8)][freebsd-sysctl]
- [FreeBSD, Single Line Web Server With nc on FreeBSD][freebsd-singlefile-nc]
- [FreeBSD, Getting Started With tor Hidden Services on FreeBSD][freebsd-tor]
- [UNIX, How do I download from SourceForge with wget?][unix-download-sourceforge]
- [UNIX, Extract tar.gz File][unix-tar-gz]
- [UNIX, How to replace a path with another path in sed?][unix-sed]
- [UNIX, Awk/Sed: How to do a recursive find/replace of a string?][unix-sed-all]
- [UNIX, Is there a standard command-line tool for unix for piping to a socket?][unix-pipe]
- [UNIX, Empty the contents of a file][unix-empty-file]
- [UNIX, Single File Elixir Programs][unix-single-elixir]
- [UNIX, What, at the bare minimum, is required for an HTTP request?][unix-minimum-http]
- [UNIX, Pipe multiple commands to a single command with no EOF signal wait][unix-pipe-multiple]
- [UNIX, Netcat without -e? No Problem!][unix-netcat-no-e]
- [UNIX, Using netcat to build a simple TCP proxy in Linux][unix-netcat-tcp-proxy]
- [UNIX, TCP proxy with netcat][unix-tcp-proxy]
- [UNIX, Installing glib in non-standard prefix fails][unix-libtool-clean]
- [Wikipedia, Interplanetary Internet][wikipedia-interplanetary]
- [Wikipedia, InterPlaNet][wikipedia-ipn]
- [Wikipedia, Delay-tolerant networking][wikipedia-dtn]

[ion-dtn]: http://sourceforge.net/projects/ion-dtn/
[ion-dtn-download]: http://sourceforge.net/projects/ion-dtn/files/?source=navbar
[ion-dtn-support]: http://sourceforge.net/p/ion-dtn/mailman/ion-dtn-support/
[ion-dtn-intro]: http://dtnsetup.com
[ion-dtn-rfc5050]: https://tools.ietf.org/html/rfc5050
[ion-dtn-interest]: https://mailarchive.ietf.org/arch/search/?email_list=dtn-interest
[ion-dtn-interest-manuals]: http://www.ietf.org/mail-archive/web/dtn-interest/current/msg03336.html
[ion-dtn-train]: https://web.archive.org/web/20070217092916/http://www.melissaho.com/research/dtn/demo/index.php
[ion-dtn-config]: https://sites.google.com/site/dtnresgroup/home/dtn-bone/use-cases/ion-and-dtn2-interoperability
[ion-dtn-nasa-email]: https://www.topcoder.com/challenge-details/30043039/?type=develop
[ion-dtn-github221]: https://github.com/b/ION
[ion-dtn-github221-pdf]: https://github.com/b/ION/blob/master/ION.pdf
[ion-dtn-man-ion]: http://manpages.org/ion/3
[ion-dtn-man-bp]: http://manpages.org/bp/3
[ion-dtn-man-bpsource]: http://manpages.org/bpsource
[ion-dtn-man-bpsink]: http://manpages.org/bpsink
[ion-dtn-man-bpchat]: http://manpages.org/bpchat
[ion-dtn-man-bpsendfile]: http://manpages.org/bpsendfile
[ion-dtn-man-bprecvfile]: http://manpages.org/bprecvfile
[ion-dtn-man-bptrace]: http://manpages.org/bptrace
[ion-dtn-man-ionsecadmin]: http://manpages.org/ionsecadmin
[ion-dtn-man-ionsecrc]: http://manpages.org/ionsecrc/5
[unix-download-sourceforge]: http://unix.stackexchange.com/questions/86971/how-do-i-download-from-sourceforge-with-wget
[unix-tar-gz]: http://www.cyberciti.biz/faq/linux-unix-bsd-extract-targz-file/
[unix-sed]: http://stackoverflow.com/questions/12061410/how-to-replace-a-path-with-another-path-in-sed
[unix-sed-all]: http://stackoverflow.com/questions/1583219/awk-sed-how-to-do-a-recursive-find-replace-of-a-string
[unix-pipe]: http://stackoverflow.com/questions/576750/is-there-a-standard-command-line-tool-for-unix-for-piping-to-a-socket
[unix-empty-file]: http://unix.stackexchange.com/questions/88808/empty-the-contents-of-a-file
[unix-minimum-http]: http://stackoverflow.com/questions/6686261/what-at-the-bare-minimum-is-required-for-an-http-request
[unix-pipe-multiple]: http://stackoverflow.com/questions/13195285/pipe-multiple-commands-to-a-single-command-with-no-eof-signal-wait
[unix-single-elixir]: https://sgeos.github.io/elixir/erlang/2016/01/08/single-file-elixir-programs.html
[unix-netcat-no-e]: https://pen-testing.sans.org/blog/2013/05/06/netcat-without-e-no-problem
[unix-netcat-tcp-proxy]: http://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html
[unix-tcp-proxy]: http://www.noah.org/wiki/TCP_proxy_with_netcat
[unix-libtool-clean]: http://stackoverflow.com/questions/10279829/installing-glib-in-non-standard-prefix-fails
[freebsd-sysctl]: https://www.freebsd.org/doc/handbook/configtuning-sysctl.html
[freebsd-sysctl-options]: https://lists.freebsd.org/pipermail/freebsd-questions/2005-August/095010.html
[freebsd-limits]: https://lists.freebsd.org/pipermail/freebsd-questions/2012-January/236726.html
[freebsd-sed]: https://forums.freebsd.org/threads/sed-not-working-with-i.12235/
[freebsd-bad-man]: https://github.com/thoughtbot/rcm/issues/131
[freebsd-manpath]: https://www.reddit.com/r/freebsd/comments/3zxa3j/on_freebsd_what_is_the_best_practice_for_adding/
[freebsd-man-manpath]: https://www.freebsd.org/cgi/man.cgi?query=manpath&apropos=0&sektion=0&manpath=FreeBSD+8.0-RELEASE&format=html
[freebsd-ld-library-path]: https://lists.freebsd.org/pipermail/freebsd-questions/2007-March/146062.html
[freebsd-singlefile-nc]: https://sgeos.github.io/freebsd/nc/2016/02/06/single-line-web-server-with-nc-on-freebsd.html
[freebsd-tor]: https://sgeos.github.io/tor/freebsd/nc/curl/2016/02/06/getting-started-with-tor-hidden-services-on-freebsd.html
[wikipedia-interplanetary]: https://en.wikipedia.org/wiki/Interplanetary_Internet
[wikipedia-ipn]: https://en.wikipedia.org/wiki/InterPlaNet
[wikipedia-dtn]: https://en.wikipedia.org/wiki/Delay-tolerant_networking

extension: markdown

gha_language: CSS


text:
---
layout: post
title: Building a simple offline-capable Notepad app using ServiceWorker
---

Today, We are going to build a progressive Notepad app which can very well be used in offline mode, be responsive on all available devices and which saves the content locally on device. So, the core functionality of this Notepad here is to make it work offline. To fulfill this requirement, we'll use [ServiceWorkers](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) which I'm going to cover next.

# Foreward

## What is a ServiceWorker?

_A service worker is a script that runs in the background, separate from your web page. It responds to events, including network requests made from pages it serves. A service worker has an intentionally short lifetime. It wakes up when it gets an event and runs only as long as it needs to process it._

The first and foremost feature ServiceWorkers provides is to give the ability to webapp to work offline. Apart from this ServiceWorkers also includes features like [push notifications](https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web) and [background sync](https://developers.google.com/web/updates/2015/12/background-sync). In the future service workers will support other things like periodic sync or geofencing. The core feature discussed in this tutorial is the ability to intercept and handle network requests, including programmatically managing a cache of responses.

## Now, let's talk about what is a Progressive Web App?

_A Progressive Web App uses modern web capabilities to deliver an app-like user experience. They evolve from pages in browser tabs to immersive, top-level apps, maintaining the web's low friction at every moment._

- This means a progressive web app should be responsive, connection-independent, app-like, fresh, installable and so forth. So, to make our Notepad a progressive web app, we need to include all above features. Let's get started.

# Building the Notepad

Let's start by creating a folder called Notepad in your favorite local web server(in my case I have used [XAMPP](https://www.apachefriends.org/index.html)) and add following files into it:

- `index.html`
- `sw.js` - This where we'll write our ServiceWorker logic
- `manifest.json` - The manifest enables your web app to have a more native-like presence on the user's homescreen. It allows the app to be launched in full-screen mode (without a URL bar being present), provides control over the screen orientation and in recent versions of Chrome on Android supports defining a [Splash Screen](https://developers.google.com/web/updates/2015/10/splashscreen?hl=en) and [theme color](https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android?hl=en) for the address bar. It is also used to define a set of icons by size and density used for the aforementioned Splash screen and homescreen icon.

Now, first thing we will do is register a `ServiceWorker` when our app hits the browser for the first time. For this, create a folder called `js` in root and add file `app.js` into it and add the following code in that file.

<script src="https://gist.github.com/amitmerchant1990/47533b3422bce2d50437d12fba705858.js"></script>

Above code will try to check if the current browser supports `ServiceWorker` and if yes, it will register one. Notice, we have passed a file called `sw.js` in the register function which we haven't created yet.

Create a file called `sw.js` in the root and add the following content into it.

<script src="https://gist.github.com/amitmerchant1990/4d5bb62b795b10cb593e8b585ae8a1a5.js"></script>

Notice, If you want to import any external script in the Service Worker, you can do it using importScripts() . In this example we'll be using the [cache-polyfill](https://github.com/coonsta/cache-polyfill) since the support for cache is limited.

Now, We need to cache all files that we want to be cached the first time `ServiceWorker` registered. In order to do this, we'll add the following content after `var CACHE_VERSION = 'app-v10';` line:

```javascript
var CACHE_FILES = [
    '/',
    'index.html',
    'js/app.js',
    'css/style.css',
    'favicon.ico',
    'manifest.json'
];
```

All this files will get cached for the offline use. Here you can see we call `caches.open()` with our desired cache name(which in our case is `CACHE_VERSION `), after which we call cache.addAll() and pass in our array of files i.e `CACHE_FILES`.

Next, we'll add following content into the file `manifest.json`.

<script src="https://gist.github.com/amitmerchant1990/ea50498abf28cd04083ccc200ac19227.js"></script>

You can see here, we have provided our application name in `short_name`, default orientation for application is `standalone` and we have also provided different sized icons of our application which you can get from [here](https://github.com/amitmerchant1990/notepad/tree/master/img).

Let's now move to the `index.html` and add following content:

<script src="https://gist.github.com/amitmerchant1990/e2d6fb2d92327fec9c7de85122a8137a.js"></script>

So, as you can see here we have taken a textarea and have given it `id`=`note` which we will use to keep track of `onKeyUp` event of textarea. For this, purpose we'll use [jQuery](https://jquery.com/). Let's also note here that, to make the app responsive on all device, we have used [Bootstrap](http://getbootstrap.com/). You can I have included all of the necessary files in `index.html`. You can get all the necessary file from [here](https://github.com/amitmerchant1990/notepad/tree/master/js) and [here](https://github.com/amitmerchant1990/notepad/tree/master/css) and add them to the relevant folders. I have also included file [style.css](https://github.com/amitmerchant1990/notepad/blob/master/css/style.css) which will make some necessary changes on the page to make it responsive.

Now, again move to the file `js/app.js` and add the following content:

<script src="https://gist.github.com/amitmerchant1990/6a4aee82dd4e54296a5c36c44496e5a2.js"></script>

As you can see, we have `bind` the textarea's `propertychange` event so that it will get the text while user types and it to the `localStorage

```javascript
if(localStorage.getItem("note") && localStorage.getItem("note")!=''){
    var noteItem = localStorage.getItem("note")
    $('#note').val(noteItem);
  }
```

Above code will check if there's anything into the `localStorage` and if found will fill the `textarea` with the available content when the next time user visits the website.

Lastly, move to `sw.js` file once again and add all the remaining files into `CACHE_FILES`.

```javascript
var CACHE_FILES = [
    '/',
    'index.html',
    'js/app.js',
    'js/jquery.min.js',
    'js/bootstrap.min.js',
    'css/bootstrap.min.css',
    'css/style.css',
    'manifest.json',
    'img/icon-48.png',
    'img/icon-96.png',
    'img/icon-144.png',
    'img/icon-196.png'
];
```

Putting all above bits and pieces at correct place, our Notepad app is now ready to be used offline. Head over to the [http://localhost](http://localhost) or relevant local web server URL and check the final app.

You can check the whole [codebase](https://github.com/amitmerchant1990/notepad) or checkout the [demo](https://www.amitmerchant.com/notepad/).

Found any typo or want to contribute? Help us improve our documentation by forking and sending your fixes and suggestions. [Improve this Page!](https://github.com/amitmerchant1990/amitmerchant1990.github.io/blob/master/_posts/2016-11-15-Building-Simple-Offline-Notepad-Using-Service-Worker.md)

_Thanks for reading!_


text:
# jwallet-web-storage

Web Storage (API) polyfill. Using following storages in order of priority: localStorage -> cookie -> memory

## Get Started

```
npm install jwallet-web-storage
```

```javascript
const storage = require('jwallet-web-storage')
```

## API

The (Web Storage API)[https://html.spec.whatwg.org/multipage/webstorage.html] provides mechanisms by which browsers can store key/value pairs.

### setItem(key, value)

Adds `key` to the storage, or updates that `key`'s `value` if it already exists.

#### Examples

```javascript
storage.setItem('Key', 'Value')

const objectStorageValue = { foo: 'bar' }
storage.setItem('AnotherKey', JSON.stringify(objectStorageValue))
```

### getItem(key)

Returns that `key`'s value.

#### Examples

```javascript
storage.getItem('Key') //> Value

JSON.parse(storage.getItem('AnotherKey')) //> { foo: 'bar' }
```

### removeItem(key)

Removes `key` from the storage.

```javascript
storage.removeItem('Key')
storage.removeItem('AnotherKey')
```

repository: jibrelnetwork/jwallet-web-storage

gha_language: JavaScript

repo_name: jibrelnetwork/jwallet-web-storage


text:
Lit scmp
========

> safe, constant-time string comparison

This was modified from the node.js version at [freewil/scmp](https://github.com/freewil/scmp).

### Install

```sh
$ lit install james2doyle/scmp
```

### Usage

```lua
local scmp = require("scmp")

assert(scmp('a', 'a'))
assert(scmp('abc', 'abc'))
assert(scmp('e727d1464ae12436e899a726da5b2f11d8381b26', 'e727d1464ae12436e899a726da5b2f11d8381b26'))

-- numbers are converted to strings
assert(scmp(0192873923,<PHONE_NUMBER>))

-- the following 2 examples will fail
assert(scmp('shouldfail', 'dontpass'), "this should fail")

assert(scmp({0192873923, "something else"}, {0192873923, "something else"}))
```


text:
# node-oauth1

This is an implementation of OAuth-1.0a signatures, originally by Netflix, Inc.

# Installation

Install using
```
$ npm install node-oauth1
```

# License
Apache-2.0


text:
# Nemania maculosa (J.D. Rogers, Callan & Samuels) G.J.D. Sm. & K.D. Hyde, 2001 SPECIES

#### Status
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Fungal Diversity 7: 118 (2001)

#### Original name
Hypoxylon maculosum J.D. Rogers, Callan & Samuels, 1987

### Remarks
null

repository: mdoering/backbone

repo_name: mdoering/backbone


text:
---
layout: single
permalink: /workshop/emip-2017-program/
header:
title: "EMIP 2017 Workshop - Program"
sidebar:
  nav: "emip-2017"
---
# Wednesday
16:45 Get-Together at [Currywurst Museum](http://currywurstmuseum.com/en/?noredirect=en_US) (Schützenstraße 70, 10117 Berlin)

18:15 Pre-Workshop Dinner at [Casa Italia](http://www.casaitalia-berlin.de/en/restaurant/check-point-charlie-berlin-germany.html) (Friedrichstraße 200, 10117 Berlin)

# Thursday
9:00 – 10:00 Registration, Coffee

10:00 – 10:45 Keynote
Eye Movements as Measures of Cognitive Processing of Text and Image when Reading Comics – *Jochen Laubrock*

11:00 – 12:00 World Café

- Text Species in Computer Science – *Lea Budde, Birte, Heinemann, Carsten Schulte*
- Do Computer Programmers With Dyslexia See Things Differently? A Computational Eye Tracking Study – *Ian McChensney, Raymond Bond*
- Ambient and Focal Attention During Source-code Comprehension – *Pavel Orlov*
- Comparing Novice and Expert Eye Movements during Program Comprehension – *Johannes Hofmeister, Jennifer Bauer, Janet Siegmund, Sven Apel, Norman Peitek*

12:00 – 13:30 Lunch

13:30 – 14:30 Talks

- Scanpath comparison with the use of web applications SMI2OGAMA and ScanGraph – *Stanislav Popelka, Jitka Dolezalova*
- Towards robust data from program comprehension studies with fine-grained interaction monitoring and eye tracking – *Martin Konopka, Jakub Hucko, Jozef Tvarozek, Pavol Navrat*

14:30 – 15:00 Coffee

15:00 – 16:00 World Café II

- Enhancing fMRI Studies of Program Comprehension with Eye-Tracking – *Norman Peitek, Janet Siegmund, André Brechmann*
- Evaluating the Readability of Example Programs for Novice Programmers – *James Paterson*
- Looking at Indentation. Analysing Gaze Movement during Program Comprehension with Indentations – *Jennifer Bauer, Johannes Hofmeister, Janet Siegmund*
- The Block Sequence Viewer – *Birte Heinemann, Lea Budde, Carsten Schulte*

16:00 – 16:30 Coffee

16:30 – 17:30 Talks / Demo

- Investigating Eye Movements in Natural Language and C++ Source Code – A Replication Experiment – Patrick Peachock, Bonita Sharif
- Distributed Data Collection
- Wrap-Up / Feedback

18:00 – 21:00 Workshop dinner at [Luise](http://luise-dahlem.de/) (Königin-Luise-Straße 40 – 42, 14195 Berlin)

# Friday
9:30 – 10:15 Talks

- The effect of syntax highlighting on source code reading – *Tanya Beelders*
- Automatic AOI detection in stimulus texts using eyeCode – *Teresa Busjahn*
eyeCode: [https://github.com/synesthesiam/eyecode](https://github.com/synesthesiam/eyecode)
Materials: [EMIP17_eyecode.zip](/assets/EMIP17_eyecode.zip) (extract to eyecode/examples)
10:15 – 10:30 Coffee

10:30 – 12:00 Introduction into BeGaze – Markus Plank (SMI)

12:00 – 12:30 Closing session

12:30 Optional lunch


text:
---
description: 'Getting started with the first of the Primitive modules: Option.'
---

# Option Module

## Option Primitive

The option module contains the **option contract primitive,** an ERC-20 token that is extended to match the specification of a vanilla option.

## Option Factory

The module has a factory system so that new option series are deployable on-chain in a decentralized way. This factory system uses several libraries in order to accomplish very gas cheap deployments of new option contracts.

## Interactions with Option

The `Trader` is a proxy contract designed to be a simple entry point for a user into the option contract to call its individual functions. For example, a user who wants to mint options can call the `safeMint` function in the `Trader` contract and it will handle the appropriate checks and operations for interacting with the low-level **option contract primitive.** The `Trader` contract uses the `TraderLib` library and is stateless. It only handles transferring tokens and calling the appropriate functions.


text:
# kendallRandomWalks 0.9.4

* Print and plot methods for the result of summarise_kendall_rw function.
* Finished vignettes.

# kendallRandomWalks 0.9.3

* `EnvStats` dependency replaced by `actuar`.

# kendallRandomWalks 0.9.2

* Functions for transformations and summaries of simulations of Kendall random walks
  (`summarise_kendall_rw` and `mutate_kendall_rw`).
* Name changed to kendallRandomWalks

# kendallRandomPackage 0.9.1

* Numerical computation of G function (so also Williamson transform)
* Exact distribution of first ladder moments

# kendallRandomPackage 0.9.0

* Generic function for printing and plotting simulation objects
* Barrier crossing simulations and visualizations

# kendallRandomPackage <IP_ADDRESS>00

* Added a `NEWS.md` file to track changes to the package.

repository: mstaniak/kendallRandomPackage

repo_name: mstaniak/kendallRandomPackage


text:
### [CVE-2017-18129](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-18129)
![](https://img.shields.io/static/v1?label=Product&message=Snapdragon%20Automobile%2C%20Snapdragon%20Mobile&color=blue)
![](https://img.shields.io/static/v1?label=Version&message=n%2Fa&color=blue)
![](https://img.shields.io/static/v1?label=Vulnerability&message=Improper%20Access%20Control%20in%20TrustZone.&color=brighgreen)

### Description

In Android before security patch level 2018-04-05 on Qualcomm Snapdragon Automobile and Snapdragon Mobile MDM9206, MDM9607, SD 845, MSM8996, MSM8998, it is possible for IPA (internet protocol accelerator) channels owned by one security domain to be controlled from other domains.

### POC

#### Reference
- http://www.securityfocus.com/bid/103671

#### Github
- https://github.com/ARPSyndicate/cvemon

repository: trickest/cve

repo_name: trickest/cve


text:
## Markdown to multipart MIME

Answering the age-old debate: HTML or plaintext emails? Both!

Write email in markdown, and convert to multipart MIME that works impeccably in
graphical and console mail clients.

* Creates a conservative [ISO/IEC 15445:2000
  HTML](https://www.iso.org/standard/27688.html) representation, which is set
  as the preferred multipart alternative for graphical clients.
* The text alternative is reflowed at 72 characters to look good in standard
  console mail readers.
* The text part also uses format=flowed, so it will shrink on narrow screens or
  terminal splits.
* Fenced code blocks in the markdown are added as inline attachments with the
  appropriate MIME type. This makes them easy to download/save from the
  message.
* URLs are listed at the bottom of the text message in a special
  `text/uri-list` inline attachment, and referred to with short codes like
  `[0]`, `[1]` ... in the message text.

### Installation

Written in portable C99. The only requirement is the
[cmark](https://github.com/commonmark/cmark) library to parse markdown.

```sh
# detect cmark and set up build flags
./configure
# then build md2mime
make
```

### Usage

```sh
./md2mime sender-domain.com < message.md > message.email
```

The sender domain is required to generate a good Message-ID.

If the original message starts with headers, pass `-p` to preserve them. Send
the message using a program like [msmtp](https://marlam.de/msmtp/):

```sh
msmtp<EMAIL_ADDRESS>< message.email
```

license: ISC

repository: ibuys/mimedown

repo_name: ibuys/mimedown


text:
---
layout: page
title: Domestic Labor
description: This is what domestic slavery was like.
background: '/img/slave3.jpg'
---

Like the rest of the of the Middle East, slaves of both genders were commonly employed as servants and household laborers. Slaves performed a variety of household tasks, including cooking and cleaning, coffee making, and child-rearing.

**Come back to this page to find more insight on:**
* What domestic slavery entailed
* What domestic slavery looked like.
* The experiences of domestic slaves.
* Statements from domestic slaves

repository: galshaif/African-Arab-SlaveTrade

repo_name: galshaif/African-Arab-SlaveTrade


text:
---
title: Ex. 17.9
linktitle: Ex 17.9
type: book
date: "2021-01-02T00:00:00+01:00"
# Prev/next pager order (if `docs_section_pager` enabled in `params.toml`)
weight: 1
toc: false
---

???+ question "Ex. 17.9"
	Suppose that we have a Gaussian graphical model in which some or all of the data at some vertices are missing.

    (a) Consider the EM algorithm for a dataset of N i.i.d. multivariate observations $x_i\in\mathbb{R}^p$ with mean $\mu$ and covariance matrix $\bm{\Sigma}$. For each sample $i$, let $o_i$ and $m_i$ index the predictors that are observed and missing, respectively. Show that in the E step, the observations are imputed from the current estimates of $\mu$ and $\bm{\Sigma}$:

    \begin{equation}
		\hat x_{i,m_i} = E(x_{i,m_i}|x_{i, o_i}, \theta) = \hat{\mu}_{m_i} + \hat\Sigma_{m_i,o_i}\hat\Sigma_{o_i,o_i}^{-1}(x_{i,o_i}-\hat\mu_{o_i})\non
	\end{equation}

    while in the M step, $\mu$ and $\bm{\Sigma}$ are re-estimated from the empirical mean and (modified) covariance of the imputed data:

    \begin{eqnarray}
		\hat\mu_{j} &=& \sum_{i=1}^N\hat x_{ij}/N\non\\
		\hat\Sigma_{jj'} &=& \sum_{i=1}^N[(\hat x_{ij}-\hat\mu_{ij})(\hat x_{ij'}-\hat \mu_{j'}) + c_{i,jj'}]/N\non
	\end{eqnarray}

    where $c_{i,jj'}=\hat\Sigma_{jj'}$ if $j, j'\in m_i$ and zero otherwise. Explain the reason for the correction term $c_{i, jj'}$ (\cite{little2019statistical}).

    (b) Implement the EM algorithm for the Gaussian graphical model using the modified regression procedure from Exercise 17.7 for the M-step.

    (c) For the flow cytometry data on the book website, set the data for the last protein Jnk in the first 1000 observations to missing, fit the model of Figure 17.1, and compare the predicted values to the actual values for *Jnk*. Compare the results to those obtained from a regression of *Jnk* on the other vertices with edges to *Jnk* in Figure 17.1, using only the non-missing data.

??? done "Soln. 17.9"
	(a) In the E-Step, the imputed estimate for missing variables follows directly from equation (17.16) in the text. In the M-Step, it's easy to see that $\hat\mu$ is the average of imputed observations. Specifically, if $x_{ij}$ is not missing, $\hat x_{ij} = x_{ij}$, otherwise, the imputed (conditional mean) $E[x_{ij}|x_{i, o}, \theta]$ is used.

	For $\Sigma$, recall (17.11) in the text, the maximum likelihood estimate is simply the (modified) covariance $\bb{S}$ (see, e.g., (17.10)), where the additional correction term $c_{i, jk}$ results from the imputation of missing values by their conditional expectations.

	(b) Note that if the graph is complete, then we could just use equations derived in (a) for the EM algorithm. When the graph is not complete, we need to use Algorithm 17.1 implemented in [Ex. 17.7](ex17-07.md) to estimate $\Sigma$.

	(c) The imputed 1000 values from EM algorithm has a mean of -38.65, while the true mean is -33.20, the mean square error is around 1972.32.

??? example "Code"
    ```python
    import pandas as pd
    import numpy as np
    import pathlib
    from sklearn.metrics import mean_squared_error
    from GraphicalGaussian import GraphicalGaussian, GraphicalGaussianEM

    # get relative data folder
    PATH = pathlib.Path(__file__).resolve().parents[1]
    DATA_PATH = PATH.joinpath("data").resolve()

    # data
    X = pd.read_csv(DATA_PATH.joinpath("cytometry_data.csv"), header=0)
    X = np.asarray(X)
    """
    Gamma: represents network in Figure 17.1
        X1 - X11 are in the following order
        Raf, Mek, Plcg, PIP2, PIP3, Erk, Akt, PKA, PKC, P38, Jnk
            -0.55 & 0.36 & 0 & 0 & 0 & 0 & -0.0048 & 0.00046 & 0 & -6.5 & 0
        if two nodes i, j are connected, Gamma[i][j] = 0, else Gamma[i][j] = 1
    """
    Gamma = pd.read_csv(DATA_PATH.joinpath("cytometry_gamma.csv"), header=0)
    Gamma = np.asarray(Gamma)

    # set first 1000 Jnk as NaN
    X_jnk = X.copy()
    X_jnk[np.arange(1000), -1] = np.nan

    model_EM = GraphicalGaussianEM()
    model_EM.fit(X_jnk, Gamma)
    cov_EM = model_EM.covariance_
    est_X = model_EM.imputed_X

    est_values, true_values = est_X[np.arange(1000), -1], X[np.arange(1000), -1]
    print('Estimated mean is {} vs actual mean is {}'.format(np.mean(est_values), np.mean(true_values)))
    print('MSE is {}'.format(mean_squared_error(est_values, true_values)))

    # drop missing value
    X_drop = X.copy()
    X_drop = X[1000:, :]

    model = GraphicalGaussian(verbose=True)
    S = np.cov(X_drop, rowvar=False)
    model.fit(S, Gamma)

    print('The norm of the difference between to estimated covariance matrix is {}'
        .format(np.linalg.norm(model.covariance_ - cov_EM)))
    ```


text:
# procyy

A simple process management library for C++ on UNIX platforms.

This is a reincarnation of small, simple and easy to use library
[procxx](https://github.com/skystrife/procxx) that seems to be abandoned.

## Usage
Here is a simple (toy) example of setting up a very basic pipeline.

```cpp
// construct a child process that runs `cat`
procyy::process cat{"cat"};

// construct a child process that runs `wc -c`
procyy::process wc{"wc", "-c"};

// set up the pipeline and execute the child processes
(cat | wc).exec();

// write "hello world" to the standard input of the cat child process
cat << "hello world";

// close the write end (stdin) of the cat child
cat.close(procyy::pipe_t::write_end());

// read from the `wc -c` process's stdout, line by line
std::string line;
while (std::getline(wc.output(), line))
    std::cout << line << std::endl;
```

procyy also provides functionality for setting resource limits on the
child processes, as demonstrated below. The functionality is implemented
via the POSIX `rlimit` functions.

```cpp
procyy::process cat{"cat"};
procyy::process wc{"wc", "-c"};

// OPTION 1: same limits for all processes in the pipeline
procyy::process::limits_t limits;
limits.cpu_time(3);         // 3 second execution time limit
limits.memory(1024*1024*1); // 1 MB memory usage limit
(cat | wc).limit(limits).exec();

// OPTION 2: individual limits for each process
procyy::process::limits_t limits;
limits.cpu_time(3);         // 3 second execution time limit
limits.memory(1024*1024*1); // 1 MB memory usage limit
wc.limit(limits);

procyy::process::limits_t limits;
limits.cpu_time(1);  // 1 second execution time limit
limits.memory(1024); // 1 KB memory usage limit
cat.limit(limits);

(cat | wc).exec();
```

## A note about SIGPIPE signal

When the parent process interacts with a child via pipes there can be a case of
reading/writing from/to closed pipe. For example, the parent tries to write
another portion of data to the standard input stream of a child process, but
the child is already died.

Unix sends SIGPIPE signal in that case. And the default reaction to that
signal is the termination of the application.

It's important to note that procyy doesn't install SIGPIPE handlers.
So it's a task of an application to install an appropriate SIGPIPE
handler before the use of procyy.

# Differences from the original procxx

## procyy namespace instead of procxx namespace

The whole content of library is now in `procyy` namespace instead of `procxx`.
So it's necessary to do search and replace during the switch to procyy.

## There are throwing and non-throwing methods

Some methods of procyy's classes now have two forms. The first one throws
exceptions and looks like in procxx.

The second form doesn't throw exceptions and returns either `std::error_code`
or `std::pair<std::error_code, some-type>`.

## There is no throwing pipe_t::read method

This method has been removed. Only non-throwing `pipe_t::read` is available
now.

If you need throwing version of `pipe_t::read` method please open an issue.

## The constructor of pipe_t::pipe_end doesn't throw now

The constructor of `pipe_t::pipe_end` in procxx accepts `unsigned int` and
throws an exception for an invalid value.

In procyy constants `pipe_t::READ_END` and `pipe_t::WRITE_END` have type
`pipe_t::pipe_end_enum` and is not `unsigned int` anymore. The constructor of
`pipe_t::pipe_end` now accepts `pipe_end_enum` instead of `unsigned int` and
doesn't check the passed value. So there is no need to throw an exception.

## Non-throwing methods are used during process instance cleanup

The procxx library had an issue: throwing versions of `flush` and `close`
methods were called during the cleanup of `process` instances. This leads to the
termination of the application if the destructor of `process` throws during the
stack unwinding due to another exception.

The procyy use non-throwing methods in `procyy::process` cleanup routines.

## Another overload of process::exec

There is another overload of `process::exec` that accepts a callback. This
callback will be called just after a successful return from `fork`. Callback
will be called in the parent and the child processes.

```cpp
procyy::process ping( "ping", "www.google.com", "-c", "2" );
ping.exec( [](procyy::process::hook_place where) {
    if(procyy::process::hook_place::child == where)
    {
        // This is callback in the child process.
        std::cout << "Child PID: " << getpid() << std::endl;
        std::cout << "Parent PID: " << getppid() << std::endl;
    }
} );
```

This callback can throw exceptions in the child process. In that case the work
of the child process will be finished (an `execvp` in the child process won't
be called).

If a callback function throws in the parent process then the exception thrown
will just be ignored.

## There is no free function running(process)

There is no more free function `running()` that accepts a reference to
`process` class. The `process::running()` method should be used instead.  It's
becase `running` can change the state of `process` instance (`waitpid` is
called inside `running` and this call changes `waited` flag inside `process`
instance).

## An extended way of posting errors from a child process to the parent

The procxx library uses additional pipe to report of `execvp` call error to the
parent process. Only one integer value is sent to that pipe in the case of an
error.

The procyy library uses the same scheme, but additional data can be posted from
a child to the parent process. For example, if an exception is thrown during
the preparation to `execvp` call then some description of that error will be
written to that pipe (if the exception class is derived from `std::exception`
this additional data will be the first 127 bytes of string returned by
`std::exception::what()`.

## Usage of pipe2 in this version of procyy

The procxx library has `PROCXX_HAS_PIPE2` feature macro and use `pipe2` call in
the constructor of `pipe_t` class if `PROCXX_HAS_PIPE2` is defined to non-zero
value. And `PROCXX_HAS_PIPE2` is defined to 1 by default without an attempt to
detect the current platform and the presence of `pipe2` call.

The procyy library has the similar `PROCYY_HAS_PIPE2` macro, but if it is not
definied explicitly then procyy tries to detect the platform. If it is Linux or
FreeBSD 10 or above then `PROCYY_HAS_PIPE2` will be automatically defined to 1
and `pipe2` call will be used in the constructor of `procyy::pipe_t` class.

If `PROCYY_HAS_PIPE2` is explicitly defined to 0, or if procyy is compiled on
some different platform (like macOS) then `pipe`+`fcntl` will be used in the
constructor of `procyy::pipe_t` class.

If such behaviour is an issue for you please provide a PR.

### std::mutex is not used around a call to pipe()

The procxx library uses a fallback to a sequence of `pipe` and `fcntl` calls if
`pipe2` is not available. This sequence is guarded by a static mutex instance.
This guard is intended to add some safety for multithreaded code (see some
explanations
[here](https://github.com/skystrife/procxx/commit/afe17ba37341528bbbee9d96c5b68b1fe154fad3)).

But the problem is that I don't understand how this mutex can prevent the leak
of pipe descriptors if another thread performs `fork`+`execvp`.

So I think this mutex is just useless. And because of that the constructor if
`procyy::pipe_t` doesn't use a lock of a mutex around calls to `pipe`+`fcntl`.

## procyy doesn't use perror

The procxx library uses `perror` in several places for error logging. It leads to
messages like "Broken pipe" on the standard error stream of your application.

The procyy library doesn't use `perror` at all.

## Since 20211003 there is no process::append_arguments method

It seemed that the old process::append_arguments worked not as expected by an ordinary user. That method constructed just one argument and initialized that argument with the help of two iterators (`first` and `last`).

Method `process::append_arguments` was removed in 20211003. Since then, there have been two new methods:

```cpp
// Adds just one argument and initilizes it via `args`.
template< typename... Args >
void emplace_argument(Args && ...args);

// Adds several arguments.
template< typename ForwardIterator >
void add_some_arguments(ForwardIterator first, ForwardIterator last);
```


text:
JPMedier template scala, play and slick
=================================

This project is based on our current knowledge of how to best make a json-estful api on scala, play and slick.
To create a new project, copy the contents of this project, delete the .git directory and create a new git repo.
For now this is the best way to start a new project, maybe in the future, we might create an activator template.

Database Access
===============
If you have an existing database, you can generate dataaccess classes by running `sbt gen-tables`. The classes will be generated under `target/src_managed`
It is recommended to copy the generated files under `app/models`and delete the content in `target`
A docker container, with mysql, can be started by running `./start_db.sh`, this can be used for dev and test, you should probably rename the container and the database. This can be done by replacing the names in `./start_db.sh` and the corresponding in `application.conf` and `application.test.conf`.
The database is created with user "root" and password "password", this is fine for dev and test and of course not for prod.

Running the app
===============

To run the app: `sbt run`, this assumes that the environment variables in `application.conf` are set.
To run the tests run `sbt test` sbt can run tests when files changes this can be done by entering a sbt session and issuing the command `~test`.

Controllers
===========

This template contains only one controller: The HealthController.
In this template you will find that is simply always returns ok, it is recommended to have the health endpoint also check that the services needed by the app are up and runing.

Components
==========

- Module.scala:

  Shows how to use Guice to bind all the components needed by your application.

Filters
=======
The LoggingFilter will log all requests.

Best practices
===============
 - Unless you have a very good reason, you should always make your controller actions async.
 - The only place in your codebase where you should allow async.await is in tests/

repository: kasperfjensen/jpmedierTemplate

repo_name: kasperfjensen/jpmedierTemplate


text:
# python-jquery-web-server
Old Fashioned, yet very simple web server with optional authentication

## Install
```bash
pip install -r requirements.txt
```

## Run
```bash
python3.6 backend/server.py 9999
```

## Run with Auth
```bash
python3.6 backend/server.py 9999 user:psw
```

repository: fran-babylon/python-jquery-web-server

repo_name: fran-babylon/python-jquery-web-server


text:
# traefik-plugin-shellexec

[![Build Status](https://github.com/tommoulard/traefik-plugin-shellexec/workflows/Main/badge.svg?branch=master)](https://github.com/tommoulard/traefik-plugin-shellexec/actions)

WIP

> This plugin is not currently possible
> since [Yaegi](https://github.com/traefik/yaegi) does not support [yet](https://github.com/traefik/yaegi/issues/1129) the `os/exec` package.

This is a plugin for [Traefik](https://traefik.io) which terminates a connection by executing a shell script.

## Usage

### Configuration

For now, there is no configuration required.

Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the `http.middlewares` section:

```yaml
# Dynamic configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - traefik-plugin-shellexec

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://<IP_ADDRESS>:5000

  middlewares:
    traefik-plugin-shellexec:
      plugin:
        traefik-plugin-shellexec:
          enabled: true
```

### Running

Once you have a running instance of this plugin, you can call the middleware with a `POST` request.
Arguments on how to run commands on the host are provided using the body of the request.

The body can look like:
```json
{
  "command": "cat -",
  "stdin": "test"
}
```

The equivalent of this request is: `echo "test" | cat -`.

The output of this request will result in:

```json
{
  "return_code": "0",
  "stderr": "",
  "stdout": "test"
}
```

### Dev Mode

Traefik also offers a developer mode that can be used for temporary testing of plugins not hosted on GitHub.
To use a plugin in dev mode, the Traefik static configuration must define the module name (as is usual for Go packages) and a path to a [Go workspace](https://golang.org/doc/gopath_code.html#Workspaces), which can be the local GOPATH or any directory.

```yaml
# Static configuration
pilot:
  token: xxxxx

experimental:
  devPlugin:
    goPath: /plugins/go
    moduleName: github.com/tommoulard/traefik-plugin-shellexec
```

(In the above example, the `shellexec` plugin will be loaded from the path `/plugins/go/src/github.com/tommoulard/traefik-plugin-shellexec`.)

#### Dev Mode Limitations

Note that only one plugin can be tested in dev mode at a time, and when using dev mode, Traefik will shut down after 30 minutes.

## TODO

 - Support more than `POST` requests
    - Query params
    - Headers
 - add more data to response
    - Time spent doing the command (can use `time` for now)
    - pid of the process (can use `$!` for now)
    - env (can use `env` for now)

repository: tomMoulard/traefik-plugin-shellexec

repo_name: tomMoulard/traefik-plugin-shellexec


text:
Molecular biology gets wikified
===============================

  [@wikidata:Q104161380]

# Highlights

Earlier this week, bioinformatics experts announced the creation of a Wikipedia-style database that allows anyone to create and amend a repository of complex biochemical pathways. The database, called WikiPathways, joins WikiGene, Protein Data Bank Wiki, and WikiProteins, not to mention a host of other wikis used by individual labs and smaller communities of researchers.

"Right now, it’s the large sequencing centres that are distributing the information,” says Andrew Su, a bioinformaticist at the Genomics Institute of the Novartis Foundation in San Diego, California. “The scientist working on their one protein at the bench doesn’t have a way to participate in that process.”

On 28 May, researchers unveiled a protein annotation database called WikiProteins2. The database, spearheaded by Barend Mons at the Erasmus Medical Centre in Rotterdam, the Netherlands, stops short of becoming a chaotic wiki free-for-all by requiring that data be entered into specific categories, such as protein function, and by noting those who participate in the editing.

This structured approach makes the data easier to mine, but some argue that the structure can limit participation. “The more structure you add, it can become an activation barrier to having people contribute content,” says Su.

Instead, Su and his collaborators have taken a much more grass-roots approach. They simply created Wikipedia pages corresponding to individual human genes – about 7,500 in all – and modified the format of the 650 gene pages which already existed, before inviting researchers to annotate each gene with information about its function and the role of the protein it encodes.

In 2006, Kai Wang, then a bioinformatics graduate student at the University of Washington in Seattle, wrote a letter to Nature 5 urging the community to create wiki-based gene annotation tools. Now a postdoc at the Children’s Hospital of Philadelphia in Pennsylvania, Wang says he has not yet contributed to any of the new wikis. “There are too many of them to invest a lot of time to test drive every single one of them.

“WikiPathways would live on if I got hit by a truck tomorrow,” he says. “Or if our entire team were to decide to go work for Google.

# Comments
I'd very much love to see a Wiki Cell Types initiative.

# Links

 * [Scholia Profile](https://scholia.toolforge.org/work/Q104161380)
 * [Wikidata](https://www.wikidata.org/wiki/Q104161380)
 * [TABernacle](https://tabernacle.toolforge.org/?#/tab/manual/Q104161380/P921%3BP4510)

license: Unlicense

gha_license_id: NOASSERTION


text:
# Yii 2 Advanced Package Template

Yii 2 Advanced Package Template is a skeleton [Yii 2](http://www.yiiframework.com/) package best for
developing complex composer packages with migrations and unit tests.

[![Latest Stable Version](https://poser.pugx.org/horat1us/yii2-advanced-package/v/stable.png)](https://packagist.org/packages/horat1us/yii2-advanced-package)
[![Total Downloads](https://poser.pugx.org/horat1us/yii2-advanced-package/downloads.png)](https://packagist.org/packages/horat1us/yii2-advanced-package)
[![Build Status](https://travis-ci.org/Horat1us/yii2-advanced-package.svg?branch=master)](https://travis-ci.org/Horat1us/yii2-advanced-package)
[![codecov](https://codecov.io/gh/Horat1us/yii2-advanced-package/branch/master/graph/badge.svg)](https://codecov.io/gh/Horat1us/yii2-advanced-package)

## Installation

### As dependency
- install using composer
```bash
composer require horat1us/yii2-advanced-package
```
- add to your `bootstrap.php`:
```php
<?php
// bootstrap.php

Yii::setAlias(
    '@Horat1us/Package/Migrations', // your namespace here
    "path-to-vendor/horat1us/yii2-advanced-package/migrations" // path to package migrations folder
);
```
- add to your console `config.php`:
```php
<?php
// console/config.php

use yii\console\controllers\MigrateController;

return [
    // some code

    'controllerMap' => [
        'migrate' => [
            'class' => MigrateController::class,
            'migrationNamespaces' => [
                'Horat1us\\Package\\Migrations',
            ],
        ],
    ],
];
```

### As new project
```bash
composer create-project horat1us/yii2-advanced-package path-to-new-project
```
then you need to change project name in composer.json and modify namespaces

## Tests
Run tests:
```bash
./vendor/bin/phpunit
```

## Configuration
Default project configuration available in [tests/config.php](./tests/config.php).
If you want to use local config just create `tests/config-local.php` with configuration array.

## Structure

```
migrations/     contains namespaced migrations (using Yii2 namespace autoloader)
src/            contains all source files (using composer autoloader)
tests/
    Mocks/          contains mocks for tests
    Fixtures/       contains Yii2 fixtures
    Unit/           contains PHPUnit tests
vendor/                  contains dependent 3rd-party packages
```
## License
[MIT](./LICENSE)


text:
[![Continuul][logo]](https://continuul.solutions)

# go-archetype [![Slack Community](https://img.shields.io/badge/slack-@continuul/green.svg?logo=slack)](https://slack.continuul.com) [![Go Report Card](https://goreportcard.com/badge/github.com/continuul/go-archetype)](https://goreportcard.com/report/github.com/continuul/go-archetype)

Archetype is a project templating toolkit. An archetype is defined as an
original pattern or model from which all other things of the same kind are made.
Archetype is a system that provides a consistent means of generating projects of
virtually any kind.

Using archetypes provides a great way to enable developers quickly in a way
consistent with best practices employed by your project or organization.  We use
archetypes to try and get our users up and running as quickly as possible by providing a
sample project while introducing new users to current best practices. In a matter of
seconds, a new user can have a working project to use as a jumping board for their
work.

## Installation

```bash
go install github.com/continuul/go-archetype
```

## Usage

```
Archetype is a project templating toolkit. An archetype is defined as an
original pattern or model from which all other things of the same kind are made.
Archetype is a system that provides a consistent means of generating projects of
virtually any kind.

Using archetypes provides a great way to enable developers quickly in a way
consistent with best practices employed by your project or organization.  We use
archetypes to try and get our users up and running as quickly as possible by providing a
sample project while introducing new users to current best practices. In a matter of
seconds, a new user can have a working project to use as a jumping board for their
work.

Usage:
  go-archetype [command]

Available Commands:
  generate    Generate a starter project from an archetype
  help        Help about any command
  list        List the available archetypes
  version     Print version information

Flags:
      --config string   config file (default is $HOME/.go-archetype.yaml)
  -h, --help            help for go-archetype
  -t, --toggle          Help message for toggle

Use "go-archetype [command] --help" for more information about a command.

```

## Related Projects

None.

## Help

**Got a question?** We got answers.

File a GitHub [issue](https://github.com/continuul/go-archetype/issues), or join our [Slack Community][slack].

## Slack Community

Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "Continuul" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *continuul* infrastructure.

## Contributing

### Bug Reports & Feature Requests

Please use the [issue tracker](https://github.com/continuul/go-archetype/issues) to report any bugs or file feature requests.

### Developing

If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you!

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

 1. **Fork** the repo on GitHub
 2. **Clone** the project to your own machine
 3. **Commit** changes to your own branch
 4. **Push** your work back up to your fork
 5. Submit a **Pull Request** so that we can review your changes

**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!

## License

[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

## About

[Continuul Solutions][website] maintains and funds this project.

  [logo]: https://avatars3.githubusercontent.com/u/57697117?s=60&v=4
  [website]: https://continuul.solutions
  [slack]: https://slack.continuul.com

  [100]: https://github.com/mlafeldt/chef-runner/blob/v0.9.0/chef/omnibus/omnibus.go
  [101]: https://github.com/hashicorp/vault-auth-plugin-example/blob/f5bad67c730e446b5fef826dfd5f1229a0e94475/Makefile
  [102]: https://sohlich.github.io/post/go_makefile/
  [103]: http://www.codershaven.com/multi-platform-makefile-for-go/

repository: continuul/go-archetype

repo_name: continuul/go-archetype


text:
New pi Image Injection Bootstrap Role
=========

Prepares a USB Raspian image prior to first boot.
* Injects wifi *wpa_supplicant.conf* file into `<image_dir>/boot`
* Updates hostname - Based on inventory host alias
* Sets up ssh authorised key

Once the role has run:
* Eject the SD, Place in Pi and boot.
* Check ssh access
   ```
   ansible newpi --vault-id <label>@<source> -i hosts -a "whoami"
   ```
* Then edit *hosts* inventory and move new pi host entry to it's normal group.

Requirements
------------

Steps required prior to running:

1. Put the hostname of the new pi in the `newpi` inventory group. E.g.
    ```
    [newpi]
    cam1pi.local
    ```
2. If not done previously, setup vault for `pies` group.
   ```
   $ ansible-vault create --vault-id <label>@<source> group_vars/pies/vault.yml
   vault_wifi_ssid: <ssid>
   vault_wifi_psk: <psk>
   vault_wifi_passphrase:

   # Created via
   # $ mkpasswd -m sha-512 <secure_password>
   vault_pi_password_hash: "<password_hash_value>"
   ```
2. Flash raspian to SD card
3. Mount SD on localhost

Now you ready to run this role on the mounted image. Refer playbook example below.

Role Variables
--------------

| Variable                 | Required | Default                         | Comments                                     |
|--------------------------|----------|---------------------------------|----------------------------------------------|
| wifi_ssid                | yes      |                                 | WiFi SSID                                    |
| wifi_psk                 | either   |                                 | Generated from `$ wpa_passphrase <ssid>`     |
| wifi_passphrase          | or       |                                 | WiFi Passphrase (recommend using `wifi_psk`) |
| wifi_country             | yes      |                                 | WiFi country code. E.g. `NZ`                   |
| inventory_hostname_short | no       | Magic Variable                  | Injected into image as hostname              |
| newpi.bootdir            | no       | */media/${USER}/boot*           | Mounted image boot partition                 |
| newpi.rootfs             | no       | */media/${USER}/rootfs*         | Mounted image rootfs partition               |
| newpi.pubkeyfile         | no       | */home/${USER}/.ssh/id_rsa.pub* | Public key to copy to authorized_keys        |

If `wifi_psk` is set then it will be used in *wpa_supplicant.conf* and `wifi_passphrase` will be ignored. So don't set it to a value. Recommend using `wifi_psk` as it is slightly more secure than having a clear text passphrase in *wpa_supplicant.conf*.

Recommend setting the required variables in *group_vars/pies/vars.yml*. Based on vault variable set in *group_vars/pies/vault.yml*.

Dependencies
------------

None.

Example Playbook
----------------

All tasks in the playbook are `delegated_to: localhost`. The inventory host alias is used to set the hostname within the image.

#### *prepimage.yml*
```yaml
- name: Prepare USB Raspian image
  hosts: newpi
  gather_facts: no

  tasks:
    - import_role:
        name: newpi
```
```bash
ansible-playbook prepimage.yml -i hosts --vault-id <label>@<source>
```


text:
# Octospora convexula (Pers.) L.R. Batra, 1963 SPECIES

#### Status
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Bulletin of the University of Kansas, Science 44: 167 (1963)

#### Original name
Peziza convexula Pers., 1800

### Remarks
null


text:
# GH Gif [![Build Status](https://secure.travis-ci.org/node-gh/gh-gif.png?branch=master)](https://travis-ci.org/node-gh/gh-gif) [![NPM version](https://badge.fury.io/js/gh-gif.png)](http://badge.fury.io/js/gh-gif) [![Dependency Status](https://david-dm.org/node-gh/gh-gif.png)](https://david-dm.org/node-gh/gh-gif)

![DaftPunktocat](http://zno.io/RMu9/daftpunktocat.gif)

NodeGH plugin for commenting on pull requests/issues using GIF reactions.

> Maintained by [Zeno Rocha](https://github.com/zenorocha) and [Eduardo Lundgren](https://github.com/eduardolundgren).

## Install

```
[sudo] npm install -g gh-gif
```

## Usage

```
gh gif
```

Option             | Usage        | Type
---                | ---          | ---
`-n`, `--number`   | **Required** | `Number`
`-R`, `--reaction` | **Required** | `String`
`-i`, `--image`    | *Optional*   | `String`
`-r`, `--repo`     | *Optional*   | `String`
`-u`, `--user`     | *Optional*   | `String`

#### Examples

* Comment on pull request/issue #75 with a happy reaction.

    ```
gh gif 75 --reaction happy
    ```

* Comment on pull request/issue #75 of a certain repo with a surprised reaction.

    ```
gh gif 75 --reaction surprised --user node-gh --repo gh-gif
    ```

* Comment on pull request/issue #75 using a certain image.

    ```
gh gif 75 --image http://media1.giphy.com/media/5DQdk5oZzNgGc/original.gif
    ```

* Comment on multiple pull requests/issues at the same time.

	```
gh gif --reaction happy --number 1 --number 2
	```

## Testing

Check [Travis](https://travis-ci.org/node-gh/gh-gif) for continous integration results.

* Run [JSHint](http://www.jshint.com/), a tool to detect errors and potential problems.

    ```
npm run-script lint
    ```

* Run [Mocha](http://visionmedia.github.io/mocha/), a unit test framework.

    ```
npm run-script test
    ```

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3.  Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## History

Check [Release](https://github.com/node-gh/gh-gif/releases) list.

## License

[BSD License](https://github.com/node-gh/gh/blob/master/LICENSE.md)

repository: brunocoelho/gh-gif

repo_name: brunocoelho/gh-gif