text:
# rehype-sanitize

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

**[rehype][]** plugin to sanitize HTML.

## Contents

*   [What is this?](#what-is-this)
*   [When should I use this?](#when-should-i-use-this)
*   [Install](#install)
*   [Use](#use)
*   [API](#api)
    *   [`defaultSchema`](#defaultschema)
    *   [`unified().use(rehypeSanitize[, schema])`](#unifieduserehypesanitize-schema)
    *   [`Options`](#options)
*   [Example](#example)
    *   [Example: headings (DOM clobbering)](#example-headings-dom-clobbering)
    *   [Example: math](#example-math)
    *   [Example: syntax highlighting](#example-syntax-highlighting)
*   [Types](#types)
*   [Compatibility](#compatibility)
*   [Security](#security)
*   [Related](#related)
*   [Contribute](#contribute)
*   [License](#license)

## What is this?

This package is a [unified][] ([rehype][]) plugin to make sure HTML is safe.
It drops anything that isn’t explicitly allowed by a schema (defaulting to how
`github.com` works).

**unified** is a project that transforms content with abstract syntax trees
(ASTs).
**rehype** adds support for HTML to unified.
**hast** is the HTML AST that rehype uses.
This is a rehype plugin that transforms hast.

## When should I use this?

It’s recommended to sanitize your HTML any time you do not completely trust
authors or the plugins being used.

This plugin is built on [`hast-util-sanitize`][hast-util-sanitize], which cleans
[hast][] syntax trees.
rehype focusses on making it easier to transform content by abstracting such
internals away.

## Install

This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:

```sh
npm install rehype-sanitize
```

In Deno with [`esm.sh`][esmsh]:

```js
import rehypeSanitize from 'https://esm.sh/rehype-sanitize@6'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
  import rehypeSanitize from 'https://esm.sh/rehype-sanitize@6?bundle'
</script>
```

## Use

Say we have the following file `index.html`:

```html
<div onmouseover="alert('alpha')">
  <a href="jAva script:alert('bravo')">delta</a>
  <img src="x" onerror="alert('charlie')">
  <iframe src="javascript:alert('delta')"></iframe>
  <math>
    <mi xlink:href="data:x,<script>alert('echo')</script>"></mi>
  </math>
</div>
<script>
require('child_process').spawn('echo', ['hack!']);
</script>
```

…and our module `example.js` looks as follows:

```js
import rehypeParse from 'rehype-parse'
import rehypeSanitize from 'rehype-sanitize'
import rehypeStringify from 'rehype-stringify'
import {read} from 'to-vfile'
import {unified} from 'unified'

const file = await unified()
  .use(rehypeParse, {fragment: true})
  .use(rehypeSanitize)
  .use(rehypeStringify)
  .process(await read('index.html'))

console.log(String(file))
```

Now running `node example.js` yields:

```html
<div>
  <a>delta</a>
  <img src="x">

</div>
```

## API

This package exports the identifier [`defaultSchema`][api-default-schema].
The default export is [`rehypeSanitize`][api-rehype-sanitize].

### `defaultSchema`

Default schema ([`Options`][api-options]).

Follows GitHub style sanitation.

### `unified().use(rehypeSanitize[, schema])`

Sanitize HTML.

###### Parameters

*   `options` ([`Options`][api-options], optional)
    — configuration

###### Returns

Transform ([`Transformer`][unified-transformer]).

### `Options`

Schema that defines what nodes and properties are allowed (TypeScript type).

This option is a bit advanced as it requires knowledge of syntax trees, so see
the docs for [`Schema` in `hast-util-sanitize`][hast-util-sanitize-schema].

## Example

### Example: headings (DOM clobbering)

DOM clobbering is an attack in which malicious HTML confuses an application by
naming elements, through `id` or `name` attributes, such that they overshadow
presumed properties in `window` (the global scope in browsers).
DOM clobbering often occurs when user content is used to generate heading IDs.
To illustrate, say we have this `browser.js` file:

```js
console.log(current)
```

And our module `example.js` contains:

```js
/**
 * @typedef {import('hast').Root} Root
 */

import fs from 'node:fs/promises'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'

const browser = String(await fs.readFile('browser.js'))
const document = `<a name="old"></a>
<h1 id="current">Current</h1>
${`<p>${'Lorem ipsum dolor sit amet. '.repeat(20)}</p>\n`.repeat(20)}
<p>Link to <a href="#current">current</a>, link to <a href="#old">old</a>.`

const file = await unified()
  .use(rehypeParse, {fragment: true})
  .use(function () {
    /**
     * @param {Root} tree
     */
    return function (tree) {
      tree.children.push({
        type: 'element',
        tagName: 'script',
        properties: {type: 'module'},
        children: [{type: 'text', value: browser}]
      })
    }
  })
  .use(rehypeStringify)
  .process(document)

await fs.writeFile('output.html', String(file))
```

This code processes HTML, inlines our browser script into it, and writes it out.
The input HTML models how markdown often looks on platforms like GitHub, which
allow heading IDs to be generated from their text and embedded HTML (including
`<a name="old"></a>`, which can be used to create anchors for renamed headings
to prevent links from breaking).
The generated HTML looks like:

```html
<a name="old"></a>
<h1 id="current">Current</h1>
<p>Lorem ipsum dolor sit amet.<!--…--></p>
<p>Link to <a href="#current">current</a>, link to <a href="#old">old</a>.</p>
<script type="module">console.log(current)</script>
```

When you run this code locally and open the generated `output.html`, you can
observe that the links at the bottom work, but also that the `<h1>` element
is printed to the console (the clobbering).

`rehype-sanitize` solves the clobbering by prefixing every `id` and `name`
attribute with `'user-content-'`.
Changing `example.js`:

```diff
@@ -15,6 +15,7 @@ ${`<p>${'Lorem ipsum dolor sit amet. '.repeat(20)}</p>\n`.repeat(20)}

   const file = await unified()
     .use(rehypeParse, {fragment: true})
+    .use(rehypeSanitize)
     .use(function () {
       /**
        * @param {Root} tree
```

Now yields:

```diff
-<a name="old"></a>
-<h1 id="current">Current</h1>
+<a name="user-content-old"></a>
+<h1 id="user-content-current">Current</h1>
```

This introduces another problem as the links are now broken.
It could perhaps be solved by changing all links, but that would make the links
rather ugly, and we’d need to track what IDs we have outside of the user content
on our pages too.
Alternatively, and what arguably looks better, we could rewrite pretty links to
their safe but ugly prefixed elements.
This is what GitHub does.
Replace `browser.js` with the following:

```js
/// <reference lib="dom" />
/* eslint-env browser */

// Page load (you could wrap this in a DOM ready if the script is loaded early).
hashchange()

// When URL changes.
window.addEventListener('hashchange', hashchange)

// When on the URL already, perhaps after scrolling, and clicking again, which
// doesn’t emit `hashchange`.
document.addEventListener(
  'click',
  function (event) {
    if (
      event.target &&
      event.target instanceof HTMLAnchorElement &&
      event.target.href === location.href &&
      location.hash.length > 1
    ) {
      setImmediate(function () {
        if (!event.defaultPrevented) {
          hashchange()
        }
      })
    }
  },
  false
)

function hashchange() {
  /** @type {string | undefined} */
  let hash

  try {
    hash = decodeURIComponent(location.hash.slice(1)).toLowerCase()
  } catch {
    return
  }

  const name = 'user-content-' + hash
  const target =
    document.getElementById(name) || document.getElementsByName(name)[0]

  if (target) {
    setImmediate(function () {
      target.scrollIntoView()
    })
  }
}
```

### Example: math

Math can be enabled in rehype by using the plugins
[`rehype-katex`][rehype-katex] or [`rehype-mathjax`][rehype-mathjax].
The operate on `span`s and `div`s with certain classes and inject complex markup
and of inline styles, most of which this plugin will remove.
Say our module `example.js` contains:

```js
import rehypeKatex from 'rehype-katex'
import rehypeParse from 'rehype-parse'
import rehypeSanitize from 'rehype-sanitize'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'

const file = await unified()
  .use(rehypeParse, {fragment: true})
  .use(rehypeKatex)
  .use(rehypeSanitize)
  .use(rehypeStringify)
  .process('<span class="math math-inline">L</span>')

console.log(String(file))
```

Running that yields:

```html
<span><span><span>LL</span><span aria-hidden="true"><span><span></span><span>L</span></span></span></span></span>
```

It is possible to pass a schema which allows MathML and inline styles, but it
would be complex, and allows *all* inline styles, which is unsafe.
Alternatively, and arguably better, would be to *first* sanitize the HTML,
allowing only the specific classes that `rehype-katex` and `rehype-mathjax` use,
and *then* using those plugins:

```diff
@@ -1,7 +1,7 @@
 import rehypeKatex from 'rehype-katex'
 import rehypeParse from 'rehype-parse'
-import rehypeSanitize from 'rehype-sanitize'
+import rehypeSanitize, {defaultSchema} from 'rehype-sanitize'
 import rehypeStringify from 'rehype-stringify'
 import {unified} from 'unified'

 main()
@@ -9,8 +9,21 @@ main()
 const file = await unified()
   .use(rehypeParse, {fragment: true})
+  .use(rehypeSanitize, {
+    ...defaultSchema,
+    attributes: {
+      ...defaultSchema.attributes,
+      div: [
+        ...(defaultSchema.attributes.div || []),
+        ['className', 'math', 'math-display']
+      ],
+      span: [
+        ...(defaultSchema.attributes.span || []),
+        ['className', 'math', 'math-inline']
+      ]
+    }
+  })
   .use(rehypeKatex)
-  .use(rehypeSanitize)
   .use(rehypeStringify)
   .process('<span class="math math-inline">L</span>')
```

### Example: syntax highlighting

Highlighting, for example with [`rehype-highlight`][rehype-highlight], can be
solved similar to how math is solved (see previous example).
That is, use `rehype-sanitize` and allow the classes needed for highlighting,
and highlight afterwards:

```js
import rehypeHighlight from 'rehype-highlight'
import rehypeParse from 'rehype-parse'
import rehypeSanitize, {defaultSchema} from 'rehype-sanitize'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'

const file = await unified()
  .use(rehypeParse, {fragment: true})
  .use(rehypeSanitize, {
    ...defaultSchema,
    attributes: {
      ...defaultSchema.attributes,
      code: [
        ...(defaultSchema.attributes.code || []),
        // List of all allowed languages:
        ['className', 'language-js', 'language-css', 'language-md']
      ]
    }
  })
  .use(rehypeHighlight, {subset: false})
  .use(rehypeStringify)
  .process('<pre><code className="language-js">console.log(1)</code></pre>')

console.log(String(file))
```

Alternatively, it’s possible to make highlighting safe by allowing all the
classes used on tokens.
Modifying the above code like so:

```diff
 const file = await unified()
   .use(rehypeParse, {fragment: true})
+  .use(rehypeHighlight, {subset: false})
   .use(rehypeSanitize, {
     ...defaultSchema,
     attributes: {
       ...defaultSchema.attributes,
-      code: [
-        ...(defaultSchema.attributes.code || []),
-        // List of all allowed languages:
-        ['className', 'hljs', 'language-js', 'language-css', 'language-md']
+      span: [
+        ...(defaultSchema.attributes.span || []),
+        // List of all allowed tokens:
+        ['className', 'hljs-addition', 'hljs-attr', 'hljs-attribute', 'hljs-built_in', 'hljs-bullet', 'hljs-char', 'hljs-code', 'hljs-comment', 'hljs-deletion', 'hljs-doctag', 'hljs-emphasis', 'hljs-formula', 'hljs-keyword', 'hljs-link', 'hljs-literal', 'hljs-meta', 'hljs-name', 'hljs-number', 'hljs-operator', 'hljs-params', 'hljs-property', 'hljs-punctuation', 'hljs-quote', 'hljs-regexp', 'hljs-section', 'hljs-selector-attr', 'hljs-selector-class', 'hljs-selector-id', 'hljs-selector-pseudo', 'hljs-selector-tag', 'hljs-string', 'hljs-strong', 'hljs-subst', 'hljs-symbol', 'hljs-tag', 'hljs-template-tag', 'hljs-template-variable', 'hljs-title', 'hljs-type', 'hljs-variable'
+          ]
       ]
     }
   })
-  .use(rehypeHighlight, {subset: false})
   .use(rehypeStringify)
   .process('<pre><code className="language-js">console.log(1)</code></pre>')
```

## Types

This package is fully typed with [TypeScript][].
It exports the additional type [`Options`][api-options].

## Compatibility

Projects maintained by the unified collective are compatible with maintained
versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `rehype-sanitize@^6`,
compatible with Node.js 16.

This plugin works with `rehype-parse` version 3+, `rehype-stringify` version 3+,
`rehype` version 5+, and `unified` version 6+.

## Security

The defaults are safe but improper use of `rehype-sanitize` can open you up to a
[cross-site scripting (XSS)][xss] attack.

Use `rehype-sanitize` after the last unsafe thing: everything after
`rehype-sanitize` could be unsafe (but is fine if you do trust it).

## Related

*   [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize)
    — utility to sanitize [hast][]
*   [`rehype-format`](https://github.com/rehypejs/rehype-format)
    — format HTML
*   [`rehype-minify`](https://github.com/rehypejs/rehype-minify)
    — minify HTML

## Contribute

See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## License

[MIT][license] © [Titus Wormer][author]

<!-- Definitions -->

[build-badge]: https://github.com/rehypejs/rehype-sanitize/workflows/main/badge.svg

[build]: https://github.com/rehypejs/rehype-sanitize/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-sanitize.svg

[coverage]: https://codecov.io/github/rehypejs/rehype-sanitize

[downloads-badge]: https://img.shields.io/npm/dm/rehype-sanitize.svg

[downloads]: https://www.npmjs.com/package/rehype-sanitize

[size-badge]: https://img.shields.io/bundlejs/size/rehype-sanitize

[size]: https://bundlejs.com/?q=rehype-sanitize

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[collective]: https://opencollective.com/unified

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[chat]: https://github.com/rehypejs/rehype/discussions

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[npm]: https://docs.npmjs.com/cli/install

[health]: https://github.com/rehypejs/.github

[contributing]: https://github.com/rehypejs/.github/blob/HEAD/contributing.md

[support]: https://github.com/rehypejs/.github/blob/HEAD/support.md

[coc]: https://github.com/rehypejs/.github/blob/HEAD/code-of-conduct.md

[license]: license

[author]: https://wooorm.com

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting

[typescript]: https://www.typescriptlang.org

[hast]: https://github.com/syntax-tree/hast

[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize

[hast-util-sanitize-schema]: https://github.com/syntax-tree/hast-util-sanitize#schema

[rehype]: https://github.com/rehypejs/rehype

[rehype-katex]: https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex

[rehype-mathjax]: https://github.com/remarkjs/remark-math/tree/main/packages/rehype-mathjax

[rehype-highlight]: https://github.com/rehypejs/rehype-highlight

[unified]: https://github.com/unifiedjs/unified

[unified-transformer]: https://github.com/unifiedjs/unified?tab=readme-ov-file#transformer

[api-default-schema]: #defaultschema

[api-options]: #options

[api-rehype-sanitize]: #unifieduserehypesanitize-schema

repository: rehypejs/rehype-sanitize

repo_name: rehypejs/rehype-sanitize


text:
# TeaAsAService

![.NET Core](https://github.com/beakersoft/TeaAsAService/workflows/.NET%20Core/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Track your Brews!
So just for a change the other day at work we were discussing who's turn it was to make a brew. A discussion I'm sure goes on in businesses across the globe.
Being a Dev I started to wonder if anyone had ever thought about ways to track your daily brew intake, and who turn it was to make the next one. A quick google revealed nothing, so i thought it might be a fun idea to make one.

Tech

So, as a mainly c# guy I was thinking of writing the API in netcore 3.1 c#. The database back end is on MySql, need to work out a way to do the data migrations. Might do them manually in prod for now but u'm hoping to keep them to a minumum.

Then the first client I was thinking of making was a command line app to run in WLS/Linux or power shell, called Tea++ that you just call every time you have a brew or pass an arg to when someone gets a round in

All ideas welcome!

# Dev Installation

First of all, clone the project as normal,

git clone git@github.com:beakersoft/TeaAsAService.git

To run this project we need a MySql server running to host our database on. Luckly this is easy to create using a docker container. Open a terminal and from the build folder just run

`docker-compose up -d`

to start a MySql docker instance. The connection string in the application should be setup to use this instance once its started, and the database will created on first load and seeded with a test user we can use to test the API

Test user id is 7EmMT6n3f0i/YniN6osJXQ== password TestPassword123*

Once the container is running you can exec into it so you can run sql commands directly on the database. In the terminal run

`docker exec -t -i container_mysql_name /bin/bash`

Once you are in the container, run

`mysql -uroot -pPassw0rd1*`

From there you can run standard MySql commands

license: MIT

repository: beakersoft/TeaAsAService

branch_name: refs/heads/master

extension: md

gha_language: C#

gha_license_id: MIT

license_type: permissive

repo_name: beakersoft/TeaAsAService


text:
# cf-api

A pluggable JSON API server

This is CatfishApi but without all of the bloat and a simple API to register plugins.
Everything becomes a plugin.

## Installation

    npm install --save cf-api

## Usage

```js
var createApi = require('cf-api')

var api = createApi(options)
  server = api.initialize()

server.get('/', homepage)
server.post('/form', submit)

// This tells the api that you've finished adding your routes
// and you now want it to add the error handling middleware
server.emit('preBoot')

server.listen(port)
```

## API API

### var api = createApi(Object: options)

Create an API instance. There are options available:

- `checkOrigin` - a function with the signature `function (url, cb) {}` to check `req.headers.origin`. `cb(null, true)` to allow and `origin`, `cb(null, false)` to deny an origin. Defaults to `cb(null, true)` for all requests, meaning all cross-domain requests are allowed. It is up to the user to implement their whitelist/blacklist.
- `logger` - a logger object with methods `debug()`, `info()`, `warn()` and `error()` (default: `console`).
- `maxBodySize` - an option to be passed along to the [body-parser json middleware](https://github.com/expressjs/body-parser#limit) function. If this is a number it will be the number of bytes, otherwise it will be parsed by the [bytes module](https://github.com/visionmedia/bytes.js) (default: `undefined` which falls back to the body parser default of `'100kB'`).
- `initialMiddleware` - an Express middleware function that will be used before all other middleware. Useful for Sentry error handlers.
- `corsOptions` - an object with the following keys:
  - `exposeHeaders` - sets `Access-Control-Expose-Headers`

*For backwards compatibility, the `allowedDomains` option still works and generates a `checkOrigin` function for you.*

### api.initialize()

Create and return the server.

## Changelog

### 3.1.1
- Cors header `Access-Control-Allow-Credentials` is now set to `true`

### 3.1.0
 - mis-tagged commit from unpulled work, unpublished.

### 3.0.0
- `express` is now installed as a peer dependency

### 2.6.0
- Allow setting cors options through initialisation options.

### 2.0.0
- Plugin interface now totally removed. Application components are registered outside of the scope of this module.
- User must call `server.emit('preBoot')` after all routes have been added to make tell the api to add the last piece of middleware: the error handler. This is due to a change in Express 4.

### 1.1.0
- API now allows binary request bodies as well as json

### 1.0.1
- Fixed cors middleware not terminating preflight requests. Do not use 1.0.0, please upgrade.

### 1.0.0
- Added `checkOrigin` option in place of `allowedDomains`. Latter is still supported for compatibility.

### Pre 1.0.0
- Unstable!

## Credits
Built by developers at [Clock](http://clock.co.uk).

## Licence
Licensed under the [New BSD License](http://opensource.org/licenses/bsd-license.php)

repository: clocklimited/cf-api

gha_language: JavaScript

repo_name: clocklimited/cf-api


text:
# W.I.P chatkuy
Simple Chat App made with Firebase

## How to contribute
1. Fork and clone this repo
2. Made some change in public folder
3. Make PR into this repo
4. We'll review your codebase, if it's good it'll be merged
5. Happy contribute :smile:

### [Live demo](https://chatkuy-a882a.web.app/)

repository: Programmer-Muda/chatkuy

gha_language: HTML

repo_name: Programmer-Muda/chatkuy


text:
---
date: 2020-10-02T17:57:02.361Z
title: Django Production Deployment on Apache Server
tags:
  - docker
  - django
  - apache
  - deployment
  - production
excerpt: Do you use python manage.py runserver to deploy web applications
  written in django? Please don't do it. Learn in this post how to deploy it in
  production using docker and apache webserver
draft: false
---
Building an software application using different algorithms, data-structures, frameworks, databases and messaging queues which can solve the mentioned problem efficiently and effectively. This is the first part of solving the problem. The second part is to deploy and maintain the application for high scalability and availability. This is as important as developing algorithms and building software applications.

To understand it's importance assume you have an application like imdb which will provide information related to movies, actors and their works. The expected workload on average could be 1000 requests per second with 300ms serving time for each request. The numbers are not quite high for some SQL db based application right? But without proper configuration applications will not be able serve even 100 request per second. Are you thinking we can increase just the number of servers to server more request as cloud providers allows to scale very quickly. Don't do that, it's possible that you will spend more money than you will generate.

The correct configuration to maximize the throughput of application is not just limited to properly configuring web-servers but also databases, messaging queues and other components of the entire application. In this article we will focus on how we can configure [Django](https://www.djangoproject.com/) application on [Apache web-server](https://httpd.apache.org/) on Unix based operating system to maximize the output. We will not talk about why should we use an server to host our applications. I would recommend you to search about it on your own.

Before looking at final configuration let's understand few terms and about application

* **mod_wsgi**: It provides an Apache module based on the python [WSGI](https://www.python.org/dev/peps/pep-3333/) specification. WSGI standard helps to setup an standard interface between web-servers and web-frameworks. The idea behind WSGI to have server and application. server will invoke your application. There could be some "middleware" too which helps both side to communicate with each other. I would recommend to read [WSGI](https://www.python.org/dev/peps/pep-3333/) specification to understand more about it.  [mod_wsgi](https://modwsgi.readthedocs.io/en/develop/index.html) allows to deploy code for frameworks like like Django, Flask, Pyramid and etc
* **Movie App**: We have built an Django application named imdb. This is an simple application which returns a list of movies already populated into the SQLite DB. We will not deep dive into the how rest APIs can be built into Django app. We have already exposed an API `/movie` which will return list of movies.

  ![Application Folder Structure](/assets/django_apache_project_structure.png "Application Folder Structure")

  Let's look at the `wsgi.py` present inside `imdb/imdb` folder. wsgi.py file is entry-point for mod_wsgi to call the application. Later in article we will see how we provide entry-point for our application to Apache module of mod_wsgi. There is a small change we have done so that the `imdb` app will have it's own process. We will deep dive further into this later in the article.

```python
"""
WSGI config for imdb project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
# comment and add new line so the process deamon will not be shared between multiple applications
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'imdb.settings')
  os.environ["DJANGO_SETTINGS_MODULE"] = "imdb.settings"

application = get_wsgi_application()
```

Django app will have line number 14 by default, which will cause app to share the process with other applications hosted by mod_wsgi in the same machine. By commenting line number 14 and adding line number 15, we are instructing mod_wsgi to use separate process for this application.

Apache allows to host applications in three ways Embedded, Daemon and Event mode. We will only talk about first two in the this article.

**Embedded Mode**: This mode is also known as **prefork mode**, this is implemented by [Apache MPM prefork](https://httpd.apache.org/docs/2.4/mod/prefork.html) module. This is the default mode for the Apache server. In this mode both the proxy and the response processes are being managed by Apache only which is why it's called embedded mode. This mode is suitable for non-threaded applications or libraries. Here process are the ones which serve the request. Each process is isolated from another process. So even if there is an issue with one process, another will not be affected due to it.

![Embedded Mode](/assets/embedded_mode_apache.png "Embedded Mode Representations")

As we can see in the diagram the main Apache process manages the process which will serve the request. So in this case a lot of processes will get created and killed which will take substantial amount of CPU in managing these process. As a separate memory need to be allocated and releases for each process. Let's discuss about the configuration shown below

* **Virtual Host**: This is the block where we mention the application entry-point to mod_wsgi. All the settings shown inside virtual host will be common for daemon and embedded mode. In case of daemon mode there will be few additional settings

  * **ServerName**: It can be the domain name by which we want to access the application or it can be the IP address of the server
  * **WSGIScriptAlias**: It is used to specify physical path of the wsgi script for the given application
  * **WSGIApplicationGroup**: It is used to group the applications hosted in single server. If there are multiple applications hosted in, we can group them to use the same python sub interpreter. If there is single application you can set it **%{GLOBAL}**
  * **Directory-Files**: This makes sure that Apache can access wsgi.py file
* **WSGIPythonPath**: This allows wsgi to search python modules. As Django application is built of modules and wsgi.py shown above tries to access imdb module.
* **mpm_prefork_module**: Here we set the configuration for our server. As in embedded mode requests are served by process. So, we will look here what is the meaning of each directive

  * **StartServer**: The number of server process which should be active by default when server starts. Be cautious of the number you set here. As each process is an copy of the application you want to run and each one of it will reserve memory for itself. So setting very high number will throw you out of memory and processes will compete with each other to get memory without serving any request.
  * **MinSpareServers**: It represents the number of ideal process, who will be up and running but will not serve any request.
  * **MaxSpareServers**: it represents the maximum number of ideal process, who will be up and running but will not serve any request
  * **ServerLimit**: Be careful with this property and do not set it if you don't know what it can do for you. This lets you set maximum request serve can handle including requests in process and queue
  * **MaxConnectionsPerChild**: This property is to define number of request which an processes will handle in it's lifetime before being killed. Never configure this property unless you know what you are doing, as keeping this number too less will just consume your memory and most of CPU time will get exhausted due to process churn.

```xml
<IfModule mpm_prefork_module>
   StartServers 2
   MinSpareServers 2
   MaxSpareServers 6
   MaxRequestWorkers 30
   #ServerLimit
   #MaxConnectionsPerChild 5
</IfModule>

WSGIPythonPath /var/www/imdb
<VirtualHost *:80>
    ServerName localhost
    WSGIScriptAlias / /var/www/imdb/imdb/wsgi.py
    WSGIApplicationGroup %{GLOBAL}
    <Directory /var/www/imdb/imdb>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
</VirtualHost>
```

In case of embedded mode it's better to use default settings of Apache, until you are not an expert in Apache configuration and you understand working of Apache well. As in embedded mode process are created and killed frequently, it puts a lot of pressure on the system.

**Daemon Mode**: This is know as **worker mode** and implemented by [mpm_worker_module](https://httpd.apache.org/docs/2.4/mod/worker.html). Worker mode implements a multi-process and multi-threaded approach to where the requests will be handled by threads instead of process. As the cost of creation and context switch for threads are quite less compared to process. We can refer the below diagram for better understanding

![Daemon Mode](/assets/deamon_mode_apache.png "Deamon Mode")

Here the parent process will maintain the worker process and worker processes will handle threads which will serve the request. Each request will be passed to thread. Here Apache will only work as proxy which will accept request and pass the request to one of the threads, hence reducing the wait time for users. Daemon mode configuration of Apache is more forgiving, as even if you have not done the configuration properly it will not consume all resources. Let's see an configuration sample for example

```plist
<IfModule mpm_worker_module>
    ServerLimit         16
    StartServers         2
    MaxRequestWorkers  150
    MinSpareThreads     25
    MaxSpareThreads     75
    ThreadsPerChild     25
</IfModule>

WSGIRestrictEmbedded On
<VirtualHost *:80>
    ServerName localhost
    WSGIScriptAlias / /var/www/imdb/imdb/wsgi.py
    WSGIDaemonProcess imdb python-path=/var/www/imdb processes=5 threads=15
    WSGIProcessGroup imdb
    WSGIApplicationGroup %{GLOBAL}
    <Directory /var/www/imdb/imdb>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
</VirtualHost>
```

We will only talk about properties which we have not discussed

* **Virtual Host**

  * **WSGIDaemonProcess**: This directive enables the number of daemon process that should be created which will manage threads to serve the request as well as number of threads in each process which should be created.
  * **WSGIProcessGroup**: This given an unique group name to the process created in daemon name. Both WSGIDaemonProcess and WSGIProcessGroup are must to enable daemon mode.
* **WSGIRestrictEmbedded On**: This directive forces to run applications in daemon mode only
* **mpm_worker_module**

  * **MaxRequestWorkers**: In Daemon mode it defines the no of request which can run simultaneously to server user request
  * **MinSpareThreads**: Minimum number of threads that should be in ideal state to serve request
  * **MaxSpareThreads**: Maximum number of threads that should be in ideal state at any given point of time to serve request
  * **ThreadsPerChild**: The number of threads that can be managed by each process

In the above configuration we have defined major of settings in number threads such ThreadsPerChild. Apache will automatically allocate enough process based on these number.

#### Now we know How does embedded and Daemon mode actually works, but still there is a question which mode should we choose and exactly why?

* Apache is not designed specifically to server python applications, but mod_wsgi daemon process are designed only for python applications. So they will help us to achieve maximum out of python web applications.
* Embedded Mode uses processes to serve the request, but daemon mode uses threads to serve request. If you know about processes vs threads, you will know why using threads are better compared to process. It will save you a lot of memory, CPU for each request. You can utilize the resources at it's maximum.
* Embedded mode is useful if you are serving an rare case application where threading can't be applied, but same kind of setup can be achieved by configuration in daemon mode too.
* Any code change will need Apache server restart, but that is not the case for daemon mode. Restarting sever in where multiple applications are hosted in same server could be problematic.

So that was enough of theory let's see in working daemon and embedded mode config.

**Embedded Mode**

We have created an docker file named **[Dockerfile.embedded](https://github.com/nitishkumar71/blog/blob/master/django-apache/Dockerfile.embedded)**, which uses an alpine image to do the configuration. We can split them into multiple steps

1. Use Alpine as base Image
2. Install python, pip and Apache with mod_wsgi
3. Move [imdb_embedded.conf](https://github.com/nitishkumar71/blog/blob/master/django-apache/imdb_embedded.conf) to Apache configuration directory. [imdb_embedded.conf](https://github.com/nitishkumar71/blog/blob/master/django-apache/imdb_embedded.conf) is the same config which we saw earlier. Install pip dependencies and move an [httpd-foreground](https://github.com/nitishkumar71/blog/blob/master/django-apache/httpd-foreground) shell script to bin folder to make it available as command
4. Expose port 80 on Docker container
5. Run [httpd-foreground](https://github.com/nitishkumar71/blog/blob/master/django-apache/httpd-foreground) command to start Apache server

```dockerfile
FROM alpine:3.12.0
RUN apk --update --no-cache add python3=3.8.5-r0 python3-dev=3.8.5-r0 py3-pip=20.1.1-r0 apache2=2.4.46-r0 apache2-dev=2.4.46-r0 apache2-mod-wsgi=4.7.1-r0;\
ln -s python3 /usr/bin/python;

ADD . .

RUN cp -R imdb /var/www/;cp imdb_embedded.conf /etc/apache2/conf.d/imdb_embedded.conf; pip install -r requirements.txt; chmod +x httpd-foreground; cp httpd-foreground /usr/local/bin

EXPOSE 80
CMD ["httpd-foreground"]
```

Run Docker file from the [django-apache](https://github.com/nitishkumar71/blog/tree/master/django-apache) folder in your local ```docker build -f Dockerfile.embedded .``` to build docker image, which will return an image id once image is built, use image_id with the command `docker run -d -p 8000:80 image_id` , This will run an container in your local and you can access the application on local port 8000 of your machine. Use `curl http://localhost:8000/movie` to access list of movies available in SQLite db.

**Daemon Mode**

There is another file name **[Dockerfile.daemon](https://github.com/nitishkumar71/blog/blob/master/django-apache/Dockerfile.daemon)**, which we can use to run application in daemon mode. Let's split the docker file in steps to understand what it does.

1. Take Debian buster slim as base image
2. Install Apache Python3, pip and mod_wsgi in to it
3. Move [imdb_daemon.conf](https://github.com/nitishkumar71/blog/blob/master/django-apache/imdb_daemon.conf) to configuration directory. Disable event mode and enable worker mode. Install python dependencies
4. Expose Port 80 of the container
5. Use apache2ctl utility to start the web-server

```dockerfile
FROM debian:buster-slim
RUN apt-get update; apt-get install -y python3 python3-dev python3-pip apache2 apache2-dev libapache2-mod-wsgi-py3;ln -s pip3 /usr/bin/pip; a2dismod mpm_event;\
a2enmod mpm_worker
# replace a2enmod mpm_worker with a2enmod mpm_prefork in above command for embedded mode
ADD . .

RUN cp -R imdb /var/www/imdb;cp imdb_daemon.conf /etc/apache2/sites-available/imdb.conf; pip install -r requirements.txt; a2ensite imdb.conf; a2dissite 000-default.conf; rm /var/www/html/index.html
# replace imdb_deamon.conf with imdb_embedded.conf for embedded mode
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
```

We can use the same steps as embedded docker file to run daemon mode docker file. Additionally we have included instructions to run application in embedded mode on Debian.

Let's end this post for now and we will see the difference in performance in some other post. You can find the source code for this post in following [link](https://github.com/nitishkumar71/blog/tree/master/django-apache).

##### Before we close the post, are you thinking why we are using Debian version instead of Alpine for Daemon mode?

Daemon mode does not works properly on Alpine Linux. The issue has been there for quite sometime. You can see following below links. Actually there is not much difference in the size of Alpine and Debian Slim buster container, it almost just 100 Mb.

* [https://github.com/GrahamDumpleton/mod_wsgi/issues/455](<* https://github.com/GrahamDumpleton/mod_wsgi/issues/455>)
* [https://modwsgi.narkive.com/WAUhcjDB/wsgidaemonprocess-segfault-inside-docker-alpine-linux](<* https://modwsgi.narkive.com/WAUhcjDB/wsgidaemonprocess-segfault-inside-docker-alpine-linux>)

To verify in which mode Apache server is running you can use `apache2ctl -V` in Debian or `httpd -V` Alpine.

![Apache Server Mode](/assets/apache_mode_2020-09-08-20-05-53.png "Apache Server Mode")

You can look at **Server MPM** section which will consist **worker** for **Daemon mode** and **prefork** for **Embedded**.


text:
---
title: "lrttparser"
no_index: true
---

A very lightweight PEG parser (a single 700 lines functor) supporting unrestricted left recursion and parsing errors recovery by text deletion and token insertion. Provided with a demo showing implementation of all the features.

* Admins:
  * [user7112](/users/user7112)
* Members:
  * [user7112](/users/user7112)
* [Releases](https://download.ocamlcore.org/lrttparser)
* Registered: 2012-06-22 19:08:52
* Archived data:
  * 0 open bugs
  * 0 open feature requests
  * 0 mailing list
  * 0 VCS
  * 4 released files

gha_language: Python


text:
geteventstore
========================

This is a simple implementation of the Event Store client for the HTTP interface. It uses asyncio to asyncly parse events

## Reference

Accessing the Event Store

### Client

`Client(options) -> client`

Creates a new event store client. The keyword arguments are:

- `host`: host of the RethinkDB instance. The default value is `localhost`.
- `port`: the driver port, by default `2113`.
- `loop`: the asyncio event loop, by default `asyncio.get_event_loop()`

*Example*: Create a new client to the default event store

```python
loop=asyncio.get_event_loop()
client = geteventstore.Client(loop=loop)
```

### stream_reader

`client.stream_reader(options) -> Reader`

Creates a stream reader. The keyword arguments are:

- `stream`: the stream to read from.

*Example*: Create a new stream readers

```python
import geteventstore
import asyncio

async def test(loop):
    try:
        current = 0
        poll = 10
        while True:
            current = await get_events(loop, current, poll)
    except KeyboardInterrupt:
        return

async def get_events(loop, current=0, poll=0):
    client = geteventstore.Client(loop=loop)
    reader = client.stream_reader('flyers')
    reader.next_version = current
    if poll > 0:
        reader.long_poll(poll)

    async for event, meatadata, updated in reader:
        print(event)
        print(metadata)
        print(updated)
    return reader.next_version

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test(loop))
```

### Reader

`geteventstore.Reader(options) -> Reader`

Creates a stream reader. The keyword arguments are:

- `stream`: the stream to read from
- `client`: the geteventstore client
- `feed_parser`: the feed parser to use, defaults to `feedparser`. Must be compatible with feedparser
- `http`: the http client to use, defaults to `aiohttp`. Must be compatible with aiohttp

*Example*: Create a new stream and read from *text*

```python
import geteventstore
import asyncio

async def test(loop):
    try:
        current = 0
        poll = 10
        while True:
            current = await get_events(loop, current, poll)
    except KeyboardInterrupt:
        return

async def get_events(loop, current=0, poll=0):
    client = geteventstore.Client(loop=loop)
    reader = geteventstore.Reader('flyers', client)
    reader.next_version = current
    if poll > 0:
        reader.long_poll(poll)

    async for event, _, updated in reader:
        print(event.id)
        print(updated)
    return reader.next_version

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test(loop))
```

TODO:

- [-] Read from stream
    - [x] Catchup subscription
    - [x] Volatile Subscriptions
    - [ ] Persistent Subscription
- [x] Write to stream

repository: vectorhacker/pygeteventstore

repo_name: vectorhacker/pygeteventstore


text:
# Integer overflow in bson_ensure_space (whoopsie CVE-2019-11484)

[CVE-2019-11484](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11484)
is an integer overflow in [whoopsie](https://launchpad.net/ubuntu/+source/whoopsie).
The integer overflow is triggered by a large crash report (> 2GB) and leads to
a subsequent heap buffer overflow.
This file contains instructions for running the simple version of the proof-of-concept exploit,
which just causes whoopsie to crash with a segmentation fault.
A more sophisticated PoC, which can get a shell as the whoopsie user, is described in
[README_CVE-2019-15790](README_CVE-2019-15790.md).
The full bug report is public on `bugs.launchpad.net`:
[bug 1830865](https://bugs.launchpad.net/ubuntu/+source/whoopsie/+bug/1830865).

## Instructions

Note: these reproduction steps will only work with a vulnerable version of whoopsie.
See [CVE-2019-11484](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11484)
for a list of vulnerable versions.

Build the PoC as follows:

```bash
make
```

And run it like this:

```bash
./killwhoopsie2
```

repository: github/securitylab

branch_name: refs/heads/main

gha_language: C

repo_name: github/securitylab


text:
---
lang: en
title: 'belongsTo Relation'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/BelongsTo-relation.html
---

## Overview

{% include note.html content="
This relation best works with databases that support foreign key
constraints (SQL).
Using this relation with NoSQL databases will result in unexpected behavior,
such as the ability to create a relation with a model that does not exist. We are [working on a solution](https://github.com/strongloop/loopback-next/issues/2341) to better handle this. It is fine to use this relation with NoSQL databases for purposes such as navigating
related models, where the referential integrity is not critical.
" %}

A `belongsTo` relation denotes a many-to-one connection of a model to another
model through referential integrity. The referential integrity is enforced by a
foreign key constraint on the source model which usually references a primary
key on the target model. This relation indicates that each instance of the
declaring or source model belongs to exactly one instance of the target model.
For example, in an application with customers and orders, an order always
belongs to exactly one customer as illustrated in the diagram below.

![belongsTo relation illustration](./imgs/hasMany-relation-example.png)

The diagram shows the declaring (source) model **Order** has property
**customerId** as the foreign key to reference the target model **Customer's**
primary key **id**.

To add a `belongsTo` relation to your LoopBack application and expose its
related routes, you need to perform the following steps:

1. Add a property to your source model to define the foreign key.
2. Modify the source model repository class to provide an accessor function for
   obtaining the target model instance.
3. Call the accessor function in your controller methods.

## Defining a belongsTo Relation

This section describes how to define a `belongsTo` relation at the model level
using the `@belongsTo` decorator to define the constraining foreign key.

{% include code-caption.html content="/src/models/order.model.ts" %}

```ts
import {belongsTo, Entity, model, property} from '@loopback/repository';
import {Customer} from './customer.model';

@model()
export class Order extends Entity {
  @property({
    type: 'number',
    id: true,
  })
  id: number;

  @belongsTo(() => Customer)
  customerId: number;

  @property({type: 'number'})
  quantity: number;

  constructor(data: Partial<Order>) {
    super(data);
  }
}
```

The definition of the `belongsTo` relation is inferred by using the `@belongsTo`
decorator. The decorator takes in a function resolving the target model class
constructor and designates the relation type. It also calls `property()` to
ensure that the decorated property is correctly defined.

A usage of the decorator with a custom primary key of the target model for the
above example is as follows:

```ts
class Order extends Entity {
  // constructor, properties, etc.
  @belongsTo(() => Customer, {keyTo: 'pk'})
  customerId: number;
}
```

## Configuring a belongsTo relation

The configuration and resolution of a `belongsTo` relation takes place at the
repository level. Once `belongsTo` relation is defined on the source model, then
there are a couple of steps involved to configure it and use it. On the source
repository, the following are required:

- In the constructor of your source repository class, use
  [Dependency Injection](Dependency-injection.md) to receive a getter function
  for obtaining an instance of the target repository. _Note: We need a getter
  function, accepting a string repository name instead of a repository
  constructor, or a repository instance, in order to break a cyclic dependency
  between a repository with a belongsTo relation and a repository with the
  matching hasMany relation._
- Declare a property with the factory function type
  `BelongsToAccessor<targetModel, typeof sourceModel.prototype.id>` on the
  source repository class.
- call the `createBelongsToAccessorFor` function in the constructor of the
  source repository class with the relation name (decorated relation property on
  the source model) and target repository instance and assign it the property
  mentioned above.

The following code snippet shows how it would look like:

{% include code-caption.html
content="/src/repositories/order.repository.ts" %}

```ts
import {Getter, inject} from '@loopback/context';
import {
  BelongsToAccessor,
  DefaultCrudRepository,
  juggler,
  repository,
} from '@loopback/repository';
import {Customer, Order} from '../models';
import {CustomerRepository} from '../repositories';

export class OrderRepository extends DefaultCrudRepository<
  Order,
  typeof Order.prototype.id
> {
  public readonly customer: BelongsToAccessor<
    Customer,
    typeof Order.prototype.id
  >;

  constructor(
    @inject('datasources.db') protected db: juggler.DataSource,
    @repository.getter('CustomerRepository')
    customerRepositoryGetter: Getter<CustomerRepository>,
  ) {
    super(Order, db);
    this.customer = this.createBelongsToAccessorFor(
      'customer',
      customerRepositoryGetter,
    );
  }
}
```

`BelongsToAccessor` is a function accepting the primary key (id) of a source
model instance (e.g. `order.id`) and returning back the related target model
instance (e.g. a `Customer` the order belongs to). See also
[API<EMAIL_ADDRESS>
## Using BelongsToAccessor in a controller

The same pattern used for ordinary repositories to expose their CRUD APIs via
controller methods is employed for `belongsTo` relation too. Once the belongsTo
relation has been defined and configured, a new controller method can expose the
accessor API as a new endpoint.

{% include code-caption.html content="src/controllers/order.controller.ts" %}

```ts
import {repository} from '@loopback/repository';
import {get} from '@loopback/rest';
import {Customer, Order} from '../models/';
import {OrderRepository} from '../repositories/';

export class OrderController {
  constructor(
    @repository(OrderRepository) protected orderRepository: OrderRepository,
  ) {}

  // (skipping regular CRUD methods for Order)

  @get('/orders/{id}/customer')
  async getCustomer(
    @param.path.number('id') orderId: typeof Order.prototype.id,
  ): Promise<Customer> {
    return await this.orderRepository.customer(orderId);
  }
}
```

In LoopBack 3, the REST APIs for relations were exposed using static methods
with the name following the pattern `__{methodName}__{relationName}__` (e.g.
`Order.__get__customer`). While we recommend to create a new controller for each
hasMany relation in LoopBack 4, we also think it's best to use the main CRUD
controller as the place where to explose `belongsTo` API.

## Handling recursive relations

Given an e-commerce system has many `Category`, each `Category` may have several
sub-categories, and may belong to 1 parent-category.

```ts
export class Category extends Entity {
  @property({
    type: 'number',
    id: true,
    generated: true,
  })
  id?: number;

  @hasMany(() => Category, {keyTo: 'parentId'})
  categories?: Category[];

  @belongsTo(() => Category)
  parentId?: number;

  constructor(data?: Partial<Category>) {
    super(data);
  }
}
```

The `CategoryRepository` must be declared like below

```ts
export class CategoryRepository extends DefaultCrudRepository<
  Category,
  typeof Category.prototype.id
> {
  public readonly parent: BelongsToAccessor<
    Category,
    typeof Category.prototype.id
  >;
  public readonly categories: HasManyRepositoryFactory<
    Category,
    typeof Category.prototype.id
  >;

  constructor(@inject('datasources.db') dataSource: DbDataSource) {
    super(Category, dataSource);
    this.categories = this.createHasManyRepositoryFactoryFor(
      'categories',
      Getter.fromValue(this),
    );
    this.parent = this.createBelongsToAccessorFor(
      'parent',
      Getter.fromValue(this),
    ); // for recursive relationship
  }
}
```

DO NOT declare
`@repository.getter(CategoryRepository) protected categoryRepositoryGetter: Getter<CategoryRepository>`
on constructor to avoid "Circular dependency" error (see
[issue #2118](https://github.com/strongloop/loopback-next/issues/2118))

repository: strongloop/loopback-labs

gha_language: TypeScript

gha_license_id: NOASSERTION

repo_name: strongloop/loopback-labs


text:
---
layout: post
title: 'Notes: The 2015 Dell XPS 13, Linux'
date: 2015-05-01
---

I recently purchased a 2015 Dell XPS 13. The new laptop replaces my
four-year-old Lenovo x220.

Just some quick thoughts on the upgrade:

- This screen is *fantastic*. It's the 1080p, matte FHD. Initially I
  was going to go with the "4k" but HiDPI isn't there yet (on any
  platform) and, mainly, glossy screens are silly.

- The keyboard is good, not great. After four years of using the
  **best** laptop keyboard ever produced (I will fight you) it's hard to
  see other keyboards as "great." In any case, there's a known key
  bounce problem that occasionally causes repeated keystrokes. Ubuntu
  (Unity, actually) includes de-bouncing software so it hasn't been
  noticable.

- Speaking of problems, the trackpad driver for Linux doesn't support
  palm detection just yet. This *has* been noticeable because it's
  incredibly annoying when your cursor jumps across the screen while
  you're typing.

- Ubuntu 15.04 works out of the box, sans the above input problems.

- The speakers are great. Quite loud and they resonate through the
  laptop in a way that makes them feel larger than they are.

- The headphone jack is *really* tight. I thought it was one of those
  old BlackBerry-style 2.5mm adapters at first. 3.5mm fits...if you push
  hard enough.

- It's not a great idea to judge battery life on one day of usage but
  I won't be surprised if this gets 10 or 11 hours on a charge.

- No kidding, this screen is fantastic.


text:
Monotype
========

Monotype so that way your font doesn't have to monospace!

Monotype is an excellent library that allows you to perform arbitrary formatting or filtering on your user's contenteditable input while they type.

#Problem

Existing DOM Range libraries, which handle caret position and selections, cannot restore themselves properly if the document tree is modified. Therefore one cannot alter the HTML without abruptly interrupting the user and losing their focus. This is because a range is bound to a node, thus if it is removed the range is destroyed. Monotype takes an exciting new approach, where ranges are restored based on the input's content rather than a tree. A whole new world of opportunities is now possible, which previously was implausible.

If you have not already been aggravated by this problem, I'm surprised you have even read this far - it is the sort of thing that seems like it would be a 'given'. Let's dive into some explanations, or if you are familiar with it - just skip to the demos.

###Examples

1. Facebook inline friend-tagging. As a developer you may think it is just as easy as highlighting the name and wrapping a stylized span tag around it. Right? Nope. First off, the entry field is a textarea which doesn't allow any formatting, just raw text. Second, even if it did, the insertion of an element behind the caret would change the caret's offset in the parent node, which would force you to restore it manually.
So how does Facebook do it? This will sound ugly, because it is. They make the textarea have an invisible background, then they layer a container behind it that replicates the textarea. This container can then be formatted, such that the necessary stylizing can be achieved.

2. Browser based IDEs and code editors. You may have noticed that your favorite online editors require you to use monospace fonts. But have you ever thought why that is the case? It is not to enhance the nerdy superpower aesthetic, but once again because formatting text during user input is tricky. They go a few nasty steps further, because we all want nicely color printed syntax. However, this is not possible with Facebook's technique because the textarea on top has a solid font color, which would block the coloring beneath.
As a result we have to make the entire textarea invisible, not just the background. We still need it on top though, to catch click focus (or rig up a pass-through system) - but poses the user a problem, what are they clicking on? The user can no longer see their caret in the textarea because the textarea is hidden!
To solve this we need to emulate a caret below, but matching caret position is the nasty part given the imprecision of character widths in fonts. If though, a font existed that had the exact same width for every character, then matching the position up would be trivial. Just count how many characters there are on a given line and multiply by a pixel width to get the absolute position of the caret aligned with the text.

Phew! Or we could just use Monotype.

#Solution

Introducing Monotype, unlimited formatting for free. But that is not all, Monotype also allows you to sanitize user input on the fly! Hopefully though, you do not need an exposé on why [unfiltered user input](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) is a bad idea. That digression shall not happen here. Onwards to the demos!

Monotype is not designed or intended to be a full fledged editor, it instead lays a reliable foundation for you to build an editor on top without worrying about caret trickery. Use it in place of your existing Range library or native code.

#Demos
[Examples](http://db.marknadal.com/monotype/test/mocha.html) ([45s video](http://www.screenr.com/Al7N))

[Syntax code editor](http://db.marknadal.com/monotype/test/editor.html)

#API
When you want to save the current range selection or caret, which is typically right before any formatting or filtering, do:

`r = monotype(editor)`

Where editor is the jQuery element of your contenteditable container, r is whatever variable you hence forth want to call your saved selection, and monotype is the global given to you when you included the script tag.
When you fancy you'd like to restore the user's selection, just:

`r.restore()`

Simple enough? Excellently so. Check out the code behind the demos if you need any further illustrations.

#Support
Monotype is a mean and lean **1.5KB** gzipped. Chrome, FF 3.6+, Safari 5.1+, some Opera/IE6+ and full IE9+.  No dependencies other than the fantastic jQuery. However, it is doing minimal support of cross-browser DOM traversal and checking, so it hypothetically could be easy to replace and remove. There is a known problem of backtracking in certain browsers.

Crafted with love by Mark Nadal, whom is not responsible for any liabilities from the use of this code.

repository: amark/monotype

repo_name: amark/monotype


text:
# Contributing

**The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the [Discord server](https://join.favware.tech) instead of opening an issue – you will get redirected there anyway.**

If you wish to contribute to the Favware project's codebase or documentation, feel free to fork the repository and submit a
pull request. We use ESLint to enforce a consistent coding style, any PR that does not follow the linting rules will not be
merged until the formatting is resolved.

## Setup

To get ready to work on the codebase, please do the following:

1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `yarn install`
3. Code your heart out!
4. Ensure your changes compile (`yarn build`)
5. If you have any substantial code changes make sure these are covered in unit tests
6. Run `yarn lint && yarn test` to run ESLint and ensure all tests pass
   - In order to run tests you will need to have the API running locally, ideally through Docker:

```sh
docker-compose up --detach pokedex
```

7. Submit a pull request

repository: favware/dexa

repo_name: favware/dexa


text:
# Employee-Tracker
Employee Tracker

The purpose of this project was to build a command line interface application that allows the user: to view employees, roles, and departments; to add employees, roles, and departments; and update employee roles. The project user story is below.

```
AS A business owner

I WANT to be able to view and manage the departments, roles, and employees in my company

SO THAT I can organize and plan my business
```

 The criteria for a successful project are below:

* Application should allow users to view employees, roles, and departments.

* Application should allow users to add employees, roles, and departments.

* Application should allow users to update employee roles.

## Getting Started

The deployed project should look like this. Click the image to see a video of the deployed project.

[![Deployed Project](ScreenShot.png)](https://youtu.be/gHqO3q2FgWc)

Below is the link to the project repository followed by a link to the video of how the application works.

https://github.com/jcw2865/Employee-Tracker

https://youtu.be/gHqO3q2FgWc

### Development

Below are the steps I took to create the application as it is so far. The most difficult aspect of this application for me was finding the correct syntax to use to speak to the MySQL database. This was my first time using MySQL, so trying to push and pull data took a lot of trial and error.

1. Created the initial files (server.js and seeds.sql).

2. Downloaded all dependecies using npm.

3. Created one large asynchronous function that housed the rest of the functions.

4. Created const's for all sets of inquirer prompts.

5. Paired the above const's with functions that took in their responses and used them in the MySQL database.

## Testing

This application was not developed using Test Driven Development. However, at numerous points throughout development, console.log's and console.table's were used to test the results of new elements. This was especially useful given how new SQL syntax is for me.

## Deployment

This program can be viewed and deployed using most internet browsers via the links in the "Getting Started" section.

## Built With

* [VSCode](https://code.visualstudio.com/) - The platform I used for developing this project.
* [MDN](https://developer.mozilla.org/en-US/) - Used as a reference tool.
* [MySQL](https://www.mysql.com/) - Used as a database management tool.
* [Node.js](https://nodejs.org/en/) - Used to execute JS code outside of a web browser.
* [NodePackageManager](https://www.npmjs.com/) - Used to install node modules/dependencies
* [Inquirer](https://www.npmjs.com/package/inquirer) - A collection of common interactive command line user interfaces.
* [YouTube](https://youtube.com) - Used to publish the video of the CLI which can be found in the "Getting Started" section.
<!-- * [GoogleChrome](https://www.google.com/chrome/) - Used for inspector tool and validating the program during development.  -->
<!-- * [Postman](https://www.getpostman.com/) - A collaboration platform for API development. -->
<!-- ## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. -->

## Authors

* **Jake Walker** - [jcw2865](https://github.com/jcw2865)

<!-- See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. -->

<!-- ## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details -->

## Acknowledgments

* The advisors, instructors, and TAs at the Trilogy Coding Bootcamp at the University of Texas at Austin
* Tutoring staff at Trilogy
* Fellow classmates at the Coding Bootcamp at UT-Austin
* Friends in the industry


text:
# Python - Random Password Generator ( R.P.G. ) 🔒

## 🔑 Features

- Generate 100% secure password.
- Random password generation.
- Custom password length and password count.
- Custom password type (Uppercase, Lowercase and Number).
- Open Source

## 🧰 Clone with HTTPS

```bash
git clone https://gitlab.com/foadh/password-generator.git
```

## 💻 Generating a password via following command

```bash
python password_generator.py
or
python3 password_generator.py
```

![Python - Random Password Generator](https://gitlab.com/foadh/password-generator/uploads/037d4aaeb5fe3c1c8c516896cb0138c0/Screen_Shot_2021-02-28_at_16.03.07.png)

repository: foad-heidari/password-generator

repo_name: foad-heidari/password-generator


text:
# Amazon Check

[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=plastic)](LICENSE.md) [![approved](https://img.shields.io/badge/approved-by%20Marco%20Hecker-green.svg?style=plastic)](https://encrypted.google.com/search?q=Marco+Hecker) [![powered_by](https://img.shields.io/badge/part%20of-Likando%20Publishing-red.svg?style=plastic)](https://www.likando.de)

An Amazon price tracker written in python.
This Skript was written by [Webklex][link-contributors], but I added a ***MySQL-Database*** and ***Config-file*** to it.

### Requirements
- bs4
- configparser
- mysql-connector
- mysql-connector-python
- requests

### Installation / Setup
```bash
pip install -r requirements.txt
```
Then install a ***MySQL-Database*** with a Table. (See [create_MySQL-DB.sql](create_MySQL-DB.sql))

### Config
Edit the [settings.ini](settings.ini.sample)
```bash
[DB]
host = mysql_server
user = mysql_user
passwd = mysql_passwd
database = mysql_database

[Email]
host = smtp.gmail.com
port = 587
username =<EMAIL_ADDRESS>password = gmail_passwd

[EmailTo]
email =<EMAIL_ADDRESS>```

### Run
```bash
python main.py
```

## Credits
- [Webklex][link-contributors]

## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

[link-contributors]: https://github.com/Webklex/python_amazon_price_tracker


text:
# Termiboard
[![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/IEEE-VIT/termiboard/)
[![GitHub license](https://img.shields.io/github/license/IEEE-VIT/termiboard.svg)](https://github.com/IEEE-VIT/termiboard/blob/master/LICENSE)
[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/IEEE-VIT/termiboard.svg)](https://github.com/IEEE-VIT/termiboard)
[![GitHub Workflow Build Passing](https://img.shields.io/github/workflow/status/IEEE-VIT/termiboard/termiboard-build)](https://github.com/IEEE-VIT/termiboard)
[![GitHub Open Issues](https://img.shields.io/github/issues-raw/IEEE-VIT/termiboard)](https://github.com/IEEE-VIT/termiboard/issues?q=is%3Aopen+is%3Aissue)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/IEEE-VIT/termiboard/issues/new/choose)

The cross platform CLI Dashboard which shows all your system stats and info in an instant.

## Getting Started
* Fork it.

* Clone your forked repo and move inside it:

`git clone https://github.com/<your-github-username>/termiboard.git && cd termiboard`

* Checkout to a new branch to work on an issue:

`git checkout -b my-amazing-feature`

* Run termiboard
```console
go run .
```

* Build termiboard
```console
go build
./termiboard
```

* Once you're all done coding, it's time to open a PR :)
Run the following commands from the root of the project directory:

`git add .`

`git commit -m "A short description about the feature."`

`git push origin <my-amazing-feature>`

Open your forked repo in your browser and then raise a PR to the `master` branch of this repository!

## Usage
Once the executable file is created, the program can be executed as:

### Without Flag Options
This will by default show all the parameters of the System.
```console
./termiboard
```
Output:
![Complete Output SS](assets/Termiboard.PNG)
### With Flag Options
If the flag options are passed, then the specific parameters of the System will be displayed.
```console
./termiboard --cpu-usage
```
Output:
![CPU Info Output SS](assets/CpuInfo.PNG)
#### All Available Options
```console
./termiboard --help
```
| Flag        | Function                                        |
|-------------|-------------------------------------------------|
| --all       | Show all stats                                  |
| --cpu-info  | Show CPU information                            |
| --cpu-usage | Show CPU usage                                  |
| --disk      | Show disk usage                                 |
| --local-ip  | Show local IP address                           |
| --public-ip | Show public IP address                          |
| --ram       | Show RAM usage                                  |
| --top5-ram  | Show top 5 process that consume the most memory |

## Contributing
To start contributing, check out [CONTRIBUTING.md](https://github.com/IEEE-VIT/termiboard/blob/master/CONTRIBUTING.md). New contributors are always welcome to support this project. Kindly consider leaving a :star: if you like the project :)

## License
This project is licensed under [MIT](https://github.com/IEEE-VIT/termiboard/blob/master/LICENSE).

repository: naturesyouth/termiboard

repo_name: naturesyouth/termiboard


text:
# flexbox setup

> An automated install for new macs

## Install Xcode

- [ ] Open App Store and Download Xcode
- [ ] `xcode-select --install`
- [ ] `sudo xcodebuild -license`

## Ruby and GitHub setup

Follow the **[macOS setup guide from lewagon](https://github.com/lewagon/setup/blob/master/macos.md)**

## Install applications from the internet

Clone the repo on your machine

```
gh repo clone flexbox/setup
```

Automatically install applications from `Brewfile`

```console
brew bundle
```

Check the result with `echo $ANDROID_HOME`

## macOS defaults for hackers

Update `.zshrc`

```console
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions`
```

```console
# ~/.zshrc

# You can change the theme with another one:
#   https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="refined"

# Useful plugins for Rails development with Sublime Text
plugins=(git gitfast common-aliases sublime zsh-syntax-highlighting history-substring-search zsh-autosuggestions)
```

```console
bash ./.macos
```

license: MIT,Ruby

repository: flexbox/setup

detected_licenses: MIT Ruby

repo_name: flexbox/setup


text:
---
title: Kth Smallest Instructions
tags: [LeetCode]
---

[1643. Kth Smallest Instructions](https://leetcode.com/problems/kth-smallest-instructions/)
Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination.

The instructions are represented as a string, where each character is either:

'H', meaning move horizontally (go right), or
'V', meaning move vertically (go down).
Multiple instructions will lead Bob to destination. For example, if destination is (2, 3), both "HHHVV" and "HVHVH" are valid instructions.

However, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.

Given an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.

#### Solution
[Reference](https://leetcode.com/problems/kth-smallest-instructions/discuss/918396/Python-Math-solution-Introduction-to-Combinatorics)

1. If we choose to walk down a row when we have N more steps and R possible rows left to walk down (including the current step), then we're cutting out the number of combinations of (N - 1) steps with R rows to walk down, because all of those combinations would result in a lexicographically smaller instruction set.

```python
def kthSmallestPath(self, destination: List[int], k: int) -> str:
    from math import comb
    r, c = destination

    ret = []
    remDown = r
    for i in range(r + c):
        remSteps = r + c - (i + 1)
        com = comb(remSteps, remDown)
        if com >= k:
            ret.append("H")
        else:
            remDown -= 1
            k -= com
            ret.append("V")

    return ''.join(ret)
```

filename: 2020-11-01-Kth Smallest Instructions.md


text:
ziproxy Cookbook
==============
This cookbook installs ziproxy software

Requirements
------------
### Supported Operating Systems
- Debian-family Linux Distributions
- RedHat-family Linux Distributions

### Cookbooks
- Depends on `checkinstall` cookbook

Attributes
----------
### Recommended tunables

* `ziproxy['install_method']`
  - String. Defaults to `source`. Can be `source` or `package`
  - `source` downloads source codes and compile them, then executes checkinstall to install as package
  - `package` installs package from the existing repo via apt or yum, depending on the distribution

* `ziproxy['url']`
  - String. Points to the ziproxy source codes archive location

* `ziproxy['version']`
  - String. ziproxy version to be compiled

* `ziproxy['checksum']`
  - String. Source codes archive checksum

* `ziproxy['compression']['rate']`
  - String. Sets the jpeg compression rate

* `ziproxy['transparent']`
  - Bool. Sets ziproxy mode of operation
  - Defaults to true

* `ziproxy['max_size']`
  - Integer. Max file size to be compressed
  - Defaults to 10485760

* `ziproxy['allow_look_change']`
  - Bool. Allow the look and feel of compressed files
  - Defaults to true

* `ziproxy['convert_to_grayscale']`
  - Bool. Converts the images to grayscale if set to true
  - Defaults to false

* `ziproxy['process_jpg']`
  - Bool. Compresses jpg files if set to true
  - Defaults to true

* `ziproxy['process_png']`
  - Bool. Compresses png files if set to true
  - Defaults to true

* `ziproxy['process_gif']`
  - Bool. Compresses gif files if set to true
  - Defaults to true

### Source specific

* `ziproxy['prefix_dir']`
  - String. The path to prefix dir
  - Defaults to `/`

* `ziproxy['exec_prefix_dir']`
  - String. The path to exec_prefix dir
  - Defaults to `/usr`

* `ziproxy['config_dir']`
  - String. The path to configuration file dir
  - Defaults to `/etc/ziproxy`

* `ziproxy['doc_dir']`
  - String. The path to docs dir
  - Defaults to `/usr/share`

Usage
-----
#### ziproxy::default
Just include `ziproxy` in your node's `run_list`:

```json
{
  "name":"my_node",
  "run_list": [
    "recipe[ziproxy]"
  ]
}
```

License and Authors
-------------------

- Author:: Rostyslav Fridman<EMAIL_ADDRESS>
```text
Copyright 2014, Rostyslav Fridman

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: vgadreau/demo

repo_name: vgadreau/demo


text:
# Benzboy

A tutorial to show how to wrap an external api in to a gem.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'benzboy'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install benzboy

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it ( https://github.com/[my-github-username]/benzboy/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

repository: mantrala/benzboy

repo_name: mantrala/benzboy


text:
---
layout: default
---

# 1996-02-14 - Re: Response to Perrygram

## Header Data

From<EMAIL_ADDRESS>(Timothy C. May)

To<EMAIL_ADDRESS>Message Hash: 701942df8e8d452d5b3e92a4371be44a648aefa6a7ab421e74a6606d8a352f8e

Message ID<EMAIL_ADDRESS>Reply To: _N/A_

UTC Datetime: 1996-02-14 01:23:33 UTC

Raw Date: Tue, 13 Feb 96 17:23:33 PST

## Raw message

```
{% raw  %}From<EMAIL_ADDRESS>(Timothy C. May)
Date: Tue, 13 Feb 96 17:23:33 PST
To<EMAIL_ADDRESS>Subject: Re: Response to Perrygram
Message-ID<EMAIL_ADDRESS>MIME-Version: 1.0
Content-Type: text/plain

At 10:16 PM 2/13/96, Perry E. Metzger wrote:

>I will repeat, Tim. You have no job and do nothing for a living. For
>you it is probably hard to understand that some of us prefer to get
>our mail segregated by topic so that we don't have to spend more time

The issue of what I do with my time is a red herring. As it happens, many
folks in the "cyberspace activism" spend as much time or more as I do on
the Net. In any case, who cares how I spend my time?

I also note that for several years Perry was clearly spending a whole lot
more time than even I am now on the Net, making the "Top Ten Usenet
Posters," or somesuch.

I am sure that when Perry was a Shearson-Lehman, or Lehman Brothers, or
whatever it was called, and was posting several articles an hour on
Extropians, Cypherpunks, Libernet, Usenet, etc., that he would have roughly
the same reaction I am now having to someone writing: "Perry, you are
writing too much--some of us are trying to get some work done!" He would
likely have dismissed their complaints as irrelevant, that no one is forced
to read his articles.

Likewise today. No one is forced to read my posts, Perry's posts, or anyone
else's posts. This is what filters are for. As it happens, I do *not* read
all of the posts here. In fact, I delete about 90% of them after scanning
the first paragraph, the subject, and the author. Takes me about 15
seconds, tops, to do this, and sometimes I'm even faster. (Do the math: I
can "dispose of" about 50 or 60 messages a day in 10-15 minutes...and this
is about the best that can be hoped for, even if Perry were the moderator
and the 10 or so messages a day that are truly off the wall were screened
out...it just wouldn't change the basic time to screen all that much.)

>than needed reading our email. However, for some of us, time is
>money. I have failed to directly answer your comments on this sort of
>thing out of deference to your "elder statesman" status around here,

Spare me, Perry. As I mentioned, you certainly used to write a truly vast
number of rants to Extropians, Libernet, and, yes, even Cypherpunks. A
check of the archives will show this clearly.

It is well and good that you apparently are now very busy and cannot write
your customary number of articles. But spare us the insinuations (in
several of your perrygrams) that because you are too busy to write you are
doing critical work and because some of us use our time to write we are
slackers.

I write because setting down my thoughts and exploring ideas is far more
important to me than just about anything else I can imagine doing,
including writing C programs. If you don't like this, learn how to use
filters and filter me out, or leave the Cypherpunks list. Seems simple
enough to me.

--Tim May

>but this is getting silly. If you want to post about libertarianism,
>libernet, so far as I know, still takes postings. If you want to read
>about the habits of migrating birds, there are interest groups for
>that. We don't have a lot of good places to discuss specifically
>cryptography and its impact, and this group was set up *for that*.
>
>I mean, why not just have one mailing list for all topics of all sorts
>if "filtering" and "hitting the 'd' key" are supposed to be the only
>way we deal with this stuff, hmm?
>
>Perry

Boycott espionage-enabled software!
We got computers, we're tapping phone lines, we know that that ain't allowed.
---------:---------:---------:---------:---------:---------:---------:----
Timothy C. May              | Crypto Anarchy: encryption, digital money,
<EMAIL_ADDRESS>408-728-0152 | anonymous networks, digital pseudonyms, zero
W.A.S.T.E.: Corralitos, CA  | knowledge, reputations, information markets,
Higher Power: 2^756839 - 1  | black markets, collapse of governments.
"National borders aren't even speed bumps on the information superhighway."

{% endraw %}
```

## Thread

+ Return to [February 1996](/archive/1996/02)

+ Return to<EMAIL_ADDRESS>(Dr. Dimitri Vulis)](/authors/dlv_at_bwalk_dm_com_dr_dimitri_vulis_)"
+ Return to "["Perry E. Metzger" <perry@piermont.com>](/authors/perry_e_metzger_perry_at_piermont_com_)"
+ Return to<EMAIL_ADDRESS>(Timothy C. May)](/authors/tcmay_at_got_net_timothy_c_may_)"

+ 1996-02-14 (Tue, 13 Feb 96 17:23:33 PST) - Re: Response to Perrygram -<EMAIL_ADDRESS>(Timothy C. May)_
  + 1996-02-15 (Thu, 15 Feb 1996 10:23:17 +0800) - [Re: Response to Perrygram](/archive/1996/02/1ad215d31dfdfc0837861ed0c8dd52a7c49d052b9da8098282a8a3b4e1deb502) - _"Perry E. Metzger"<EMAIL_ADDRESS>    + 1996-02-15 (Thu, 15 Feb 1996 18:42:08 +0800) - [Re: Response to Perrygram](/archive/1996/02/c2fe542e6eb5502c02ecf363daec88fabd743ca95ce17c1c4ac3f27d93e0a843) -<EMAIL_ADDRESS>(Dr. Dimitri Vulis)_


text:
# Reference

Reference materials.

The tests case shown in this documentation are going to use the Catch2 framework. But there is no direct dependency between FSeam and any testing framework (you can use [GTest](https://github.com/google/googletest), [CppUnit](https://github.com/Ultimaker/CppUnit) or any [other testing framework](https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C++) with FSeam).

**Globals:**
* [Quick Start](cheat-sheet.md#cheat-sheet)
* [FSeam Tutorial](http://freeyoursoul.online/fseam-a-mocking-framework-that-requires-no-change-in-code-part-2/)
* [Why FSeam?](why-fseam.md#fseam-answer)

**Usage:**
* [Install fseam](usage.md#install)
* [CMake integration](usage.md#cmake-with-fseam)

**Writing tests:**
* [Verifications](testing.md#verifications)
* [Arguments expectations](testing.md#argument-expectation)
* [Free functions mock](free-functions.md#free-functions)
* [Custom Logging](logging.md#logging)

**Other:**

* [Todo list](future.md#future-to-be-implemented)
* [Known limitations](limitations.md#known-limitations)
* [Contributions](contributing.md#contributing-to-fseam)

### Internal documentation

This documentation is about implementation details and is not needed to be read.

repository: jenisys/FSeam

repo_name: jenisys/FSeam


text:
# Typescript - Typings autoinstaller
Project home - [https://github.com/jvitor83/typings-autoinstaller](https://github.com/jvitor83/typings-autoinstaller)

## Installation
You can browse and install extensions from within VS Code. Press `Ctrl+P` and narrow down the list commands by typing `ext install typings-autoinstaller`.

### Usage
Any time you save either package.json or bower.json the typings packages will be installed/uninstalled automatically in the background.

#### Commands
To initially install all typings of a project, open the Command Palette with F1 and type in `Typings: Install definitions for all dependencies`, press Enter to select it.

#### How it works
It watch for dependencies, devDependencies and engines and use the name of those packages to run `typings install dt~xxxxxxx --global --save`.
> More info at: [https://github.com/typings/typings](https://github.com/typings/typings)

### Contributing
Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the [Issues section](https://github.com/jvitor83/typings-autoinstaller/issues)).
Please make sure all commits are properly documented.

### License
MIT-licensed

** Enjoy! **


text:
### Socket server/client samples

The ***first goal*** is to show an example of a service, using **non-blocking tcp sockets**. :+1:

```
non_blocking_service.py
```

Also, for completeness and comparation, there is an example of a service using **blocking tcp sockets**:

```
blocking_socket.py
```

And a **connectionless server/client** example:

```
connectionless_service.py
connectionless_client.py
```

#### How to use them:
1- Download it:

```
git clone --depth=1 https://github.com/facundovictor/non-blocking-socket-samples.git
```

2- Execute the example with python, as an example:

```
python non_blocking_service.py
```


text:
# My wonderful world of iOS [![Thanks](https://img.shields.io/badge/Say%20Thanks-💗-ff69b4.svg)](https://www.patreon.com/nikitavoloboev)
> List of applications and tools that make my iOS experience even more amazing

> [Wallpaper link](https://ello.co/maalavidaa/post/0avsbcnwu5jet6j-uckz2g)

##### Contents
- [Philosophy](#philosophy)
- [Applications](#applications)
	- [Social](#social)
	- [Productivity](#productivity)
	- [Photos](#photos)
	- [Learn](#learn)
	- [Utilities](#utilities)
	- [Write](#write)
	- [Music](#music)
- [Widgets](#widgets)
- [Control Center](#control-center)
- [Screen Time](#screen-time)
- [My wonderful world of macOS](#my-wonderful-world-of-macos-)
- [Related](#related)
- [Contributing](#contributing)

## Philosophy
For me, an iPhone is essentially a consumption and communication device. I can
do everything I can do on the phone, faster and better on the laptop. Thus I find it is very valuable to give each of these devices a well defined purpose and use them in this way.

With all the freedom and power that a smartphone brings, it also brings a lot of **distraction**. There is Twitter, Reddit, Instagram with their endless feeds of streaming live updating content. Reddit, Hacker News, Medium or any other news outlet you prefer to stay on top of news. Staying on top of everything at all times is exhausting and addictive.

I use my phone when I am not using my computer. I use it to read books, update my budget, make photographs, quickly edit them, check tasks I have set out to do, listen to podcasts, music, audio books, read Wikipedia, answer messages on slack, telegram, write quick notes and memos, search the internet and read my mail. I of course do other things too, but these are the main ones. With that said, I try to use the best tools that I can to get these tasks completed.

## Applications
Here is a list of apps that I use the most in my day to day life, sorted by category and their importance.

### Social
#### [Telegram](https://itunes.apple.com/us/app/telegram-x/id898228810?mt=8) - Messenger
- This is my favourite messenger and I prefer it over others due its speed, its ability to sync with a native macOS client and the many free and awesome stickers you can use.
- I also use the app to quickly send media/messages between my mac and the phone.

#### [Tweetbot](https://itunes.apple.com/us/app/tweetbot-4-for-twitter/id1018355599?mt=8) - Twitter client
- My favorite Twitter client. I prefer it over others for its ability to sync timelines with the macOS app and the night theme.

#### [Apollo](https://itunes.apple.com/us/app/apollo-for-reddit/id979274575?mt=8) - Reddit client
- My preferred client for browsing Reddit. I love how you can operate the app seamlessly with gestures. I also customized the app to work with my own gestures.

#### [Spark](https://sparkmailapp.com) - Mail client
- My favorite email client that I love due its simplicity of UI and UX.

#### [Slack](https://itunes.apple.com/app/slack-team-communication/id618783545) - Team communication
- I only keep essential teams I am signed up on there.

### Productivity
#### [2Do](https://www.2doapp.com/ios/) - Flexible task manager
- My task manager of choice. I mostly use it to view the tasks I have made on the mac that I need to complete for today.
- I can separate the tasks by tags and filter through everything nicely. I wrote more on how I use the app [here](https://wiki.nikitavoloboev.xyz/macOS/apps/2do.html).

#### [Day One](https://dayoneapp.com) - Digital journal
- I often use it to check on events that happened to me `On this day`.
- I wrote about all the different journals I use and how [here](https://wiki.nikitavoloboev.xyz/macOS/apps/day-one.html).

#### [Streaks](https://streaksapp.com) - Habit tracker
- Do something often enough and it becomes a habit. I try to [cultivate and grow new healthy habits with time](https://wiki.nikitavoloboev.xyz/focusing/habits.html).
- I use the app to list the habits I hope to integrate in my life. If I get 30 ongoing repetitions, I remove the habit and add new ones.

#### [Strong](http://strongapp.io) - Workout tracker
- I use it to track my workouts. I have a few custom workouts that I made that I can then start and simply follow the exercises and the number of sets for the exercise as my workout progresses.

#### [Paprika](https://itunes.apple.com/us/app/paprika-recipe-manager-3/id1303222868?ls=1&mt=8) - Recipe manager
- I use the app mainly as my meal planner for [recipes](https://github.com/nikitavoloboev/recipes#readme) I want to make during the day. Often I make the meal plans on my mac and then just view the things I plan to eat from my phone and cook it. I try to always cook my own food.
- I also use it as my shopping list.

#### [PDF Expert](https://itunes.apple.com/us/app/pdf-expert-by-readdle/id743974925?mt=8) - PDF reader/editor
- Use it to read PDF books and documents. I use and love its `Text Reflow` feature that allows me to focus on the text and see only that. I try to not waste time on my phone and always do something proactive and useful. I also have a [huge list of books I want to read](https://wiki.nikitavoloboev.xyz/books/books.html).

#### [MindNode](https://mindnode.com/mindnode/ios) - Interactive Mind Mapping
- Use it quickly review various mind maps I made. I like the mind mapping format and I wrote about it in more detail [here](https://medium.com/@nikitavoloboev/mind-map-everything-d27670f70739#.p7w44kr44).

### Photos
#### [Photos](http://www.apple.com/lae/ios/photos/) - Photo library
- Right now my photos are a mess and I can't find a good way to organize them well like I can with [Pixave](http://www.littlehj.com/).
- But nevertheless this is the only place right now where I can store my personal images.

#### [VSCO](https://itunes.apple.com/us/app/vsco/id588013838?mt=8) - Image editor and photo sharing
- Use it to quickly edit photographs I made as I much prefer its filters and editing options than other photo editors.
- I then post the edited photos I like to Instagram.

#### [Instagram](https://itunes.apple.com/us/app/instagram/id389801252?mt%3D8) - Photo sharing
- Like it as a way to share my life through photographs, videos and stories.
- I block [camera and microphone access](https://medium.com/@damln/instagram-is-listening-to-you-97e8f2c53023) and only cross post edited photographs from VSCO.

### Learn
#### [Books](https://www.apple.com/ibooks/)
- Aside from PDFs that I read in PDF Expert, I also read `.epub` books which this app handles well. It also syncs my notes and highlights as I read the book.

#### [V for Wiki](http://v-for-wiki.com) - Wiki reader
- Amazing and beautiful Wikipedia reader. The typography of it and the design makes you explore and easily get lost in reading the wiki.

#### [Medium](https://itunes.apple.com/us/app/medium/id828256236?mt=8) - Online publishing platform
- Use the app to read articles on Medium.

#### [Trello](https://itunes.apple.com/us/app/trello/id461504587?mt=8) - Project management tool
- All of my [ideas](https://trello.com/b/alB1ryRP) and plans live on Trello. The app makes accessing any Trello board I need quickly.

### Utilities
#### [1Password](https://itunes.apple.com/us/app/1password/id568903335?mt=8) - Password manager
- Can't live without the app. It holds all my passwords and anything private so that I only need to remember one thing. My master password.

#### [Overcast](https://overcast.fm) - Podcasts
- Let's me listen to the plethora of podcasts I love.
- I love its [smart<EMAIL_ADDRESS>feature to cut
out on silent pauses.

#### [AdGuard](https://itunes.apple.com/us/app/adguard-adblock-privacy/id1047223162?mt=8) - Safari ad blocker
- Use the app to block annoying ads and tracking in Safari.

#### [Dropbox](https://www.dropbox.com/iphoneapp) - File hosting
- Use it to sync files between my devices. I also use it to sync some applications like YNAB.

#### [ScanBot](https://itunes.apple.com/app/apple-store/id834854351?mt=8) - PDF Scanner
- My life is fully digital. This means I scan every paper I write on.
- When I do that, the image gets dropped to my Dropbox folder and from there gets picked up by [Pixave](http://www.littlehj.com/) and sorted accordingly. From there I can search for anything that I want quickly

#### Apple Clock - Alarms & timers
- I love that Apple finally added night mode to the app. I use it to set my alarms, timers (often created by Siri).

### Write
#### [Ulysses](https://itunes.apple.com/us/app/ulysses/id1225571038?mt=8) - Writing
- Ulysses is my go-to place for anything I want to write.
- I mostly use the app to sometimes make edits to my [wiki](https://wiki.nikitavoloboev.xyz). Since the wiki is a bunch of markdown files in a folder that I keep on Dropbox, I can add that folder to Ulysses as external folder and make edits to it.

### Music
#### [Spotify](https://itunes.apple.com/us/app/spotify-music/id324684580?mt=8) - Music streaming
- Prefer using Spotify over Apple Music due to superior music discovery and ability to create and share playlists easily.

## Widgets
Here are the widgets I use:

I use [Fantastical](https://flexibits.com/fantastical-iphone) to see the events that are coming soon on my schedule. I use [Streaks](https://streaksapp.com/) to mark of habits I have completed throughout the day. I use [Trello](https://trello.com) to quickly add any [ideas](https://trello.com/b/alB1ryRP) or things to Trello. I use [Swarm](https://www.swarmapp.com) to quickly mark off certain locations I have been too. I use [Paprika](https://itunes.apple.com/us/app/paprika-recipe-manager-3/id1303222868?ls=1&mt=8) to see the recipes I have planned to eat/cook for the day. [ScanBot](https://itunes.apple.com/app/apple-store/id834854351?mt=8) to quickly make a scan, `Favorites` to quickly make calls and [Overcast](https://overcast.fm) to see the current & upcoming podcast episodes.

## Control Center
Here is how my control center looks:

## Screen Time
I loved how iOS 12 added the Screen Time feature where now you could set limits to apps & websites as well as set a Downtime time in which only apps you want to use are activated and the rest are disabled. I have turned on Downtime to activate from 10 PM to 8 AM:

Here are the limits I currently have set for apps/websites:

And here are the apps that I allow during Downtime:

The other awesome utility from Screen Time is how I can analyze how I spend the time on my phone and which apps I use the most alongside what notifications get sent to me the most often. I try to cut out any notifications that bring no value to me and the only notifications that can reach me are from my task manager, calendar and Telegram.

## [My wonderful world of macOS 💻](https://github.com/nikitavoloboev/my-mac-os#readme)

![](https://raw.githubusercontent.com/nikitavoloboev/my-mac-os/master/desktop.png)

If you found this interesting, I also have a [similar repository](https://github.com/nikitavoloboev/my-mac-os#readme) going over what applications I use on macOS.

## Related
- [Awesome iOS](https://github.com/vsouza/awesome-ios#readme)

## Contributing
[Suggestions](../../issues/) and pull requests are highly encouraged!

I love finding new awesome tools and apps. If you have a favorite tool or app that you think I missed, please [say it](../../issues/new).

## Thank you 💜
You can support me on [Patreon](https://www.patreon.com/nikitavoloboev) or look into [other projects](https://nikitavoloboev.xyz/projects) I shared.

## License
MIT © [Nikita Voloboev](https://nikitavoloboev.xyz)

repository: parinck/my-ios

repo_name: parinck/my-ios


text:
Recent Progress

* Download builder seems ok after latest fix
* Adam and Richard talked with a couple guys from Microsoft about helping out with Widget Factory docs as they've been getting to know it quite well
* Richard and Andrew met about docs xml and xslt, split task into two, each took a half. Richard will focus on Mediawiki to XML transform using ???, maybe Mediawiki. Andrew will focus on XML to HTML transform using XSLT
* E-board decided there should be temporary sub-teams formed for Download Builder rewrite and ThemeRoller refactor projects
* Some discussion of whether next version of ThemeRoller should do away with theme gallery/pre-built themes. Discussion will continue on wiki with rework

Todos

* Ralph: move build checklists from basecamp to wiki
* Corey: start figuring out how to document effects using new XML format
* Scott: finish reviewing tab fixes, try and get Tabs ready for 1.9m5
* All: Review https://github.com/jquery/jquery-color/commits/api-2 and https://public.etherpad-mozilla.org/p/jquery-color-api

Still open

* ???: Need a link on developer links section of jqueryui.com to jquery-ui.git
* Richard: create a wiki page for new docs XML and XSLT effort
* Todd: create a wiki page gathering ThemeRoller rewrite status and forward-looking requirements and needed changes, ideally to support 1.9 and looking ahead to mobile+swatches
* Dan: Jenkins-TestSwarm plugin
* Dan: Hotlinking issue with Themeswitcher
* Dan: See if we should move swarm.jquery.org


text:
# DiskMate Website

DiskMate landing page using GatsbyJS and Bulma. Feel free to use this as a template for your projects.

[![screenshot](screenshot.png 'screenshot')](https://diskmate.tombiel.com)

1. **Install dependencies.**

   ```shell
   npm install
   ```

3. **Start the site in `develop` mode.**

   ```sh
   gatsby develop
   # Running at http://localhost:8000
   ```

3. **Start the site in `build` mode.**

   ```sh
   gatsby build
   ```

---

- Copyright (c) 2019 Tom Biel
- All Rights Reserved

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default)

repository: tom-biel/diskmate-website

repo_name: tom-biel/diskmate-website


text:
# eslint-config-pigeon

**:bird: O-pigeon-ated eslint configuration.**

This configuration uses the typescript eslint parser with plugins and rules for
better structured development and is very opinionated.
It is brand new so rules will be added when we feel the need to.

## How to use
```sh
# Install configuration
yarn add eslint-config-pigeon --dev

# Install peer dependencies
npx install-peerdeps eslint-config-pigeon -DY

# Extend config in package.json
"eslintConfig": {
  "extends": [
    "pigeon"
  ]
},
```

## Upgrade
To upgrade to the latest version run the following commands:
```sh
# Upgrade configuration
yarn upgrade eslint-config-pigeon --latest

# Upgrade peer dependencies
npx install-peerdeps eslint-config-pigeon -DY
```

repository: SanderHeling/eslint-config-pigeon

repo_name: SanderHeling/eslint-config-pigeon


text:
# 2020-07-30-git_collaboration-lcmanoj
Git collaboration notes

- git clone url : downloads the repository from remote to local. Do not nest repos. Do this only once

## Branches
- git branch -a : list all branches
- git branch branchName : create branch where HEAD is
- git switch branchName : move to branch

# More commands
- git fetch --prune : clean git history and remove references from remote
- git branch -d branchName : removes branch from local
- git checkout -b branchName