text:
# Questioner
![](https://i.imgur.com/SVj3C1U.png)
Questioner is a web app that enables users to create meetups and post questions and comments on the meetups and do basic log monitoring via the user's profile. Users can monitor upcoming meetups and even go further to have a curated list of top questions on upcoming meetups accessible right in their profile.

[![Build Status](https://travis-ci.org/wachiranduati/Questioner.svg?branch=develop)](https://travis-ci.org/wachiranduati/Questioner)
[![Coverage Status](https://coveralls.io/repos/github/wachiranduati/Questioner/badge.svg?branch=develop)](https://coveralls.io/github/wachiranduati/Questioner?branch=develop)
[![Maintainability](https://api.codeclimate.com/v1/badges/640293f83f49c685503a/maintainability)](https://codeclimate.com/github/wachiranduati/Questioner/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/640293f83f49c685503a/test_coverage)](https://codeclimate.com/github/wachiranduati/Questioner/test_coverage)

## Features Currenctly supported by the api
 1. create a meetup record.
 2. Create a question record.
 3. Get a specific meetup record
 4. Get all meetup records.
 5. Upvote or downvote a question.
 6. Rsvp for a meetup.

## Functional Api Endpoints
[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/16214aa917050d5b8926)

Method        | EndPoint      | Functionality |
------------- | ------------- | ---------------
POST  | /api/v1/meetups  | Create a meetup record   |
GET  | /api/v1/meetups/<meetup-id>  | Fetch a specific meetup record.   |
GET  | /api/v1/meetups/upcoming   | Fetch all upcoming meetup records   |
GET  | /api/v1/questions/<questionId> | Fetch a specific question
POST  | /api/v1/questions | Create a question for a specific meetup.   |
PUT  | /api/v1/questions/<question-id>/upvote | Upvote (increase votes by 1) a specific question.   |
PUT | /api/v1/questions/<question-id>/downvote | Downvote (decrease votes by 1) a specific question.   |
POST | /api/v1/meetups/<meetup-id>/rsvps| Respond to meetup RSVP.

[View the Questioner documentation](https://documenter.getpostman.com/view/6358115/RznLHGqe)

## Getting Started

### Prerequisites

- ```Python3``` - A programming language that lets us work more quickly (The universe loves speed!).

- ```Flask``` - A microframework for Python based on Werkzeug, Jinja 2 and good intentions.

- ```Virtualenv``` - A tool to create isolated virtual environment

### Installing

First install python3 into your machine.
Clone this repository and cd into it.
> $ git clone https://github.com/wachiranduati/Questioner.git
> $ cd Questioner
- Install a virtual Environment and activate it

> $ python3 install virtualenvironment
> $ virtualenv env
> $ source venv/bin/activate
- Install all the dependencies using

>$ pip install -r requirements.txt

- run the app
> $ export FLASK_ENV=development
> $ export FLASK_APP=run.py
> $ flask run

## Running the tests

To run tests on this application simply run pytest in the root folder of the application

> $ pytest

![](https://i.imgur.com/uU7gzAG.gif)

###### Typical test on an end point on Questioner
*This is how a correct payload to the `create meetup endpoint` [here](https://questionerplus.herokuapp.com/api/v1/meetups)* looks like.
>{
"location" : "Kasabun",
"images" : ["https://test.materia.io", "https://doesitwork.com"],
"topic" : "Purely testing this",
"happeningOn" : "12-23-2010",
"Tags" : ["Grand Turismo", "Nduthify", "Sleep"],
"details": "lorem ipsum and some other mumbo jumbo all foall in here"
}

###### Expected success response

>{
    "status": 201,
    "data": "The meetup *Purely testing this* was created successfully"
}

##### Response should an error arise
*This was due to a missing **location** field*
>{
    "status": 400,
    "error": "Error with the request field the location field should not be longer than 100 nor smaller than 4 or does not exist"
}

*This was trying to send the same payload again **recreate the same meetup***
>{
    "status": 409,
    "error": "Sorry the meetup already exists"
}

## Built With
- ```Python3``` - Python is an object-oriented, high-level programming language with integrated dynamic semantics primarily for web and app development

- ```Flask``` - A microframework for Python based on Werkzeug, Jinja 2 and good intentions.

- ```Virtualenv``` - A tool to create isolated virtual environment
- ```Flask-restplus``` - A tool

## Authors

* **Nicholas Nduati** - *Initial work* - [WachiraNduati](https://github.com/wachiranduati)

## License

This project is licensed under the MIT License

## Acknowledgments

* *Nbo-36 #Team3*
* Solomon Macharia
* Kelyn Paul
* Jackline Muthoni
* Nbo-36 members

repository: wachiranduati/Questioner

repo_name: wachiranduati/Questioner


text:
---
layout:      post
title:       "Exercise 6.10: Tail Bounds for Non-Symmetric Matrices"
sorting_tag: "0610"
tags:        [chapter 6]
comments:    true
---

## (a)

Since $$\| Q_i \|_2^2 = \| Q_i^2 \|_2$$ for symmetric matrices, and
\begin{align}
  Q_i^2
  =
  \begin{bmatrix}
    A\_i A\_i^\top & 0 \newline
    0 & A\_i^\top A\_i
  \end{bmatrix}
  \, ,
\end{align}
the characteristic equation $$\det(Q_i^2 - \lambda I)$$ tells us that the
eigenvalues of $$Q_i^2$$ are the union of eigenvalues of $$A_i A_i^\top$$, and
$$A_i^\top A_i$$. Since these are the same
\begin{align}
  \\| Q_i \\|\_2
  =
  \sqrt{\\| A\_i A\_i^\top \\|\_2}
  =
  \sqrt{\\| A\_i^\top A\_i \\|\_2}
  =
  \\| A\_i \\|\_2
  \, .
\end{align}

## (b)

Since $$\E [A_i] = 0$$ by assumption, $$\V (Q_i) = \E [Q_i^2]$$. Then by an
argument analogous to (a)
\begin{align}
  \bigl\\| \sum\_i \V(Q\_i) \bigr\\|\_2
  =
  \max \bigl\lbrace
    \bigl\\| \sum\_i \E [A\_i A\_i^\top] \bigr\\|\_2
    ,
    \bigl\\| \sum\_i \E [A\_i^\top A\_i] \bigr\\|\_2
  \bigr\rbrace
  =
  n \sigma^2
  \, .
\end{align}

## (c)

Appealing to the characteristic equation as in (a), we see
$$\|\! \sum_i Q_i \|_2 = \|\! \sum_i A_i \|_2$$. By (a) again,
$$\| Q_i \|_2 = \| A_i \|_2 \leq b$$. Hence we can combine (b) with the
Bernstein concentration bound from Theorem 6.17 to obtain
\begin{align}
  \P \bigl(
    \bigl\\| \sum\_i A\_i \bigr\\|\_2 \geq n \delta
  \bigr)
  \leq
  2 (d\_1 + d\_2)
  \exp \bigl\lbrace
    -\tfrac{n \delta^2}{2(\sigma^2 + b \delta)}
  \bigr\rbrace
  \, ,
\end{align}
where we used $$\rank \bigl[\sum_i \V (Q_i)\bigr] \leq d_1 + d_2$$.

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# `gg-scm.io/pkg/git` Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[Unreleased]: https://github.com/gg-scm/gg-git/compare/v0.1.0...main

## [0.1.0][] - 2020-11-23

Version 0.1 is the first release of the `gg-scm.io/pkg/ghdevice` library.

[0.1.0]: https://github.com/gg-scm/ghdevice/releases/tag/v0.1.0

repository: gg-scm/ghdevice

branch_name: refs/heads/main

repo_name: gg-scm/ghdevice


text:
pdfx-ext
========

Updated and extended version of LaTeX package [pdfx](http://ctan.org/pkg/pdfx) by River Valley. In accordance with the LPPPL, this new version has a new name to avoid confusion.

It mostly focuses on PDF/A-1b compliance and eventually including a reference list in the XMP metadata.

The original package was distributed under the LaTeX Project Public License; this is too.

Goals
-----
I had a few ideas for this package:
 - [x] support all constructs of the original package (including Subject, which wasn't implemented before)
 - [ ] comply with the PDF/A standard (which has its quircks, like allowing at most one `dc:creator` in PDF/A-1)
 - [x] allow the author's URI to be embedded as dcterms:creator
 - [x] embed a subset of the PRISM vocabulary in XMP in the PDF/A prescribed way (partially complete)
 - [ ] embed (subsets of) the FaBiO and CiTO ontologies in XMP in the PDF/A prescribed way
 - [ ] use XMP to embed a layout style-independent and machine readable reference list
 - [ ] provide a construct (macro, or a program) to convert BibTeX to PRISM+CiTO statements in XMP
 - [ ] be a reference implementation for connecting PDF documents created from LaTeX to the Semantic Web/Web of Data :)
 - [ ] support PDF/A-2, which supposedly supports multiple `dc:creator`s

Instructions
------------
Basic install instructions:
 - put *.xmp, pdfx-ext.sty and glyphtounicode-cmr-tex in a directory pdfx-ext in $TEXMF/tex/latex
 - update the TeX package catalog

Usage instructions:
 - create a <project>.xmpdata file containing the metadata
 - copy the .icm file in your project directory
 - add `\usepackage{pdfx-ext}` to the preamble of your LaTeX document
 - run pdfLaTeX as usual.


text:
---
id: ktor-schema
title: Writing Schemas with Ktor
---

GraphQL schema, queries and mutation objects have to implement the corresponding marker interface. You can then configure
GraphQL plugin with references to your objects.

```kotlin
@ContactDirective(
    name = "My Team Name",
    url = "https://myteam.slack.com/archives/teams-chat-room-url",
    description = "send urgent issues to [#oncall](https://yourteam.slack.com/archives/oncall)."
)
@GraphQLDescription("My schema description")
class MySchema : Schema

class HelloWorldQuery : Query {
    fun hello(): String = "Hello World!"
}

class UpdateGreetingMutation : Mutation {
    fun updateGreeting(greeting: String): String = TODO()
}

fun Application.graphQLModule() {
    install(GraphQL) {
        schema {
            packages = listOf("com.example")
            queries = listOf(
                HelloWorldQuery()
            )
            mutations = listOf(
                UpdateGreetingMutation()
            )
            schemaObject = MySchema()
        }
    }
    routing {
        graphQLPostRoute()
    }
}
```

Above code will generate following GraphQL schema

```graphql
schema @contact(description : "send urgent issues to [#oncall](https://yourteam.slack.com/archives/oncall).", name : "My Team Name", url : "https://myteam.slack.com/archives/teams-chat-room-url"){
  query: Query
  mutation: Mutation
}

type Query {
  hello: String!
}

type Mutation {
    updateGreeting(greeting: String!): String!
}
```

repository: ExpediaGroup/graphql-kotlin

gha_language: Kotlin

repo_name: ExpediaGroup/graphql-kotlin


text:
# Image Format

Support Format: **bmp, jpg, png, pbm**

The main Tesseract.js functions (ex. recognize, detect) take an `image` parameter, which should be something that is like an image. What's considered "image-like" differs depending on whether it is being run from the browser or through NodeJS.

On a browser, an image can be:
- an `img`, `video`, or `canvas` element
- a `File` object (from a file `<input>`)
- a path or URL to an accessible image

In Node.js, an image can be
- a path to a local image

repository: deanspina/deanspina

gha_language: JavaScript

repo_name: deanspina/deanspina


text:
---
title: 'url'
displayTitle: 'URL'
category: 'api'
version: 'v18'
---

<Metadata data={{"update":{"type":"introduced_in","version":["v0.10.0"]}}} />

<Stability stability={2}>

Stable

</Stability>

<Metadata version="v18.16.1" data={{"source_link":"lib/url.js"}} />

The `node:url` module provides utilities for URL resolution and parsing. It can
be accessed using:

```mjs|cjs
import url from 'node:url';
--------------
const url = require('node:url');
```

### URL strings and URL objects

A URL string is a structured string containing multiple meaningful components.
When parsed, a URL object is returned containing properties for each of these
components.

The `node:url` module provides two APIs for working with URLs: a legacy API that
is Node.js specific, and a newer API that implements the same
[WHATWG URL Standard][] used by web browsers.

A comparison between the WHATWG and legacy APIs is provided below. Above the URL
`'https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'`, properties
of an object returned by the legacy `url.parse()` are shown. Below it are
properties of a WHATWG `URL` object.

WHATWG URL's `origin` property includes `protocol` and `host`, but not
`username` or `password`.

```text
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                              href                                              │
├──────────┬──┬─────────────────────┬────────────────────────┬───────────────────────────┬───────┤
│ protocol │  │        auth         │          host          │           path            │ hash  │
│          │  │                     ├─────────────────┬──────┼──────────┬────────────────┤       │
│          │  │                     │    hostname     │ port │ pathname │     search     │       │
│          │  │                     │                 │      │          ├─┬──────────────┤       │
│          │  │                     │                 │      │          │ │    query     │       │
"  https:   //    user   :   pass   @ sub.example.com : 8080   /p/a/t/h  ?  query=string   #hash "
│          │  │          │          │    hostname     │ port │          │                │       │
│          │  │          │          ├─────────────────┴──────┤          │                │       │
│ protocol │  │ username │ password │          host          │          │                │       │
├──────────┴──┼──────────┴──────────┼────────────────────────┤          │                │       │
│   origin    │                     │         origin         │ pathname │     search     │ hash  │
├─────────────┴─────────────────────┴────────────────────────┴──────────┴────────────────┴───────┤
│                                              href                                              │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
```

Parsing the URL string using the WHATWG API:

```js
const myURL =
  new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash');
```

Parsing the URL string using the legacy API:

```mjs|cjs
import url from 'node:url';
const myURL =
  url.parse('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash');
--------------
const url = require('node:url');
const myURL =
  url.parse('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash');
```

#### Constructing a URL from component parts and getting the constructed string

It is possible to construct a WHATWG URL from component parts using either the
property setters or a template literal string:

```js|js
const myURL = new URL('https://example.org');
myURL.pathname = '/a/b/c';
myURL.search = '?d=e';
myURL.hash = '#fgh';
--------------
const pathname = '/a/b/c';
const search = '?d=e';
const hash = '#fgh';
const myURL = new URL(`https://example.org${pathname}${search}${hash}`);
```

To get the constructed URL string, use the `href` property accessor:

```js
console.log(myURL.href);
```

### The WHATWG URL API

#### <DataTag tag="C" /> `URL`

<Metadata data={{"changes":[{"version":"v10.0.0","pr-url":"https://github.com/nodejs/node/pull/18281","description":"The class is now available on the global object."}],"update":{"type":"added","version":["v7.0.0","v6.13.0"]}}} />

Browser-compatible `URL` class, implemented by following the WHATWG URL
Standard. [Examples of parsed URLs][] may be found in the Standard itself.
The `URL` class is also available on the global object.

In accordance with browser conventions, all properties of `URL` objects
are implemented as getters and setters on the class prototype, rather than as
data properties on the object itself. Thus, unlike [legacy `urlObject`][]s,
using the `delete` keyword on any properties of `URL` objects (e.g. `delete
myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
return `true`.

##### <DataTag tag="M" /> `new URL(input[, base])`

* `input` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The absolute or relative input URL to parse. If `input`
  is relative, then `base` is required. If `input` is absolute, the `base`
  is ignored. If `input` is not a string, it is [converted to a string][] first.
* `base` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The base URL to resolve against if the `input` is not
  absolute. If `base` is not a string, it is [converted to a string][] first.

Creates a new `URL` object by parsing the `input` relative to the `base`. If
`base` is passed as a string, it will be parsed equivalent to `new URL(base)`.

```js
const myURL = new URL('/foo', 'https://example.org/');
// https://example.org/foo
```

The URL constructor is accessible as a property on the global object.
It can also be imported from the built-in url module:

```mjs|cjs
import { URL } from 'node:url';
console.log(URL === globalThis.URL); // Prints 'true'.
--------------
console.log(URL === require('node:url').URL); // Prints 'true'.
```

A `TypeError` will be thrown if the `input` or `base` are not valid URLs. Note
that an effort will be made to coerce the given values into strings. For
instance:

```js
const myURL = new URL({ toString: () => 'https://example.org/' });
// https://example.org/
```

Unicode characters appearing within the host name of `input` will be
automatically converted to ASCII using the [Punycode][] algorithm.

```js
const myURL = new URL('https://測試');
// https://xn--g6w251d/
```

This feature is only available if the `node` executable was compiled with
[ICU][] enabled. If not, the domain names are passed through unchanged.

In cases where it is not known in advance if `input` is an absolute URL
and a `base` is provided, it is advised to validate that the `origin` of
the `URL` object is what is expected.

```js
let myURL = new URL('http://Example.com/', 'https://example.org/');
// http://example.com/

myURL = new URL('https://Example.com/', 'https://example.org/');
// https://example.com/

myURL = new URL('foo://Example.com/', 'https://example.org/');
// foo://Example.com/

myURL = new URL('http:Example.com/', 'https://example.org/');
// http://example.com/

myURL = new URL('https:Example.com/', 'https://example.org/');
// https://example.org/Example.com/

myURL = new URL('foo:Example.com/', 'https://example.org/');
// foo:Example.com/
```

##### <DataTag tag="M" /> `url.hash`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the fragment portion of the URL.

```js
const myURL = new URL('https://example.org/foo#bar');
console.log(myURL.hash);
// Prints #bar

myURL.hash = 'baz';
console.log(myURL.href);
// Prints https://example.org/foo#baz
```

Invalid URL characters included in the value assigned to the `hash` property
are [percent-encoded][]. The selection of which characters to
percent-encode may vary somewhat from what the [`url.parse()`][] and
[`url.format()`][] methods would produce.

##### <DataTag tag="M" /> `url.host`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the host portion of the URL.

```js
const myURL = new URL('https://example.org:81/foo');
console.log(myURL.host);
// Prints example.org:81

myURL.host = 'example.com:82';
console.log(myURL.href);
// Prints https://example.com:82/foo
```

Invalid host values assigned to the `host` property are ignored.

##### <DataTag tag="M" /> `url.hostname`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the host name portion of the URL. The key difference between
`url.host` and `url.hostname` is that `url.hostname` does _not_ include the
port.

```js
const myURL = new URL('https://example.org:81/foo');
console.log(myURL.hostname);
// Prints example.org

// Setting the hostname does not change the port
myURL.hostname = 'example.com';
console.log(myURL.href);
// Prints https://example.com:81/foo

// Use myURL.host to change the hostname and port
myURL.host = 'example.org:82';
console.log(myURL.href);
// Prints https://example.org:82/foo
```

Invalid host name values assigned to the `hostname` property are ignored.

##### <DataTag tag="M" /> `url.href`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the serialized URL.

```js
const myURL = new URL('https://example.org/foo');
console.log(myURL.href);
// Prints https://example.org/foo

myURL.href = 'https://example.com/bar';
console.log(myURL.href);
// Prints https://example.com/bar
```

Getting the value of the `href` property is equivalent to calling
[`url.toString()`][].

Setting the value of this property to a new value is equivalent to creating a
new `URL` object using [`new URL(value)`][`new URL()`]. Each of the `URL`
object's properties will be modified.

If the value assigned to the `href` property is not a valid URL, a `TypeError`
will be thrown.

##### <DataTag tag="M" /> `url.origin`

<Metadata data={{"changes":[{"version":"v15.0.0","pr-url":"https://github.com/nodejs/node/pull/33325","description":"The scheme \"gopher\" is no longer special and `url.origin` now returns `'null'` for it."}]}} />

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets the read-only serialization of the URL's origin.

```js|js
const myURL = new URL('https://example.org/foo/bar?baz');
console.log(myURL.origin);
// Prints https://example.org
--------------
const idnURL = new URL('https://測試');
console.log(idnURL.origin);
// Prints https://xn--g6w251d

console.log(idnURL.hostname);
// Prints xn--g6w251d
```

##### <DataTag tag="M" /> `url.password`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the password portion of the URL.

```js
const myURL = new URL('https://abc:xyz@example.com');
console.log(myURL.password);
// Prints xyz

myURL.password = '123';
console.log(myURL.href);
// Prints<EMAIL_ADDRESS>```

Invalid URL characters included in the value assigned to the `password` property
are [percent-encoded][]. The selection of which characters to
percent-encode may vary somewhat from what the [`url.parse()`][] and
[`url.format()`][] methods would produce.

##### <DataTag tag="M" /> `url.pathname`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the path portion of the URL.

```js
const myURL = new URL('https://example.org/abc/xyz?123');
console.log(myURL.pathname);
// Prints /abc/xyz

myURL.pathname = '/abcdef';
console.log(myURL.href);
// Prints https://example.org/abcdef?123
```

Invalid URL characters included in the value assigned to the `pathname`
property are [percent-encoded][]. The selection of which characters
to percent-encode may vary somewhat from what the [`url.parse()`][] and
[`url.format()`][] methods would produce.

##### <DataTag tag="M" /> `url.port`

<Metadata data={{"changes":[{"version":"v15.0.0","pr-url":"https://github.com/nodejs/node/pull/33325","description":"The scheme \"gopher\" is no longer special."}]}} />

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the port portion of the URL.

The port value may be a number or a string containing a number in the range
`0` to `65535` (inclusive). Setting the value to the default port of the
`URL` objects given `protocol` will result in the `port` value becoming
the empty string (`''`).

The port value can be an empty string in which case the port depends on
the protocol/scheme:

| protocol | port |
| -------- | ---- |
| "ftp"    | 21   |
| "file"   |      |
| "http"   | 80   |
| "https"  | 443  |
| "ws"     | 80   |
| "wss"    | 443  |

Upon assigning a value to the port, the value will first be converted to a
string using `.toString()`.

If that string is invalid but it begins with a number, the leading number is
assigned to `port`.
If the number lies outside the range denoted above, it is ignored.

```js
const myURL = new URL('https://example.org:8888');
console.log(myURL.port);
// Prints 8888

// Default ports are automatically transformed to the empty string
// (HTTPS protocol's default port is 443)
myURL.port = '443';
console.log(myURL.port);
// Prints the empty string
console.log(myURL.href);
// Prints https://example.org/

myURL.port = 1234;
console.log(myURL.port);
// Prints 1234
console.log(myURL.href);
// Prints https://example.org:1234/

// Completely invalid port strings are ignored
myURL.port = 'abcd';
console.log(myURL.port);
// Prints 1234

// Leading numbers are treated as a port number
myURL.port = '5678abcd';
console.log(myURL.port);
// Prints 5678

// Non-integers are truncated
myURL.port = 1234.5678;
console.log(myURL.port);
// Prints 1234

// Out-of-range numbers which are not represented in scientific notation
// will be ignored.
myURL.port = 1e10; //<PHONE_NUMBER>0, will be range-checked as described below
console.log(myURL.port);
// Prints 1234
```

Numbers which contain a decimal point,
such as floating-point numbers or numbers in scientific notation,
are not an exception to this rule.
Leading numbers up to the decimal point will be set as the URL's port,
assuming they are valid:

```js
myURL.port = 4.567e21;
console.log(myURL.port);
// Prints 4 (because it is the leading number in the string '4.567e21')
```

##### <DataTag tag="M" /> `url.protocol`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the protocol portion of the URL.

```js
const myURL = new URL('https://example.org');
console.log(myURL.protocol);
// Prints https:

myURL.protocol = 'ftp';
console.log(myURL.href);
// Prints ftp://example.org/
```

Invalid URL protocol values assigned to the `protocol` property are ignored.

###### Special schemes

<Metadata data={{"changes":[{"version":"v15.0.0","pr-url":"https://github.com/nodejs/node/pull/33325","description":"The scheme \"gopher\" is no longer special."}]}} />

The [WHATWG URL Standard][] considers a handful of URL protocol schemes to be
_special_ in terms of how they are parsed and serialized. When a URL is
parsed using one of these special protocols, the `url.protocol` property
may be changed to another special protocol but cannot be changed to a
non-special protocol, and vice versa.

For instance, changing from `http` to `https` works:

```js
const u = new URL('http://example.org');
u.protocol = 'https';
console.log(u.href);
// https://example.org/
```

However, changing from `http` to a hypothetical `fish` protocol does not
because the new protocol is not special.

```js
const u = new URL('http://example.org');
u.protocol = 'fish';
console.log(u.href);
// http://example.org/
```

Likewise, changing from a non-special protocol to a special protocol is also
not permitted:

```js
const u = new URL('fish://example.org');
u.protocol = 'http';
console.log(u.href);
// fish://example.org
```

According to the WHATWG URL Standard, special protocol schemes are `ftp`,
`file`, `http`, `https`, `ws`, and `wss`.

##### <DataTag tag="M" /> `url.search`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the serialized query portion of the URL.

```js
const myURL = new URL('https://example.org/abc?123');
console.log(myURL.search);
// Prints ?123

myURL.search = 'abc=xyz';
console.log(myURL.href);
// Prints https://example.org/abc?abc=xyz
```

Any invalid URL characters appearing in the value assigned the `search`
property will be [percent-encoded][]. The selection of which
characters to percent-encode may vary somewhat from what the [`url.parse()`][]
and [`url.format()`][] methods would produce.

##### <DataTag tag="M" /> `url.searchParams`

* [`URLSearchParams`](/api/v18/url#urlsearchparams)

Gets the [`URLSearchParams`][] object representing the query parameters of the
URL. This property is read-only but the `URLSearchParams` object it provides
can be used to mutate the URL instance; to replace the entirety of query
parameters of the URL, use the [`url.search`][] setter. See
[`URLSearchParams`][] documentation for details.

Use care when using `.searchParams` to modify the `URL` because,
per the WHATWG specification, the `URLSearchParams` object uses
different rules to determine which characters to percent-encode. For
instance, the `URL` object will not percent encode the ASCII tilde (`~`)
character, while `URLSearchParams` will always encode it:

```js
const myURL = new URL('https://example.org/abc?foo=~bar');

console.log(myURL.search);  // prints ?foo=~bar

// Modify the URL via searchParams...
myURL.searchParams.sort();

console.log(myURL.search);  // prints ?foo=%7Ebar
```

##### <DataTag tag="M" /> `url.username`

* [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Gets and sets the username portion of the URL.

```js
const myURL = new URL('https://abc:xyz@example.com');
console.log(myURL.username);
// Prints abc

myURL.username = '123';
console.log(myURL.href);
// Prints<EMAIL_ADDRESS>```

Any invalid URL characters appearing in the value assigned the `username`
property will be [percent-encoded][]. The selection of which
characters to percent-encode may vary somewhat from what the [`url.parse()`][]
and [`url.format()`][] methods would produce.

##### <DataTag tag="M" /> `url.toString()`

* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

The `toString()` method on the `URL` object returns the serialized URL. The
value returned is equivalent to that of [`url.href`][] and [`url.toJSON()`][].

##### <DataTag tag="M" /> `url.toJSON()`

* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

The `toJSON()` method on the `URL` object returns the serialized URL. The
value returned is equivalent to that of [`url.href`][] and
[`url.toString()`][].

This method is automatically called when an `URL` object is serialized
with [`JSON.stringify()`][].

```js
const myURLs = [
  new URL('https://www.example.com'),
  new URL('https://test.example.org'),
];
console.log(JSON.stringify(myURLs));
// Prints ["https://www.example.com/","https://test.example.org/"]
```

##### <DataTag tag="M" /> `URL.createObjectURL(blob)`

<Metadata data={{"update":{"type":"added","version":["v16.7.0"]}}} />

<Stability stability={1}>

Experimental

</Stability>

* `blob` [`Blob`](/api/v18/buffer#blob)
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Creates a `'blob:nodedata:...'` URL string that represents the given [`Blob`](/api/v18/buffer#blob)
object and can be used to retrieve the `Blob` later.

```js
const {
  Blob,
  resolveObjectURL,
} = require('node:buffer');

const blob = new Blob(['hello']);
const id = URL.createObjectURL(blob);

// later...

const otherBlob = resolveObjectURL(id);
console.log(otherBlob.size);
```

The data stored by the registered [`Blob`](/api/v18/buffer#blob) will be retained in memory until
`URL.revokeObjectURL()` is called to remove it.

`Blob` objects are registered within the current thread. If using Worker
Threads, `Blob` objects registered within one Worker will not be available
to other workers or the main thread.

##### <DataTag tag="M" /> `URL.revokeObjectURL(id)`

<Metadata data={{"update":{"type":"added","version":["v16.7.0"]}}} />

<Stability stability={1}>

Experimental

</Stability>

* `id` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) A `'blob:nodedata:...` URL string returned by a prior call to
  `URL.createObjectURL()`.

Removes the stored [`Blob`](/api/v18/buffer#blob) identified by the given ID. Attempting to revoke a
ID that isn't registered will silently fail.

#### <DataTag tag="C" /> `URLSearchParams`

<Metadata data={{"changes":[{"version":"v10.0.0","pr-url":"https://github.com/nodejs/node/pull/18281","description":"The class is now available on the global object."}],"update":{"type":"added","version":["v7.5.0","v6.13.0"]}}} />

The `URLSearchParams` API provides read and write access to the query of a
`URL`. The `URLSearchParams` class can also be used standalone with one of the
four following constructors.
The `URLSearchParams` class is also available on the global object.

The WHATWG `URLSearchParams` interface and the [`querystring`][] module have
similar purpose, but the purpose of the [`querystring`][] module is more
general, as it allows the customization of delimiter characters (`&` and `=`).
On the other hand, this API is designed purely for URL query strings.

```js
const myURL = new URL('https://example.org/?abc=123');
console.log(myURL.searchParams.get('abc'));
// Prints 123

myURL.searchParams.append('abc', 'xyz');
console.log(myURL.href);
// Prints https://example.org/?abc=123&abc=xyz

myURL.searchParams.delete('abc');
myURL.searchParams.set('a', 'b');
console.log(myURL.href);
// Prints https://example.org/?a=b

const newSearchParams = new URLSearchParams(myURL.searchParams);
// The above is equivalent to
// const newSearchParams = new URLSearchParams(myURL.search);

newSearchParams.append('a', 'c');
console.log(myURL.href);
// Prints https://example.org/?a=b
console.log(newSearchParams.toString());
// Prints a=b&a=c

// newSearchParams.toString() is implicitly called
myURL.search = newSearchParams;
console.log(myURL.href);
// Prints https://example.org/?a=b&a=c
newSearchParams.delete('a');
console.log(myURL.href);
// Prints https://example.org/?a=b&a=c
```

##### <DataTag tag="M" /> `new URLSearchParams()`

Instantiate a new empty `URLSearchParams` object.

##### <DataTag tag="M" /> `new URLSearchParams(string)`

* `string` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) A query string

Parse the `string` as a query string, and use it to instantiate a new
`URLSearchParams` object. A leading `'?'`, if present, is ignored.

```js
let params;

params = new URLSearchParams('user=abc&query=xyz');
console.log(params.get('user'));
// Prints 'abc'
console.log(params.toString());
// Prints 'user=abc&query=xyz'

params = new URLSearchParams('?user=abc&query=xyz');
console.log(params.toString());
// Prints 'user=abc&query=xyz'
```

##### <DataTag tag="M" /> `new URLSearchParams(obj)`

<Metadata data={{"update":{"type":"added","version":["v7.10.0","v6.13.0"]}}} />

* `obj` [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) An object representing a collection of key-value pairs

Instantiate a new `URLSearchParams` object with a query hash map. The key and
value of each property of `obj` are always coerced to strings.

Unlike [`querystring`][] module, duplicate keys in the form of array values are
not allowed. Arrays are stringified using [`array.toString()`][], which simply
joins all array elements with commas.

```js
const params = new URLSearchParams({
  user: 'abc',
  query: ['first', 'second'],
});
console.log(params.getAll('query'));
// Prints [ 'first,second' ]
console.log(params.toString());
// Prints 'user=abc&query=first%2Csecond'
```

##### <DataTag tag="M" /> `new URLSearchParams(iterable)`

<Metadata data={{"update":{"type":"added","version":["v7.10.0","v6.13.0"]}}} />

* `iterable` [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) An iterable object whose elements are key-value pairs

Instantiate a new `URLSearchParams` object with an iterable map in a way that
is similar to [`Map`][]'s constructor. `iterable` can be an `Array` or any
iterable object. That means `iterable` can be another `URLSearchParams`, in
which case the constructor will simply create a clone of the provided
`URLSearchParams`. Elements of `iterable` are key-value pairs, and can
themselves be any iterable object.

Duplicate keys are allowed.

```js
let params;

// Using an array
params = new URLSearchParams([
  ['user', 'abc'],
  ['query', 'first'],
  ['query', 'second'],
]);
console.log(params.toString());
// Prints 'user=abc&query=first&query=second'

// Using a Map object
const map = new Map();
map.set('user', 'abc');
map.set('query', 'xyz');
params = new URLSearchParams(map);
console.log(params.toString());
// Prints 'user=abc&query=xyz'

// Using a generator function
function* getQueryPairs() {
  yield ['user', 'abc'];
  yield ['query', 'first'];
  yield ['query', 'second'];
}
params = new URLSearchParams(getQueryPairs());
console.log(params.toString());
// Prints 'user=abc&query=first&query=second'

// Each key-value pair must have exactly two elements
new URLSearchParams([
  ['user', 'abc', 'error'],
]);
// Throws TypeError [ERR_INVALID_TUPLE]:
//        Each query pair must be an iterable [name, value] tuple
```

##### <DataTag tag="M" /> `urlSearchParams.append(name, value)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* `value` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Append a new name-value pair to the query string.

##### <DataTag tag="M" /> `urlSearchParams.delete(name)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Remove all name-value pairs whose name is `name`.

##### <DataTag tag="M" /> `urlSearchParams.entries()`

* Returns: [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)

Returns an ES6 `Iterator` over each of the name-value pairs in the query.
Each item of the iterator is a JavaScript `Array`. The first item of the `Array`
is the `name`, the second item of the `Array` is the `value`.

Alias for [`urlSearchParams[@@iterator]()`][`urlSearchParams@@iterator()`].

##### <DataTag tag="M" /> `urlSearchParams.forEach(fn[, thisArg])`

<Metadata data={{"changes":[{"version":"v18.0.0","pr-url":"https://github.com/nodejs/node/pull/41678","description":"Passing an invalid callback to the `fn` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}]}} />

* `fn` [`Function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) Invoked for each name-value pair in the query
* `thisArg` [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) To be used as `this` value for when `fn` is called

Iterates over each name-value pair in the query and invokes the given function.

```js
const myURL = new URL('https://example.org/?a=b&c=d');
myURL.searchParams.forEach((value, name, searchParams) => {
  console.log(name, value, myURL.searchParams === searchParams);
});
// Prints:
//   a b true
//   c d true
```

##### <DataTag tag="M" /> `urlSearchParams.get(name)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) or `null` if there is no name-value pair with the given
  `name`.

Returns the value of the first name-value pair whose name is `name`. If there
are no such pairs, `null` is returned.

##### <DataTag tag="M" /> `urlSearchParams.getAll(name)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: string\[]

Returns the values of all name-value pairs whose name is `name`. If there are
no such pairs, an empty array is returned.

##### <DataTag tag="M" /> `urlSearchParams.has(name)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)

Returns `true` if there is at least one name-value pair whose name is `name`.

##### <DataTag tag="M" /> `urlSearchParams.keys()`

* Returns: [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)

Returns an ES6 `Iterator` over the names of each name-value pair.

```js
const params = new URLSearchParams('foo=bar&foo=baz');
for (const name of params.keys()) {
  console.log(name);
}
// Prints:
//   foo
//   foo
```

##### <DataTag tag="M" /> `urlSearchParams.set(name, value)`

* `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* `value` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Sets the value in the `URLSearchParams` object associated with `name` to
`value`. If there are any pre-existing name-value pairs whose names are `name`,
set the first such pair's value to `value` and remove all others. If not,
append the name-value pair to the query string.

```js
const params = new URLSearchParams();
params.append('foo', 'bar');
params.append('foo', 'baz');
params.append('abc', 'def');
console.log(params.toString());
// Prints foo=bar&foo=baz&abc=def

params.set('foo', 'def');
params.set('xyz', 'opq');
console.log(params.toString());
// Prints foo=def&abc=def&xyz=opq
```

##### <DataTag tag="M" /> `urlSearchParams.size`

<Metadata data={{"update":{"type":"added","version":["v18.16.0"]}}} />

The total number of parameter entries.

##### <DataTag tag="M" /> `urlSearchParams.sort()`

<Metadata data={{"update":{"type":"added","version":["v7.7.0","v6.13.0"]}}} />

Sort all existing name-value pairs in-place by their names. Sorting is done
with a [stable sorting algorithm][], so relative order between name-value pairs
with the same name is preserved.

This method can be used, in particular, to increase cache hits.

```js
const params = new URLSearchParams('query[]=abc&type=search&query[]=123');
params.sort();
console.log(params.toString());
// Prints query%5B%5D=abc&query%5B%5D=123&type=search
```

##### <DataTag tag="M" /> `urlSearchParams.toString()`

* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Returns the search parameters serialized as a string, with characters
percent-encoded where necessary.

##### <DataTag tag="M" /> `urlSearchParams.values()`

* Returns: [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)

Returns an ES6 `Iterator` over the values of each name-value pair.

##### <DataTag tag="M" /> `urlSearchParams[Symbol.iterator]()`

* Returns: [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)

Returns an ES6 `Iterator` over each of the name-value pairs in the query string.
Each item of the iterator is a JavaScript `Array`. The first item of the `Array`
is the `name`, the second item of the `Array` is the `value`.

Alias for [`urlSearchParams.entries()`][].

```js
const params = new URLSearchParams('foo=bar&xyz=baz');
for (const [name, value] of params) {
  console.log(name, value);
}
// Prints:
//   foo bar
//   xyz baz
```

#### <DataTag tag="M" /> `url.domainToASCII(domain)`

<Metadata data={{"update":{"type":"added","version":["v7.4.0","v6.13.0"]}}} />

* `domain` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Returns the [Punycode][] ASCII serialization of the `domain`. If `domain` is an
invalid domain, the empty string is returned.

It performs the inverse operation to [`url.domainToUnicode()`][].

This feature is only available if the `node` executable was compiled with
[ICU][] enabled. If not, the domain names are passed through unchanged.

```mjs|cjs
import url from 'node:url';

console.log(url.domainToASCII('español.com'));
// Prints xn--espaol-zwa.com
console.log(url.domainToASCII('中文.com'));
// Prints xn--fiq228c.com
console.log(url.domainToASCII('xn--iñvalid.com'));
// Prints an empty string
--------------
const url = require('node:url');

console.log(url.domainToASCII('español.com'));
// Prints xn--espaol-zwa.com
console.log(url.domainToASCII('中文.com'));
// Prints xn--fiq228c.com
console.log(url.domainToASCII('xn--iñvalid.com'));
// Prints an empty string
```

#### <DataTag tag="M" /> `url.domainToUnicode(domain)`

<Metadata data={{"update":{"type":"added","version":["v7.4.0","v6.13.0"]}}} />

* `domain` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Returns the Unicode serialization of the `domain`. If `domain` is an invalid
domain, the empty string is returned.

It performs the inverse operation to [`url.domainToASCII()`][].

This feature is only available if the `node` executable was compiled with
[ICU][] enabled. If not, the domain names are passed through unchanged.

```mjs|cjs
import url from 'node:url';

console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty string
--------------
const url = require('node:url');

console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty string
```

#### <DataTag tag="M" /> `url.fileURLToPath(url)`

<Metadata data={{"update":{"type":"added","version":["v10.12.0"]}}} />

* `url` [`URL`](/api/v18/url#the-whatwg-url-api) | [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The file URL string or URL object to convert to a path.
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The fully-resolved platform-specific Node.js file path.

This function ensures the correct decodings of percent-encoded characters as
well as ensuring a cross-platform valid absolute path string.

```mjs|cjs
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);

new URL('file:///C:/path/').pathname;      // Incorrect: /C:/path/
fileURLToPath('file:///C:/path/');         // Correct:   C:\path\ (Windows)

new URL('file://nas/foo.txt').pathname;    // Incorrect: /foo.txt
fileURLToPath('file://nas/foo.txt');       // Correct:   \\nas\foo.txt (Windows)

new URL('file:///你好.txt').pathname;      // Incorrect: /%E4%BD%A0%E5%A5%BD.txt
fileURLToPath('file:///你好.txt');         // Correct:   /你好.txt (POSIX)

new URL('file:///hello world').pathname;   // Incorrect: /hello%20world
fileURLToPath('file:///hello world');      // Correct:   /hello world (POSIX)
--------------
const { fileURLToPath } = require('node:url');
new URL('file:///C:/path/').pathname;      // Incorrect: /C:/path/
fileURLToPath('file:///C:/path/');         // Correct:   C:\path\ (Windows)

new URL('file://nas/foo.txt').pathname;    // Incorrect: /foo.txt
fileURLToPath('file://nas/foo.txt');       // Correct:   \\nas\foo.txt (Windows)

new URL('file:///你好.txt').pathname;      // Incorrect: /%E4%BD%A0%E5%A5%BD.txt
fileURLToPath('file:///你好.txt');         // Correct:   /你好.txt (POSIX)

new URL('file:///hello world').pathname;   // Incorrect: /hello%20world
fileURLToPath('file:///hello world');      // Correct:   /hello world (POSIX)
```

#### <DataTag tag="M" /> `url.format(URL[, options])`

<Metadata data={{"update":{"type":"added","version":["v7.6.0"]}}} />

* `URL` [`URL`](/api/v18/url#the-whatwg-url-api) A [WHATWG URL][] object
* `options` [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
  * `auth` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` if the serialized URL string should include the
    username and password, `false` otherwise. **Default:** `true`.
  * `fragment` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` if the serialized URL string should include the
    fragment, `false` otherwise. **Default:** `true`.
  * `search` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` if the serialized URL string should include the
    search query, `false` otherwise. **Default:** `true`.
  * `unicode` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) `true` if Unicode characters appearing in the host
    component of the URL string should be encoded directly as opposed to being
    Punycode encoded. **Default:** `false`.
* Returns: [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)

Returns a customizable serialization of a URL `String` representation of a
[WHATWG URL][] object.

The URL object has both a `toString()` method and `href` property that return
string serializations of the URL. These are not, however, customizable in
any way. The `url.format(URL[, options])` method allows for basic customization
of the output.

```mjs|cjs
import url from 'node:url';
const myURL = new URL('https://a:b@測試?abc#foo');

console.log(myURL.href);
// Prints https://a:b@xn--g6w251d/?abc#foo

console.log(myURL.toString());
// Prints https://a:b@xn--g6w251d/?abc#foo

console.log(url.format(myURL, { fragment: false, unicode: true, auth: false }));
// Prints 'https://測試/?abc'
--------------
const url = require('node:url');
const myURL = new URL('https://a:b@測試?abc#foo');

console.log(myURL.href);
// Prints https://a:b@xn--g6w251d/?abc#foo

console.log(myURL.toString());
// Prints https://a:b@xn--g6w251d/?abc#foo

console.log(url.format(myURL, { fragment: false, unicode: true, auth: false }));
// Prints 'https://測試/?abc'
```

#### <DataTag tag="M" /> `url.pathToFileURL(path)`

<Metadata data={{"update":{"type":"added","version":["v10.12.0"]}}} />

* `path` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The path to convert to a File URL.
* Returns: [`URL`](/api/v18/url#the-whatwg-url-api) The file URL object.

This function ensures that `path` is resolved absolutely, and that the URL
control characters are correctly encoded when converting into a File URL.

```mjs|cjs
import { pathToFileURL } from 'node:url';

new URL('/foo#1', 'file:');           // Incorrect: file:///foo#1
pathToFileURL('/foo#1');              // Correct:   file:///foo%231 (POSIX)

new URL('/some/path%.c', 'file:');    // Incorrect: file:///some/path%.c
pathToFileURL('/some/path%.c');       // Correct:   file:///some/path%25.c (POSIX)
--------------
const { pathToFileURL } = require('node:url');
new URL(__filename);                  // Incorrect: throws (POSIX)
new URL(__filename);                  // Incorrect: C:\... (Windows)
pathToFileURL(__filename);            // Correct:   file:///... (POSIX)
pathToFileURL(__filename);            // Correct:   file:///C:/... (Windows)

new URL('/foo#1', 'file:');           // Incorrect: file:///foo#1
pathToFileURL('/foo#1');              // Correct:   file:///foo%231 (POSIX)

new URL('/some/path%.c', 'file:');    // Incorrect: file:///some/path%.c
pathToFileURL('/some/path%.c');       // Correct:   file:///some/path%25.c (POSIX)
```

#### <DataTag tag="M" /> `url.urlToHttpOptions(url)`

<Metadata data={{"update":{"type":"added","version":["v15.7.0","v14.18.0"]}}} />

* `url` [`URL`](/api/v18/url#the-whatwg-url-api) The [WHATWG URL][] object to convert to an options object.
* Returns: [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) Options object
  * `protocol` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Protocol to use.
  * `hostname` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) A domain name or IP address of the server to issue the
    request to.
  * `hash` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The fragment portion of the URL.
  * `search` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The serialized query portion of the URL.
  * `pathname` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The path portion of the URL.
  * `path` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Request path. Should include query string if any.
    E.G. `'/index.html?page=12'`. An exception is thrown when the request path
    contains illegal characters. Currently, only spaces are rejected but that
    may change in the future.
  * `href` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The serialized URL.
  * `port` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) Port of remote server.
  * `auth` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Basic authentication i.e. `'user:password'` to compute an
    Authorization header.

This utility function converts a URL object into an ordinary options object as
expected by the [`http.request()`][] and [`https.request()`][] APIs.

```mjs|cjs
import { urlToHttpOptions } from 'node:url';
const myURL = new URL('https://a:b@測試?abc#foo');

console.log(urlToHttpOptions(myURL));
/*
{
  protocol: 'https:',
  hostname: 'xn--g6w251d',
  hash: '#foo',
  search: '?abc',
  pathname: '/',
  path: '/?abc',
  href: 'https://a:b@xn--g6w251d/?abc#foo',
  auth: 'a:b'
}
*/
--------------
const { urlToHttpOptions } = require('node:url');
const myURL = new URL('https://a:b@測試?abc#foo');

console.log(urlToHttpOptions(myURL));
/*
{
  protocol: 'https:',
  hostname: 'xn--g6w251d',
  hash: '#foo',
  search: '?abc',
  pathname: '/',
  path: '/?abc',
  href: 'https://a:b@xn--g6w251d/?abc#foo',
  auth: 'a:b'
}
*/
```

### Legacy URL API

<Metadata data={{"changes":[{"version":["v15.13.0","v14.17.0"],"pr-url":"https://github.com/nodejs/node/pull/37784","description":"Deprecation revoked. Status changed to \"Legacy\"."},{"version":"v11.0.0","pr-url":"https://github.com/nodejs/node/pull/22715","description":"This API is deprecated."}]}} />

<Stability stability={3}>

Legacy: Use the WHATWG URL API instead.

</Stability>

#### Legacy `urlObject`

<Metadata data={{"changes":[{"version":["v15.13.0","v14.17.0"],"pr-url":"https://github.com/nodejs/node/pull/37784","description":"Deprecation revoked. Status changed to \"Legacy\"."},{"version":"v11.0.0","pr-url":"https://github.com/nodejs/node/pull/22715","description":"The Legacy URL API is deprecated. Use the WHATWG URL API."}]}} />

<Stability stability={3}>

Legacy: Use the WHATWG URL API instead.

</Stability>

The legacy `urlObject` (`require('node:url').Url` or
`import { Url } from 'node:url'`) is
created and returned by the `url.parse()` function.

##### <DataTag tag="M" /> `urlObject.auth`

The `auth` property is the username and password portion of the URL, also
referred to as _userinfo_. This string subset follows the `protocol` and
double slashes (if present) and precedes the `host` component, delimited by `@`.
The string is either the username, or it is the username and password separated
by `:`.

For example: `'user:pass'`.

##### <DataTag tag="M" /> `urlObject.hash`

The `hash` property is the fragment identifier portion of the URL including the
leading `#` character.

For example: `'#hash'`.

##### <DataTag tag="M" /> `urlObject.host`

The `host` property is the full lower-cased host portion of the URL, including
the `port` if specified.

For example: `'sub.example.com:8080'`.

##### <DataTag tag="M" /> `urlObject.hostname`

The `hostname` property is the lower-cased host name portion of the `host`
component _without_ the `port` included.

For example: `'sub.example.com'`.

##### <DataTag tag="M" /> `urlObject.href`

The `href` property is the full URL string that was parsed with both the
`protocol` and `host` components converted to lower-case.

For example: `'http://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'`.

##### <DataTag tag="M" /> `urlObject.path`

The `path` property is a concatenation of the `pathname` and `search`
components.

For example: `'/p/a/t/h?query=string'`.

No decoding of the `path` is performed.

##### <DataTag tag="M" /> `urlObject.pathname`

The `pathname` property consists of the entire path section of the URL. This
is everything following the `host` (including the `port`) and before the start
of the `query` or `hash` components, delimited by either the ASCII question
mark (`?`) or hash (`#`) characters.

For example: `'/p/a/t/h'`.

No decoding of the path string is performed.

##### <DataTag tag="M" /> `urlObject.port`

The `port` property is the numeric port portion of the `host` component.

For example: `'8080'`.

##### <DataTag tag="M" /> `urlObject.protocol`

The `protocol` property identifies the URL's lower-cased protocol scheme.

For example: `'http:'`.

##### <DataTag tag="M" /> `urlObject.query`

The `query` property is either the query string without the leading ASCII
question mark (`?`), or an object returned by the [`querystring`][] module's
`parse()` method. Whether the `query` property is a string or object is
determined by the `parseQueryString` argument passed to `url.parse()`.

For example: `'query=string'` or `{'query': 'string'}`.

If returned as a string, no decoding of the query string is performed. If
returned as an object, both keys and values are decoded.

##### <DataTag tag="M" /> `urlObject.search`

The `search` property consists of the entire "query string" portion of the
URL, including the leading ASCII question mark (`?`) character.

For example: `'?query=string'`.

No decoding of the query string is performed.

##### <DataTag tag="M" /> `urlObject.slashes`

The `slashes` property is a `boolean` with a value of `true` if two ASCII
forward-slash characters (`/`) are required following the colon in the
`protocol`.

#### <DataTag tag="M" /> `url.format(urlObject)`

<Metadata data={{"changes":[{"version":"v17.0.0","pr-url":"https://github.com/nodejs/node/pull/38631","description":"Now throws an `ERR_INVALID_URL` exception when Punycode conversion of a hostname introduces changes that could cause the URL to be re-parsed differently."},{"version":["v15.13.0","v14.17.0"],"pr-url":"https://github.com/nodejs/node/pull/37784","description":"Deprecation revoked. Status changed to \"Legacy\"."},{"version":"v11.0.0","pr-url":"https://github.com/nodejs/node/pull/22715","description":"The Legacy URL API is deprecated. Use the WHATWG URL API."},{"version":"v7.0.0","pr-url":"https://github.com/nodejs/node/pull/7234","description":"URLs with a `file:` scheme will now always use the correct number of slashes regardless of `slashes` option. A falsy `slashes` option with no protocol is now also respected at all times."}],"update":{"type":"added","version":["v0.1.25"]}}} />

<Stability stability={3}>

Legacy: Use the WHATWG URL API instead.

</Stability>

* `urlObject` [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) A URL object (as returned by `url.parse()` or
  constructed otherwise). If a string, it is converted to an object by passing
  it to `url.parse()`.

The `url.format()` method returns a formatted URL string derived from
`urlObject`.

```js
const url = require('node:url');
url.format({
  protocol: 'https',
  hostname: 'example.com',
  pathname: '/some/path',
  query: {
    page: 1,
    format: 'json',
  },
});

// => 'https://example.com/some/path?page=1&format=json'
```

If `urlObject` is not an object or a string, `url.format()` will throw a
[`TypeError`][].

The formatting process operates as follows:

* A new empty string `result` is created.
* If `urlObject.protocol` is a string, it is appended as-is to `result`.
* Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an
  [`Error`][] is thrown.
* For all string values of `urlObject.protocol` that _do not end_ with an ASCII
  colon (`:`) character, the literal string `:` will be appended to `result`.
* If either of the following conditions is true, then the literal string `//`
  will be appended to `result`:
  * `urlObject.slashes` property is true;
  * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or
    `file`;
* If the value of the `urlObject.auth` property is truthy, and either
  `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of
  `urlObject.auth` will be coerced into a string and appended to `result`
  followed by the literal string `@`.
* If the `urlObject.host` property is `undefined` then:
  * If the `urlObject.hostname` is a string, it is appended to `result`.
  * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string,
    an [`Error`][] is thrown.
  * If the `urlObject.port` property value is truthy, and `urlObject.hostname`
    is not `undefined`:
    * The literal string `:` is appended to `result`, and
    * The value of `urlObject.port` is coerced to a string and appended to
      `result`.
* Otherwise, if the `urlObject.host` property value is truthy, the value of
  `urlObject.host` is coerced to a string and appended to `result`.
* If the `urlObject.pathname` property is a string that is not an empty string:
  * If the `urlObject.pathname` _does not start_ with an ASCII forward slash
    (`/`), then the literal string `'/'` is appended to `result`.
  * The value of `urlObject.pathname` is appended to `result`.
* Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an
  [`Error`][] is thrown.
* If the `urlObject.search` property is `undefined` and if the `urlObject.query`
  property is an `Object`, the literal string `?` is appended to `result`
  followed by the output of calling the [`querystring`][] module's `stringify()`
  method passing the value of `urlObject.query`.
* Otherwise, if `urlObject.search` is a string:
  * If the value of `urlObject.search` _does not start_ with the ASCII question
    mark (`?`) character, the literal string `?` is appended to `result`.
  * The value of `urlObject.search` is appended to `result`.
* Otherwise, if `urlObject.search` is not `undefined` and is not a string, an
  [`Error`][] is thrown.
* If the `urlObject.hash` property is a string:
  * If the value of `urlObject.hash` _does not start_ with the ASCII hash (`#`)
    character, the literal string `#` is appended to `result`.
  * The value of `urlObject.hash` is appended to `result`.
* Otherwise, if the `urlObject.hash` property is not `undefined` and is not a
  string, an [`Error`][] is thrown.
* `result` is returned.

#### <DataTag tag="M" /> `url.parse(urlString[, parseQueryString[, slashesDenoteHost]])`

<Metadata data={{"changes":[{"version":"v18.13.0","pr-url":"https://github.com/nodejs/node/pull/44919","description":"Documentation-only deprecation."},{"version":["v15.13.0","v14.17.0"],"pr-url":"https://github.com/nodejs/node/pull/37784","description":"Deprecation revoked. Status changed to \"Legacy\"."},{"version":"v11.14.0","pr-url":"https://github.com/nodejs/node/pull/26941","description":"The `pathname` property on the returned URL object is now `/` when there is no path and the protocol scheme is `ws:` or `wss:`."},{"version":"v11.0.0","pr-url":"https://github.com/nodejs/node/pull/22715","description":"The Legacy URL API is deprecated. Use the WHATWG URL API."},{"version":"v9.0.0","pr-url":"https://github.com/nodejs/node/pull/13606","description":"The `search` property on the returned URL object is now `null` when no query string is present."}],"update":{"type":"added","version":["v0.1.25"]}}} />

<Stability stability={0}>

Deprecated: Use the WHATWG URL API instead.

</Stability>

* `urlString` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The URL string to parse.
* `parseQueryString` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) If `true`, the `query` property will always
  be set to an object returned by the [`querystring`][] module's `parse()`
  method. If `false`, the `query` property on the returned URL object will be an
  unparsed, undecoded string. **Default:** `false`.
* `slashesDenoteHost` [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) If `true`, the first token after the literal
  string `//` and preceding the next `/` will be interpreted as the `host`.
  For instance, given `//foo/bar`, the result would be
  `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
  **Default:** `false`.

The `url.parse()` method takes a URL string, parses it, and returns a URL
object.

A `TypeError` is thrown if `urlString` is not a string.

A `URIError` is thrown if the `auth` property is present but cannot be decoded.

`url.parse()` uses a lenient, non-standard algorithm for parsing URL
strings. It is prone to security issues such as [host name spoofing][]
and incorrect handling of usernames and passwords. Do not use with untrusted
input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
[WHATWG URL][] API instead.

#### <DataTag tag="M" /> `url.resolve(from, to)`

<Metadata data={{"changes":[{"version":["v15.13.0","v14.17.0"],"pr-url":"https://github.com/nodejs/node/pull/37784","description":"Deprecation revoked. Status changed to \"Legacy\"."},{"version":"v11.0.0","pr-url":"https://github.com/nodejs/node/pull/22715","description":"The Legacy URL API is deprecated. Use the WHATWG URL API."},{"version":"v6.6.0","pr-url":"https://github.com/nodejs/node/pull/8215","description":"The `auth` fields are now kept intact when `from` and `to` refer to the same host."},{"version":["v6.5.0","v4.6.2"],"pr-url":"https://github.com/nodejs/node/pull/8214","description":"The `port` field is copied correctly now."},{"version":"v6.0.0","pr-url":"https://github.com/nodejs/node/pull/1480","description":"The `auth` fields is cleared now the `to` parameter contains a hostname."}],"update":{"type":"added","version":["v0.1.25"]}}} />

<Stability stability={3}>

Legacy: Use the WHATWG URL API instead.

</Stability>

* `from` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The base URL to use if `to` is a relative URL.
* `to` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The target URL to resolve.

The `url.resolve()` method resolves a target URL relative to a base URL in a
manner similar to that of a web browser resolving an anchor tag.

```js
const url = require('node:url');
url.resolve('/one/two/three', 'four');         // '/one/two/four'
url.resolve('http://example.com/', '/one');    // 'http://example.com/one'
url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
```

To achieve the same result using the WHATWG URL API:

```js
function resolve(from, to) {
  const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
  if (resolvedUrl.protocol === 'resolve:') {
    // `from` is a relative URL.
    const { pathname, search, hash } = resolvedUrl;
    return pathname + search + hash;
  }
  return resolvedUrl.toString();
}

resolve('/one/two/three', 'four');         // '/one/two/four'
resolve('http://example.com/', '/one');    // 'http://example.com/one'
resolve('http://example.com/one', '/two'); // 'http://example.com/two'
```

<a id="whatwg-percent-encoding"></a>

### Percent-encoding in URLs

URLs are permitted to only contain a certain range of characters. Any character
falling outside of that range must be encoded. How such characters are encoded,
and which characters to encode depends entirely on where the character is
located within the structure of the URL.

#### Legacy API

Within the Legacy API, spaces (`' '`) and the following characters will be
automatically escaped in the properties of URL objects:

```text
< > " ` \r \n \t { } | \ ^ '
```

For example, the ASCII space character (`' '`) is encoded as `%20`. The ASCII
forward slash (`/`) character is encoded as `%3C`.

#### WHATWG API

The [WHATWG URL Standard][] uses a more selective and fine grained approach to
selecting encoded characters than that used by the Legacy API.

The WHATWG algorithm defines four "percent-encode sets" that describe ranges
of characters that must be percent-encoded:

* The _C0 control percent-encode set_ includes code points in range U+0000 to
  U+001F (inclusive) and all code points greater than U+007E.

* The _fragment percent-encode set_ includes the _C0 control percent-encode set_
  and code points U+0020, U+0022, U+003C, U+003E, and U+0060.

* The _path percent-encode set_ includes the _C0 control percent-encode set_
  and code points U+0020, U+0022, U+0023, U+003C, U+003E, U+003F, U+0060,
  U+007B, and U+007D.

* The _userinfo encode set_ includes the _path percent-encode set_ and code
  points U+002F, U+003A, U+003B, U+003D, U+0040, U+005B, U+005C, U+005D,
  U+005E, and U+007C.

The _userinfo percent-encode set_ is used exclusively for username and
passwords encoded within the URL. The _path percent-encode set_ is used for the
path of most URLs. The _fragment percent-encode set_ is used for URL fragments.
The _C0 control percent-encode set_ is used for host and path under certain
specific conditions, in addition to all other cases.

When non-ASCII characters appear within a host name, the host name is encoded
using the [Punycode][] algorithm. Note, however, that a host name _may_ contain
_both_ Punycode encoded and percent-encoded characters:

```js
const myURL = new URL('https://%CF%80.example.com/foo');
console.log(myURL.href);
// Prints https://xn--1xa.example.com/foo
console.log(myURL.origin);
// Prints https://xn--1xa.example.com
```

[ICU]: /api/v18/intl#options-for-building-nodejs
[Punycode]: https://tools.ietf.org/html/rfc5891#section-4.4
[WHATWG URL]: #the-whatwg-url-api
[WHATWG URL Standard]: https://url.spec.whatwg.org/
[`Error`]: /api/v18/errors#class-error
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
[`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
[`TypeError`]: /api/v18/errors#class-typeerror
[`URLSearchParams`]: #class-urlsearchparams
[`array.toString()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
[`http.request()`]: /api/v18/http#httprequestoptions-callback
[`https.request()`]: /api/v18/https#httpsrequestoptions-callback
[`new URL()`]: #new-urlinput-base
[`querystring`]: /api/v18/querystring
[`url.domainToASCII()`]: #urldomaintoasciidomain
[`url.domainToUnicode()`]: #urldomaintounicodedomain
[`url.format()`]: #urlformaturlobject
[`url.href`]: #urlhref
[`url.parse()`]: #urlparseurlstring-parsequerystring-slashesdenotehost
[`url.search`]: #urlsearch
[`url.toJSON()`]: #urltojson
[`url.toString()`]: #urltostring
[`urlSearchParams.entries()`]: #urlsearchparamsentries
[`urlSearchParams@@iterator()`]: #urlsearchparamssymboliterator
[converted to a string]: https://tc39.es/ecma262/#sec-tostring
[examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing
[host name spoofing]: https://hackerone.com/reports/678487
[legacy `urlObject`]: #legacy-urlobject
[percent-encoded]: #percent-encoding-in-urls
[stable sorting algorithm]: https://en.wikipedia.org/wiki/Sorting_algorithm#Stability

gha_language: TypeScript

gha_license_id: MIT


text:
Infopolisi-theme
==============

This is the InfoPolisi theme for Alaveteli. The intention is to
support simple overlaying of templates and resources without the
need to touch the core Alaveteli software.

This theme contains:

 * CSS-based customisations in lib/views/general/custom_css.rhtml

 * Custom versions of non-functional pages (like "about
   us", at lib/views/help/about.rhtml -- and/or localised versions at
   lib/views/help/about.es.rhtml)

Look in the lib/ folder of the plugin to see how the overrides happen.

To install:
-----------

  ./script/plugin install git://github.com/kulikabel/infopolisi.git

A symbolic link will be created automatically in the `public/` folder
of the main app, pointing to the `public/` folder of the theme, in
order to serve static assets.

To uninstall:
-------------

  ./script/plugin remove git://github.com/kulikabel/infopolisi.git

The symbolic link created during the installation will be removed
automatically.

repository: kulikabel/infopolisi

repo_name: kulikabel/infopolisi


text:
# Azure Lab and Public Datasets

### This is a summary of the datasets used in Azure Machine Learning Foundation Course, order by course session with duplicates.  Some are direct download links, some are the source link of the original data. Feel free to use it for further exploration!

### Lab 2.23 Train a Linear Regression Model (Azure Open Dataset):

#### Summary:
In this lab, we will be using a subset of NYC Taxi & Limousine Commission - green taxi trip records available from Azure Open Datasets. The data is enriched with holiday and weather data. Based on the enriched dataset, we will learn to use the Azure Machine Learning Graphical Interface to process data, build, train, score, and evaluate a regression model to predict NYC taxi fares.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/nyc-taxi/nyc-taxi-sample-data.csv

### Lab 3.4 Import, Transform, and Export Data:

#### Summary:
The following exercise focuses on the Import Data module to load data into a machine learning pipeline from several datasets that will be merged and restructured. We will be using some sample data from the UCI dataset repository to demonstrate how you can perform basic data import transformation steps with the modules available in Azure Machine Learning designer.

**Download datasets:**

https://introtomlsampledata.blob.core.windows.net/data/crime-data/crime-dirty.csv

https://introtomlsampledata.blob.core.windows.net/data/crime-data/crime-spring.csv

https://introtomlsampledata.blob.core.windows.net/data/crime-data/crime-winter.csv

### Lab 3.9 Create and Version a Dataset:

#### Summary:
In this lab, we are using a subset of NYC Taxi & Limousine Commission - green taxi trip records available from Azure Open Datasets to show how you can register and version a Dataset using the AML designer interface. In the first exercises we use a modified version of the original CSV file, which includes collected records for five months (January till May). The second exercise demonstrates how we can create a new version of the initial dataset when new data is collected (in this case, we included records collected in June in the CSV file).

**Download datasets:**

https://introtomlsampledata.blob.core.windows.net/data/nyc-taxi/nyc-taxi-sample-data-5months.csv

https://introtomlsampledata.blob.core.windows.net/data/nyc-taxi/nyc-taxi-sample-data-6months.csv

### Lab 3.15 Engineer and Select Features (Azure sample dataset):

#### Summary:
This lab demonstrates the feature engineering process for building a regression model using bike rental demand prediction as an example. In machine learning predictions, effective feature engineering will lead to a more accurate model. We will use the Bike Rental UCI dataset as the input raw data for this experiment. This dataset is based on real data from the Capital Bikeshare company, which operates a bike rental network in Washington DC in the United States. The dataset contains 17,379 rows and 17 columns, each row representing the number of bike rentals within a specific hour of a day in the years 2011 or 2012. Weather conditions (such as temperature, humidity, and wind speed) were included in this raw feature set, and the dates were categorized as holiday vs. weekday etc.

The field to predict is cnt which contains a count value ranging from 1 to 977, representing the number of bike rentals within a specific hour. Our main goal is to construct effective features in the training data, so we build two models using the same algorithm, but with two different datasets. Using the Split Data module in the visual designer, we split the input data in such a way that the training data contains records for the year 2011, and the testing data, records for 2012. Both datasets have the same raw data at the origin, but we added different additional features to each training set:

* Set A = weather + holiday + weekday + weekend features for the predicted day
* Set B = number of bikes that were rented in each of the previous 12 hours

We are building two training datasets by combining the feature set as follows:
* Training set 1: feature set A only
* Training set 2: feature sets A+B

For the model, we are using regression because the number of rentals (the label column) contains continuous real numbers. As the algorithm for the experiment, we will be using the Boosted Decision Tree Regression.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/bike-rental/bike-rental-hour.csv

### Python code used in lab 3.15:

```python
# The script MUST contain a function named azureml_main
# which is the entry point for this module.

# imports up here can be used to
import pandas as pd
import numpy as np

# The entry point function can contain up to two input arguments:
#   Param<dataframe1>: a pandas.DataFrame
#   Param<dataframe2>: a pandas.DataFrame
def azureml_main(dataframe1 = None, dataframe2 = None):

    # Execution logic goes here
    print(f'Input pandas.DataFrame #1: {dataframe1}')

    # If a zip file is connected to the third input port,
    # it is unzipped under "./Script Bundle". This directory is added
    # to sys.path. Therefore, if your zip file contains a Python file
    # mymodule.py you can import it using:
    # import mymodule

    for i in np.arange(1, 13):
        prev_col_name = 'cnt' if i == 1 else 'Rentals in hour -{}'.format(i-1)
        new_col_name = 'Rentals in hour -{}'.format(i)

        dataframe1[new_col_name] = dataframe1[prev_col_name].shift(1).fillna(0)

    # Return value must be of a sequence of pandas.DataFrame
    # E.g.
    #   -  Single return value: return dataframe1,
    #   -  Two return values: return dataframe1, dataframe2
    return dataframe1,
```

### Lab 3.27 Train and Evaluate a Model (Azure sample dataset):

#### Summary:
In this lab, we will be using the Flight Delays data set that is enhanced with the weather data. Based on the enriched dataset, we will learn to use the Azure Machine Learning Graphical Interface to process data, build, train, score, and evaluate a classification model to predict if a particular flight will be delayed by 15 minutes or more.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/flightdelays/flightdelays.csv

### Lab 3.31 Train a Two-Class Boosted Decision Tree:

#### Summary:
In this lab, we will be using the Flight Delays data set that is enhanced with the weather data. Based on the enriched dataset, we will learn to use the Azure Machine Learning Graphical Interface to process data, build, train, score, and evaluate a classification model to predict if a particular flight will be delayed by 15 minutes or more. The classification algorithm used in this lab will be the ensemble algorithm: Two-Class Boosted Decision Tree.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/flightdelays/flightdelays.csv

### Lab 3.34 Train a Simple Classifier with Automated ML:

#### Summary:
In this lab, you learn how to create, run, and explore automated machine learning experiments in the Azure Machine Learning Studio without a single line of code. As part of this lab, we will be using the Flight Delays data set that is enhanced with the weather data. Based on the enriched dataset, we will use automated machine learning to find the best performing classification model to predict if a particular flight will be delayed by 15 minutes or more.

**Download dataset:**
 https://introtomlsampledata.blob.core.windows.net/data/flightdelays/flightdelays.csv

### Lab 4.4 Two-Class Classifiers Performance

#### Summary:
In this lab, we will be compare the performance of two binary classifiers: Two-Class Boosted Decision Tree and Two-Class Logistic Regression for predicting customer churn. The goal is to run an expensive marketing campaign for high risk customers; thus, the precision metric is going to be key in evaluating performance of these two algorithms.

**Find dataset:**

CRM dataset shared: https://docs.microsoft.com/en-us/azure/machine-learning/studio/use-sample-datasets

### Lab 4.8 Multi-Class Classifiers Performance:

#### Summary:
In this lab, we will be compare the performance of two different multiclass classification approaches: Two-Class Support Vector Machine used with One-vs-All Multiclass module vs Multiclass Decision Forest. We will apply the two approaches for the letter recognition problem and compare their performance.

**Download dataset:**
https://www.kaggle.com/nishan192/letterrecognition-using-svm

### Lab 4.11 Training a Classifier Using Automated Machine Learning (Azure sample dataset):

#### Summary:
In this lab, we will use Automated Machine Learning to find the best performing binary classification model for predicting customer churn. We will do all of this from the Azure Machine Learning Studio without writing a single line of code.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/crm-churn/crm-churn.csv

### Lab 4.15 Regressors Performance (Azure sample dataset):

#### Summary:
In this lab, we will be compare the performance of two regression algorithms: Boosted Decision Tree Regression and Neural Net Regression for predicting automobile prices.

**Download dataset:**

Automobile price data(raw):

https://www.kaggle.com/toramky/automobile-dataset (.csv)

or

https://archive.ics.uci.edu/ml/datasets/Automobile (.data)

### Lab 4.19 Train a Regressor using Automated Machine Learning:

#### Summary:
In this lab, we will use Automated Machine Learning to find the best performing regression model for predicting automobile prices.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/automobile-price/automobile-price.csv

### Lab 4.25 Train a Simple Clustering Model (Azure sample dataset):

#### Summary:
In this lab, we will be using the Weather Dataset that has weather data for 66 different airports in the USA from April to October 2013. We will cluster the dataset into 5 distinct clusters based on key weather metrics, such as visibility, temperature, dew point, wind speed etc. The goal is to group airports with similar weather conditions. We will do all of this from the Azure Machine Learning designer without writing a single line of code.

**Download dataset:**
https://az754797.vo.msecnd.net/data/WeatherDataset.csv

### Lab 5.7 Train a Simple Neural Net:

#### Summary:
In this lab we will be using a subset of NYC Taxi & Limousine Commission - green taxi trip records available from Azure Open Datasets. The data is enriched with holiday and weather data. Based on the enriched dataset, we will configure the prebuilt Neural Network Regression module to create a regression model using a customizable neural network algorithm. We will train the model by providing the model and the NYC taxi dataset as an input to Train Model. The trained model can then be used to predict NYC taxi fares.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/nyc-taxi/nyc-taxi-sample-data.csv

### Lab 5.12 Train a Simple Recommender (Azure sample dataset):

#### Summary:
In this lab, we make use of the Train SVD Recommender module available in Azure Machine Learning designer (preview), to train a movie recommender engine. We use the collaborative filtering approach: the model learns from a collection of ratings made by users on a subset of a catalog of movies. Two open datasets available in Azure Machine Learning designer are used the IMDB Movie Titles dataset joined on the movie identifier with the Movie Ratings dataset. The Movie Ratings data consists of approximately 225,000 ratings for 15,742 movies by 26,770 users, extracted from Twitter using techniques described in the original paper by Dooms, De Pessemier and Martens. The paper and data can be found on GitHub.

We will both train the engine and score new data, to demonstrate the different modes in which a recommender can be used and evaluated. The trained model will predict what rating a user will give to unseen movies, so we’ll be able to recommend movies that the user is most likely to enjoy.

**Find dataset:**
https://github.com/sidooms/MovieTweetings

### Lab 5.16 Train a Simple Text Classifier (Azure sample dataset):

#### Summary:
In this lab we demonstrate how to use text analytics modules available in Azure Machine Learning designer (preview) to build a simple text classification pipeline. We will create a training pipeline and initialize a multiclass logistic regression classifier to predict the company category with Wikipedia SP 500 dataset derived from Wikipedia. The dataset manages articles of each S&P 500 company. Before uploading to Azure Machine Learning designer, the dataset was processed as follows: extracted text content for each specific company, removed wiki formatting, removed non-alphanumeric characters, converted all text to lowercase, known company categories added. Articles could not be found for some companies, so that’s why the number of records is less than 500.

Data is derived from Wikipedia (https://www.wikipedia.org/) based on articles of each S&P 500 company, stored as XML data.

Before uploading to Azure Machine Learning Studio (classic), the dataset was processed as follows:
* 		Extract text content for each specific company
* 		Remove wiki formatting
* 		Remove non-alphanumeric characters
* 		Convert all text to lowercase
* 		Known company categories were added

Note that for some companies an article could not be found, so the number of records is less than 500.

**Find dataset:**
https://github.com/datasets/s-and-p-500-companies-financials
(WARNING: THIS MAY NOT BE THE ORIGINAL DATA USED IN AZURE LAB)

### Lab 5.23 Forecasting (Azure sample dataset):

#### Summary:
In this lab you will learn how the Automated Machine Learning capability in Azure Machine Learning (AML) can be used for the life cycle management of the manufactured vehicles and how AML helps in creation of better vehicle maintenance plans. To accomplish this, you will train a Linear Regression model to predict the number of days until battery failure using Automated Machine Learning available in AML studio.

**Download dataset:**
https://introtomlsampledata.blob.core.windows.net/data/battery-lifetime/training-formatted.csv

## Open Dataset Resources

### Azure sample datasets:
https://docs.microsoft.com/en-us/azure/machine-learning/studio/use-sample-datasets

### Azure open dataset:
https://azure.microsoft.com/en-us/services/open-datasets/catalog/

### UCI Machine Learning Repository:
https://archive.ics.uci.edu/ml/datasets.php

### 25 Excellent Machine Learning Open Datasets
https://medium.com/@ODSC/25-excellent-machine-learning-open-datasets-940ca2124dfc

gha_language: Jupyter Notebook


text:
# AWS Workshop - Dynamic Blog

## Setup Contentful

Refer to following guide to [setup content on contentful](CONTENTFUL_SETUP.md)

## Start Dev Server

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Build Production Site

```bash
npm run build
# or
yarn build
```

## Start Production Server

```bash
npm run start
# or
yarn start
```


text:
scos
===
This is a simple operating system, which I wrote from scratch in my high school in order to learn how an OS runs on a machine. It is partly a mimic of Linux 0.11. It contains a bootloader, a kernel, a shell and some tools that can run on it for demonstration.

* It runs in x86 protected mode(32-bit), the kernal runs in ring 0, and other programs runs in ring 3.
* It partially supports memory paging, with page mapping from vitual address space to physical address space and allocating physical pages on demand.
* It (only) supports floppy disk controller and FAT-12 system. (the whole OS is installed in a 1.44 MB floppy disk)
* It supports DMA to read/write the disk.
* It supports preemptive multi-tasking, and each process(no thread) has 64MB memory (all process sharing the same system page table) and equal CPU time slice (a simple implementation).
* It cantains a system API on which the shell and other tools base. It is called through software interruption.

build
---
The `Makefile` was originally wrote for `djgpp` on Windows, and I adapt it to OS X. There are still some problems now:
* `ld` from `djgpp`(GNU) and from `xcode` are quite different. Our binaries need the `text section` being put at the begining of the file and specified address origins, but Apple's `ld` does not support `link script` and raw binary format, it always puts a head before anything else in the file.
* After El Capitan, `Disk Utility` seems not to support loading empty image file any more (file created by `dd bs=1024 count=1440 if=/dev/zero of=disk.img`) and images created by `hdiutil` always contains an extra sector at the begining of the disk (the boot sector is moved to the second sector). So I cannot find a way to create a standard FAT-12 disk image right now. For now, you could use any 1.44MB FAT-12 floppy disk image you have or found on the Internet, backup and format them.

To build is quite simple:

make sure that you have `nasm` installed
```
# use GNU-toolset
make
# use OSX toolset
make OSX_TOOLSET=1
```
There are 5 binary files built, `boot.bin`, `kernel.bin`, `shell.bin`, `edit.bin`, `demo.bin`.
1. Mount the disk image on your system
2. Use the `boot.bin` to replace the boot sector of the disk.
```
# replace '/dev/fda1' with the filename of your mounted image
dd bs=512 count=1 if=boot.bin of=/dev/fda1
```
3. Put other binaries files into the disk directly through `File Explorer` or `Finder`.

Caution: if you use the OSX toolset, please remember to cut off the head part from the files:
```
# our code and other sections start after 8192 bytes from the begining of the file
dd bs=8192 skip=1 if=old.bin of=new.bin
```

repository: shenchi/scos

repo_name: shenchi/scos


text:
# Concurrency

## 1. Use Promises, not callbacks

Callbacks aren't clean, and they cause excessive amounts of nesting.  Use them!

```javascript
// Bad!
import { get } from "request";
import { writeFile } from "fs";

get(
  "https://en.wikipedia.org/wiki/Robert_Cecil_Martin",
  (requestErr, response, body) => {
    if (requestErr) {
      console.error(requestErr);
    } else {
      writeFile("article.html", body, writeErr => {
        if (writeErr) {
          console.error(writeErr);
        } else {
          console.log("File written");
        }
      });
    }
  }
);
```

```javascript
// Good!
import { get } from "request-promise";
import { writeFile } from "fs-extra";

get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
  .then(body => {
    return writeFile("article.html", body);
  })
  .then(() => {
    console.log("File written");
  })
  .catch(err => {
    console.error(err);
  });
```

## 2. Async/Await are even cleaner than Promises

Promises are a very clean alternative to callbacks, but ES2017/ES8 brings async and await which offer an even cleaner solution. All you need is a function that is prefixed in an async keyword, and then you can write your logic imperatively without a then chain of functions. Use this if you can take advantage of ES2017/ES8 features today!

```javascript
// Okay!
import { get } from "request-promise";
import { writeFile } from "fs-extra";

get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
  .then(body => {
    return writeFile("article.html", body);
  })
  .then(() => {
    console.log("File written");
  })
  .catch(err => {
    console.error(err);
  });
```

```javascript
// Good!
import { get } from "request-promise";
import { writeFile } from "fs-extra";

async function getCleanCodeArticle() {
  try {
    const body = await get(
      "https://en.wikipedia.org/wiki/Robert_Cecil_Martin"
    );
    await writeFile("article.html", body);
    console.log("File written");
  } catch (err) {
    console.error(err);
  }
}

getCleanCodeArticle()
```

## 3. Callbacks versus Promises versus Async/await

**Callbacks = Inversion of Control**

The function you pass a callback to is entirely in control of when your callback is invoked, how it is invoked, and what data is passed along with that invocation. This is why sometimes callbacks are spoken about as an inversion of control.

**Callbacks = Horizontal pyramids**

Callback hell is the name given to the undesirable proliferation of multiple nested callbacks within a piece of code, usually done to carry out a series of asynchronous tasks that each rely on another previous asynchronous task.

```javascript
async(task, () => {
  async(task, () => {
    async(task, () => {
      async(task, () => {
        async(task, () => {
          async(task, () => {
            // Something
          })
        })
      })
    })
  })
})
```

**Solving the horizontal pyramid**

- Choose an event emitter system (OR)
- Choose a promise (OR)
- Choose async/await


text:
# Tic-tac-toe

A Tic-tac-toe game that never loses. See it in action [here](http://tic-tac-toe-mchliakh.herokuapp.com/).

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'tic_tac_toe_mchliakh'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install tic_tac_toe_mchliakh

## Usage

```ruby
class GamesController < ApplicationController
  def new
    render json: Game.create.id
  end

  def move
    game = Game.find(params[:id])

    result = TicTacToe.move(params[:square], game.board)

    if result[:board]
      game.update_attributes(board: result[:board])
    end

    render json: result
  end
end
```

1. Fork it ( https://github.com/[my-github-username]/tic_tac_toe_mchliakh/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: mchliakh/tic-tac-toe

repo_name: mchliakh/tic-tac-toe


text:
# BitDo2

[![Build Status](https://travis-ci.org/zix99/bitdo2.svg?branch=master)](https://travis-ci.org/zix99/bitdo2)
[![npm](https://img.shields.io/npm/v/bitdo2.svg)](https://www.npmjs.com/package/bitdo2)
[![npm](https://img.shields.io/npm/l/bitdo2.svg)](https://www.npmjs.com/package/bitdo2)

> NOTE: BitDo2 is still under development, and can't execute rules quite yet.  It can display and track your holding history to a local database.  Please wait a little bit longer until it can execute rules.

A cryptocurrency automated trader (not an intelligent trader!) and set of utilities.

The intention of this is to provide a configurable platform for performing
automated trades at preset points.

## Installing

Make sure to use at least node 6.x. You can always find the version of node I'm using in the [.nvmrc](.nvmrc) file.

If you get an error about installing/loading the exchanges or plugins, make sure you're running an up-to-date version of `npm`. You
can update npm by running `npm update -g npm`.

```bash
npm install -g bitdo2
```

## Configuration

You will need a file `bitdo.conf` that contains your exchange configuration.

## Using as a Library

By default, you can use bitdo2 as a library in your own applications.  It exports the common exchange abstraction,
so you can operate on various exchanges without having to worry about their specific APIs.

eg.
```js
const bitdo2 = require('bitdo2');
bitdo2.createExchange('gdax', {... config ...});

OR

bitdo2.createFromConfig({
  gdax: {
    ...
  },
  bittrex: {
    ...
  }
});
```

## UI

Run: `bitdo-ui`

Make sure you have configuration in the current directory.

You will be presented with a UI showing your current holdings and orders.

## Watch

Run: `bitdo-watch --help`

Watches prices or orders for completion or failure cases. Meant to be chained with something else, eg:

```bash
# Watch an order and alert
bitdo-watch -p gdax:BTC-USD --crosses 20000 --timeout 1d && notify-send "Bitcoin crossed 20000!" || notify-send "Bitcoin didnt cross after a day"

# Trigger an order when a price dips below a value
bitdo-watch -p gdax:BTC-USD --below 18000 --timeout 1d && bitdo-order buy -p gdax:BTC-USD --price 18000 --amount 0.1 || echo "Order timed out"

# And can even be chained for more complex scenarios (Crosses below, then back up)
bitdo-watch -p gdax:BTC-USD --below 18000 && bitdo-watch -p gdax:BTC-USD --above 18500 || bitdo-order ...
```

## Order

Run: `bitdo-order --help`

This allows you to execute buy/sell/trail orders via command line on any configured exchanges.

**DO SO AT YOUR OWN RISK!**

## Recorder

Run: `bitdo-recorder`

This will (by default) poll your holdings in exchanges and write them to a sqlite DB so you can track them over time.

Uses *Sequelize* to write to DB, so can use any database it supports (mysql, postgres, etc)

# Plugins

There are two abstracted parts of bitdo2 that support plugins: *exchanges* and *plugins*

## Exchanges

Although bitdo2 comes with a set of exchanges builtin (though internally, they're just plugins), you
can extend this by creating a global package (or installing a global package) with the name `bitdo-exchange-XXX`,
where `XXX` is the name of your exchange.

When loading, bitdo will search for a local exchange first, and if one is not found, will check the global
packages.

If you want to implement a new exchange, look at the [plugin constract](exchanges/index.js) for required
methods and contracts.

## Plugins

Some pieces of bitdo use plugins to extend the application without needing to pull the dependencies into
the main app.

Similar to the exchange, these plugins will first be loaded internally, and then searched for in the global
node modules with the pattern `bitdo-plugin-XXX`.

To develop a plugin look at [plugin contract](plugins/index.js)

# License

Copyright (c) 2017 Christopher LaPointe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

 IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.