text:
---
layout: post
title: "Damn I Love Docker: Local DNS With CoreDNS"
date: 2020-01-03
category: [docker, containers, devops, DNS]
---
###  Table of Contents
* [Synopsis](#synop)
* [Introduction](#intro)
* [Getting Started](#setup)
  * [CoreDNS Config](#config)
  * [DNS Zone File](#zonefile)
  * [Docker Deploy](#deploy)
* [Using Your Local Name Server](#usage)
  * [Testing](#test)
  * [macOS DNS Resolver](#mac)
* [References](#references)

##  [Synopsis](#toc)
Here we are going to discuss how you can setup a local DNS[^fn1][^fn2] server
using docker[^fn3][^fn4] and CoreDNS.[^fn5][^fn6]

##  [Introduction](#toc)
If you are not already familiar with how DNS[^fn1][^fn2] works, then basically
it is an address book. In this address book are stored the IP addresses[^fn7] and
their corresponding `Domain Names` (i.e. google.com, youtube.com, amazon.com,
etc...). When you type `google.com` in your browser, your browser will first
attempt to resolve this `Domain Name` by querying whatever `Name Servers` your
computer has set in its local configuration (Note: this is most often set
automatically by the router on the wired/wireless network when you first join).

The result of this query is the `resolution` of the `Domain Name` to its
corresponding address (e.g. while google.com has multiple IP addresses, one of
the returned addresses is `<IP_ADDRESS>`). This can be seen below in the
following example using the well known tool `dig`:[^fn8][^fn9]
```
$ dig google.com

; <<>> DiG 9.10.6 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10808
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             76      IN      A       <IP_ADDRESS>
google.com.             76      IN      A       <IP_ADDRESS>
google.com.             76      IN      A       <IP_ADDRESS>
google.com.             76      IN      A       <IP_ADDRESS>
google.com.             76      IN      A       <IP_ADDRESS>
google.com.             76      IN      A       <IP_ADDRESS>

;; Query time: 7 msec
;; SERVER: <IP_ADDRESS>#53(<IP_ADDRESS>)
;; WHEN: Fri Jan 03 10:09:45 EST 2020
;; MSG SIZE  rcvd: 135

```
We can see from the above example that there are several `IP addresses`
associated for `google.com` (including the `<IP_ADDRESS>` address we noted
earlier). Now your browser can actually send the desired `HTTP request`[^fn10]
to Google's servers at `<IP_ADDRESS>`, which will in turn respond with the
desired `HTML/CSS/Javascript` that comprise its search engine interface. All
`DNS` really did is allow you to **"lookup"** the address for Google's server.
In a very simplified way, this is how `DNS` works.

But this example only applies to externally located hosts (e.g. the servers
running websites like `google.com`, `youtube.com`, and `amazon.com`). What if
you wanted to create `Domain Names` and the corresponding `DNS Records` for your
local hosts/services running on your local network? This is where you would
want to have a locally running `DNS server`, with entries composed of `Domain
Names` pointing to `local IP addresses`on your *local* network.

##  [Getting Started](#toc)
###  [CoreDNS Config](#toc)
To start with we need to create the config file for CoreDNS. This file is
called a `Corefile` and an example can be seen below
```
$ mkdir -p local-dns/root
$ cd local-dns
$ cat <<EOF > root/Corefile
.:53 {
    forward . <IP_ADDRESS> <IP_ADDRESS>
    log
    errors
}

example.com:53 {
    file /root/db.example
    log
    errors
}
EOF
```
First we start by using `mkdir` to create the directories to store our config
files. Then we use the `cat` command and a `heredoc` to write to the `Corefile`.
The first section of this Corefile (i.e. the `.:53`) corresponds to all DNS
queries that do no match any of the other domains listed in the config file
(in this instance we mean the `example.com` domain listed underneath). What
we are saying with this first section is *"any query that does not directly
match any other domains listed in this Corefile, forward that query to the
name servers at <IP_ADDRESS> and <IP_ADDRESS>"*. These are Google's DNS servers (<IP_ADDRESS>
and <IP_ADDRESS> respectively). This works out well because not all of our DNS
queries are going to correspond to local domains, we still need to send out
queries for external domains out on then WAN[^fn11] (i.e. internet).

If you have not already guessed, the last section specifically matches any
DNS queries for the domain `example.com`. Here you are telling the CoreDNS
server to specifically reference the `file` located at `/root/db.example` for
every DNS query that specifies `example.com`. The domain name here can be
whatever you want and as many as you want, but you would need a separate `db.*`
file for each domain you are referencing in this `Corefile`:
```
foobarbaz.org:53 {
    file /root/db.foobarbaz
    log
    errors
}

helloworld.com:53 {
    file /root/db.helloworld
    log
    errors
}
```
In the above example we created rules to add to the `Corefile` for the domains
`foobarbaz.org` and `helloworld.com`. Notice we have uniquely named `db.*` files
for `foobarbaz.db` and `helloworld.db` respectively.

###  [DNS Zone File](#toc)
Back to our original example, let us now dive into the `db.example`[^fn12] file we
referenced in the `Corefile` above, and look at how it can be setup to work:
```
$ cat <<EOF > root/db.example
$ORIGIN example.com.  ; designates the start of this zone file in the namespace
$TTL 1h               ; default expiration time of all resource records without their own TTL value
@                 IN  SOA     ns.example.com. rtiger.example.com. (
<PHONE_NUMBER>     ; Serial
                                  1d             ; Refresh
                                  2h             ; Retry
                                  4w             ; Expire
                                  1h)            ; Minimum TTL
@                 IN  A       <IP_ADDRESS>       ; Local IPv4 address for example.com.
@                 IN  NS      ns.example.com.    ; Name server for example.com.
ns                IN  CNAME   @                  ; Alias for name server (points to example.com.)
webblog           IN  CNAME   @                  ; Alias for webblog.example.com
netprint          IN  CNAME   @                  ; Alias for netprint.example.com
```
We will leave an extensive explanation of the `zone file` for further
reference,[^fn12] and will instead attempt a brief explanation of the above
values.

As you can see at the top of the file is the `$ORIGIN` keyword, which merely
sets the global `ORIGIN` domain name (i.e. in this case `example.com`). The
`$ORIGIN` value can then be referenced using the `@` symbol throughout the
zone file. You can see the use of the `@` symbol to replace the `example.com`
domain name through various records. Again, please refer to the zone file
reference[^fn12] for information on the `$TTL` value.

Next we see several *resource records* (also shortened to `RR`) starting
directly below the `$TTL` value:
```
$ORIGIN example.com.  ; designates the start of this zone file in the namespace
$TTL 1h               ; default expiration time of all resource records without their own TTL value

; =============================== Resource Records ==============================

@                 IN  SOA     ns.example.com. rtiger.example.com. (
<PHONE_NUMBER>     ; Serial
                                  1d             ; Refresh
                                  2h             ; Retry
                                  4w             ; Expire
                                  1h)            ; Minimum TTL
@                 IN  A       <IP_ADDRESS>       ; Local IPv4 address for example.com.
@                 IN  NS      ns.example.com.    ; Name server for example.com.
ns                IN  CNAME   @                  ; Alias for ns.example.com
webblog           IN  CNAME   @                  ; Alias for webblog.example.com
netprint          IN  CNAME   @                  ; Alias for netprint.example.com
```
More information on the `resource records` can be found in the references[^fn13]
located in the reference section. What is important to understand here is that
we have an `address record` with the label `A` that connects the domain name
`example.com` to the IP address `<IP_ADDRESS>`. This is the actual address for
`example.com`. The other resource records for `CNAME` are what are known as
`canonical name` records. Here we use some shorthand to alias the domain `ns`,
`weblog`, and `netprint` (which correspond to `ns.example.com`,
`webblog.example.com`, `netprint.example.com` respectively) to `example.com`
(again we used the `@` symbol here as a reference). This is simply because all
of the subdomain names are all pointing to the same IP address as `example.com`
so we can simply point them to the `example.com` domain. This makes management
much easier, because should we need to change the IP address associated with
`example.com`, we will not have excessive multiple entries to change.

Finally we have the `NS` and `SOA` resource records. The `NS` records simply
stand for `name server` and allow us to declare a name server (in this case
we use the `ns.example.com` domain which is actually an alias or `CNAME` for
`example.com`). The `SOA` record is the only record specifically required by
the zone file and is short for `Start of Authority`. This DNS record has a few
different features compared to previously described `A`, `CNAME`, and `NS`
records. It requires a name server address (in this case the `ns.example.com`
domain name) that hosts the `A` record for the `$ORIGIN` domain (in this case
`example.com`). In this specific example the name server is the same as the
server hosting this `zone file`, that is why the name server is this example
is merely an alias to `example.com`. It also requires an administrator contact
(in this case the `rtiger.example.com`) and various time-related data (seen
above with comments to the right). Please see the references on the resource
records[^fn13] and zone file[^fn12] for more info.

###  [Docker Deploy](#toc)
Finally we are ready to deploy our local DNS server. We can deploy it simply as
shown below:
```
$ docker run -d \
             --name coredns \
             -v ~/local-dns/root/:/root \
             -p 53:53/udp \
             coredns/coredns -conf /root/Corefile
```
To clarify, we are mounting the directories we created earlier
`~/local-dns/root` for CoreDNS to find the config files, so be aware that if
your path is different you will need to change this value to the location of
your Corefile/db.* files. Now we need to test it to make sure it is working

##  [Using Local DNS Server](#toc)
###  [Testing](#toc)
To begin using our server, we need to first test whether our DNS request will
work. This will involve our good friend, once again, `dig`.[^fn8][^fn9] Let us
start by querying the server using its local IP address and the `example.com`
domain:
```
$ dig @<IP_ADDRESS> example.com

; <<>> DiG 9.10.6 <<>> @<IP_ADDRESS> example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50252
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            3600    IN      A       <IP_ADDRESS>

;; AUTHORITY SECTION:
example.com.            3600    IN      NS      ns.example.com.

;; Query time: 41 msec
;; SERVER: <IP_ADDRESS>#53(<IP_ADDRESS>)
;; WHEN: Sun Jan 05 18:52:10 EST 2020
;; MSG SIZE  rcvd: 106
```
We can see in the `ANSWER SECTION` of the `dig` report that the `A` record for
`example.com` points to `<IP_ADDRESS>` just like we defined in the `zone file`.
We can also see that the `AUTHORITY SECTION` reports an `NS` record with
`ns.example.com` as the name server, just like we defined in the `zone file`.
 Our local DNS
server is working!!!

###  [macOS DNS Resolver](#toc)
In this section we actually cover how to setup your `macOS` computer to
use the *local DNS* server we have just successfully deployed and tested. We
will be using a *macOS-specific* command line tool called `networksetup`. With
this tool we will be setting the `name servers` used for a specific interface
(in this case `Wi-Fi`):
```
$ networksetup -setdnsservers Wi-Fi <IP_ADDRESS>
```
This will immediately point all your DNS traffic to the CoreDNS server we
deployed on host `<IP_ADDRESS>`. To reset the name servers used to the default:
```
$ networksetup -setdnsservers Wi-Fi empty
```
Now we are back the the original DNS servers being used. Confirm this with
the following:
```
$ networksetup -getdnsservers Wi-Fi
There aren't any DNS Servers set on Wi-Fi.
```
The above response is the default response for macOS (i.e. the state before
we changed it to use our local DNS servers). Note: These commands were performed
in `macOS Mojave`.

##  [References](#toc)
[^fn1]: [Domain Name System](https://en.wikipedia.org/wiki/Domain_Name_System)
[^fn2]: [What is DNS](https://www.cloudflare.com/learning/dns/what-is-dns/)
[^fn3]: [Docker Wiki](https://en.wikipedia.org/wiki/Docker_(software))
[^fn4]: [Docker Docs](https://docs.docker.com/engine/docker-overview/)
[^fn5]: [CoreDNS Docs](https://coredns.io/)
[^fn6]: [CoreDNS Github](https://github.com/coredns/coredns)
[^fn7]: [IP Adresses](https://en.wikipedia.org/wiki/IP_address)
[^fn8]: [dig Wiki](https://en.wikipedia.org/wiki/Dig_(command))
[^fn9]: [dig man page](https://linux.die.net/man/1/dig)
[^fn10]: [Hypertext Transfer Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol)
[^fn11]: [WAN](https://en.wikipedia.org/wiki/Wide_area_network)
[^fn12]: [Zone File](https://en.wikipedia.org/wiki/Zone_file)
[^fn13]: [Resource Records](https://en.wikipedia.org/wiki/List_of_DNS_record_types)


text:
# Artificial Intelligence

Artificial Intelligence project based on the paper _PAC Identification of Many Good Arms in Stochastic Multi-Armed Bandits_ by Arghya Roy Chaudhuri and Shivaram Kalyanakrishnan.

![alt text](https://img.shields.io/badge/Language-Italian-infomrmational?style=for-the-badge)

## Authors

### Team

-   **Samuele Ferri**: [Site](https://samuelexferri.com), [GitHub](https://github.com/samuelexferri)

## Version

![alt text](https://img.shields.io/badge/Version-0.0.1-blue.svg?style=for-the-badge)

## License

[![License](https://img.shields.io/badge/License-MIT_License-blue.svg?style=for-the-badge)](https://badges.mit-license.org)

license: MIT

repository: samuelexferri/unibg-ai

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: samuelexferri/unibg-ai


text:
# vscode-extension-mammoth

> Word preview and export extension for vscode.

## Preview

![screenshot](https://gw.alicdn.com/imgextra/i4/O1CN01dSm93Z1jhEIbvtGJO_!!6000000004579-2-tps-2118-1060.png)

## Links

* [mammoth.js](https://github.com/mwilliamson/mammoth.js)
* [js-beautify](https://github.com/beautify-web/js-beautify)

repository: F-loat/vscode-extension-mammoth

branch_name: refs/heads/main

repo_name: F-loat/vscode-extension-mammoth


text:
You will need to modify this a lot for your custom use case, but it can be a good place to get started

To use this package, you must install the C libraries for Phidgets:

http://www.phidgets.com/docs/OS_-_Linux

Then follow the instructions to install the Python Phidgets module:
http://www.phidgets.com/docs/Language_-_Python


text:
# `kubectl unfork`

A kubectl plugin to find forked helm charts running in a cluster, extract [Kustomize](https://kustomize.io) compatible patches, and allow you to delete the fork and return to the upstream Chart, while preserving your patches.

Usage:

```
curl https://unfork.io/install | bash
kubectl unfork
```

This plugin will:
- Connect to your Kubernetes cluster and search for a Helm Tiller pod.
- Connect to your Tiller using the Helm GRPC API and query to receive a list of all installed Helm Charts.
- Meanwhile, Unfork will download a list of all known Helm Charts from [Monocular](https://hub.helm.sh/).
- Comparing your Helm charts with the Monocular index, Unfork will attempt to determine which upstream your fork is from.
- Once you've confirmed the best upstream, Unfork will convert your custom changes into [Kustomize](https://kustomize.io) patches and resources.
- You can now update the Helm chart to the latest version, and re-apply your patches.

Note: Unfork does **not** make any changes to the applications running in your cluster. Unfork only needs access to your cluster in order to port-forward and gain access to Tiller.

repository: pecigonzalo/unfork

repo_name: pecigonzalo/unfork


text:
# DevOps

## Continuous Integration

### [Flakehell](flakeheaven.md)

* Correction: Update the git repository.

    The existent repository has been archived in favor of [this one](https://github.com/flakeheaven/flakeheaven)

# Coding

## Python

### [Boto3](boto3.md)

* New: Introduce the AWS SDK library and explain how to test it.

    [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) is
    the AWS SDK for Python to create, configure, and manage AWS services,
    such as Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Simple Storage
    Service (Amazon S3). The SDK provides an object-oriented API as well as
    low-level access to AWS services.

    For [testing](boto3.md#testing), try to use [moto](boto3.md#moto), using the [Botocore's stubber](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/stubber.html) as fallback option.

### [DeepDiff](deepdiff.md)

* Improvement: Remove advice to use my fork instead.

    The original one has already merged my [PR](https://github.com/seperman/deepdiff/pull/239) `＼\ ٩( ᐛ )و /／`. Beware though as the `regexp` are not enabled by default (against my will). You need to use the `use_regexp=True` as an argument to `grep` or `DeepSearch`.

### [FactoryBoy](factoryboy.md)

* New: [Explain how to use `Enum` with factoryboy.](factoryboy.md#word-from-enum-choices)

### [Python Snippets](python_snippets.md)

* Correction: [Add warning about the method to use direct dependencies.](python_snippets.md#install-a-python-dependency-from-a-git-repository)

    Last time I used this solution, when I added the library on a `setup.py`
    the direct dependencies weren't installed :S

### [Pydantic](pydantic.md)

* New: [Explain how to update entity attributes with a dictionary.](pydantic.md#update-entity-attributes-with-a-dictionary)

    You can create a new object with the new data using the `update`
    argument of the `copy` entity method.

# Arts

## [Writing](writing.md)

* New: [Explain when to use I'm good or I'm well.](writing.md#im-good-or-im-well)

    Use I'm well when referring to being ill, use I'm good for the rest.

# Other

* New: Explain how to select a random choice from `Enum` objects.

    [pydantic](pydantic.md) uses `Enum` objects to define [the choices of
    fields](https://pydantic-docs.helpmanual.io/usage/types/#enums-and-choices), so
    we need them to create the factories of those objects.

repository: lyz-code/blue-book

gha_language: Makefile

repo_name: lyz-code/blue-book


text:
# impala-rpm

Tested on CentOS 7 and Hortonworks 2.4 (Hadoop)

### Install Dependancies :
```
yum install java-1.7.0-openjdk-devel python-setuptools doxygen redhat-lsb gcc-c++ python-devel cyrus-sasl-devel openssl-devel vim-common wget curl rpm-build maven git make
```

### Set JAVA_HOME :
add /etc/profile.d/java.sh
```
export JAVA_HOME=/usr/lib/jvm/java
```

### Clone and Build RPMS
```
git clone https://github.com/hurdad/impala-rpm.git
cd impala-rpm && make
```

### RPMS Location
```
cd rpmbuild/RPMS/x86_64/
```

repository: eubnara/impala-rpm

repo_name: eubnara/impala-rpm


text:
# jack

A command line tool for time-based queries on log files.

## How to install

    pip install jack

To run jack, `cd` to a directory with log files (`.log` or `.log.gz` extension) and run something like this:

    jack 8:15am to 8:20am
    jack 8:15am to 8:20am PDT
    jack 16:30 to 16:45
    jack May 1st 16:30 to May 1st 16:45
    jack 2014-03-01 8:15am to 2014-03-01 8:20am PDT
    jack yesterday to today

## How to create and ship a change

* Mark your change in a branch off `master` and submit a pull-request on GitHub. Ping @dbader to review it.

#### Testing
* Test the package locally and make sure it installs cleanly and works via `pip install -e .` (in the project root).

#### Releasing
* Bump `PACKAGE_VERSION` in `setup.py`
* Create a git tag for the release:
    * `git tag 0.0.1 -m "The best release so far"`
    * `git push --tags origin master`
* `python setup.py sdist upload -r pypi`

## Roadmap

* Turn this into a `pip install`able package
* Add usage / nice errors for the CLI
* Add unit tests
* Set up TravisCI continuous integration

## Changelog

* `0.1.0`: First working PyPI release.

## Glossary
(todo)

## Where to get help
Talk to [@dbader_org](https://twitter.com/dbader_org).

repository: dbader/jack

gha_language: Python

gha_license_id: MIT

repo_name: dbader/jack


text:
# flashcards

:flower_playing_cards: "Flashcards" is the third React project made for the React Udacity Nanodegree program.

![alt text](https://github.com/tavioalves/flashcards/blob/master/images/flashcards.png)

## Tested with

The application was tested using a iOS(iPhone 6S) device, unfortunately I don't have a Android device to test the app with it.

## How to use and test

*PS: It's necessary that you have a mobile device that has Expo app, and a computer that can run the Expo CLI.*

Clone the repository to a folder of your choice, redirect to the cloned repository and execute the following command:

```javascript
yarn install
```

After the installation of the libs and dependencies, start the project executing the command:

```javascript
yarn start
```

Use the mobile device camera to scan the QRCode and run the project.

## Organization

The project is organized in the following way:

- src
  - actions
  - components
  - reducers
  - screens
  - types
- App.js

## Libs

Below we can see all the libs used in the project:

|       Name       |                                                                                Function                                                                                |
| :--------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|       expo       |                           A free and open source toolchain built around React Native to help you build native iOS and Android apps using JavaScript and React.                           |
|      redux       |                         Helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.                         |
|   redux-thunk    | Thunks are the recommended middleware for basic Redux side effects logic, including complex synchronous logic that needs access to the store, and simple async logic like AJAX requests. |
|   react-redux    |                                                                                Binding of React and Redux                                                                                |
| react-navigation |                                                                                React native navigation                                                                                |

## License

MIT © 2018

## Build tool

This project was created using the [Expo](https://expo.io/).


text:
# Fdo
Feedback Directed Optimization can be useful to squeeze some extra peformance out of an
application.  An instrumented version of the application is build and run, which produces
runtime profile information that is used in a subsequent build to guide the optimization
process.

Note that the run using the instrumented code must be representative for the actual workload
of the application.

## What is it?
1. `cache_hierarchy.c`: a simple C application that times array operations as a function of
    their size to illustrate the cache hierarchy (L1, L2, L3 and RAM) on modern CPUs.
1. `test_fdo.pbs`: a PBS torque script (can be run in bash as well, of course) that
  * builds the application using `-O3` optimization, runs it, and produces an output file
        with timing information.
  * builds an instrumented version of the application, runs it to produce profile information.
  * builds an optimized version using the profile information, runs it, and produces an
        output file with timing information.
1. `test_fdo.plt`: gnuplot script to compare the timings for the `-O3` and FDO version of
    the application.

repository: binomaiheu/training-material

repo_name: binomaiheu/training-material


text:
**Right Where You Left Me** 是由Taylor
Swift录唱的一首歌曲，被收录在她的第九张录音室专辑《Evermore》。该歌曲讲述的是一个女孩子被渣男对待的故事，歌词生动有趣！

Evermore是上张专辑Folklore的姊妹专辑，都是在发行前几个小时就在社交媒体上发布的惊喜专辑。发布后获得了广泛的好评。在Metacritic上，将各家出版社所对于《Evermore》的评价归一化后，再根据该专辑的12条评论给与了85分的平均均分。

同时，网站还为大家提供了《[ **Dorothea**](Music-12515-Dorothea-Taylor-Swift.html
"Dorothea")》曲谱下载

歌词下方是 _Right Where You Left Me钢琴谱_ ，大家可以免费下载学习。

### Right Where You Left Me歌词：

[Verse 1]
Friends break up, friends get married
Strangers get born, strangers get buried
Trends change, rumors fly through new skies
But I'm right where you left me
Matches burn after the other
Pages turn and stick to each other
Wages earned and lessons learned
But I'm right where you left me
[Pre-Chorus]
Help, I'm still at the restaurant
Still sitting in a corner I haunt
Cross-legged in the dim light
They say, "What a sad sight"
I, I swear you could hear a hair pin drop
Right when I felt the moment stop
Glass shattered on the white cloth
Everybody moved on, I, I stayed there
Dust collected on my pinned-up hair
They expected me to find somewhere
Some perspective, but I sat and stared
[Chorus]
Right where you left me
You left me no, you left me no
You left me no choice but to stay here forever
You left me, you left me no, you left me no
You left me no choice but to stay here forever
[Verse 2]
Did you ever hear about the girl who got frozen?

url: https://raw.githubusercontent.com/Emptyspirit/everyonepiano-music-database/fb8ba03dd9474f049b18d9822c40a395229b7aca/流行/Right Where You Left Me-Taylor Swift/README.md


text:
## Authenticate

https://accounts.google.com/o/oauth2/auth?
  client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&
  redirect_uri=http%3A%2F%2Flocalhost%2Foauth2callback&
  scope=https://www.googleapis.com/auth/youtube&
  response_type=code&
  access_type=offline

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1020433707922-h4gu5fbe7i4hg4rlcmm6dk5n59ug7597.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%2Foauth2callback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.force-ssl&access_type=offline

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1020433707922-3hno8dmetcud8ptcer8mq8oa16f5qdf3.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%2Foauth2callback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.force-ssl&access_type=offline

## List first page of live streams

```
curl \
  'https://youtube.googleapis.com/youtube/v3/liveBroadcasts?broadcastStatus=completed&broadcastType=broadcastTypeFilterUnspecified&maxResults=5&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed
```

## Insert broadcast

Open API explorer
```
https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert?hl=en&authuser=2&apix=true&apix_params=%7B%22part%22%3A%5B%22snippet%2CcontentDetails%2Cstatus%22%5D%2C%22resource%22%3A%7B%22snippet%22%3A%7B%22title%22%3A%22Test%20broadcast%22%2C%22scheduledStartTime%22%3A%222022-10-19T09%3A15%3A00%22%2C%22scheduledEndTime%22%3A%222022-10-19T10%3A40%3A00%22%2C%22channelId%22%3A%22UC5tpyZ_6K_hTov2tesd9yTA%22%7D%2C%22contentDetails%22%3A%7B%22enableClosedCaptions%22%3Atrue%2C%22enableContentEncryption%22%3Atrue%2C%22enableDvr%22%3Atrue%2C%22enableEmbed%22%3Atrue%2C%22recordFromStart%22%3Atrue%2C%22startWithSlate%22%3Atrue%7D%2C%22status%22%3A%7B%22privacyStatus%22%3A%22unlisted%22%7D%7D%7D
```

curl:

repository: tstephen/cbc-gsuite

repo_name: tstephen/cbc-gsuite