text:
---
layout: post
current: post
cover: assets/images/covers/euler.jpg
navigation: True
title: Project Euler
date: 2019-09-18 12:00:00
# tags: python maths
class: post-template
subclass: "post tag-python tag-maths"
---

When I was searching for coding challenges recently, I came across [Project Euler](https://projecteuler.net/). This website has problems that range in difficulty, but generally involve a mixture of skills in mathematics and coding. I decided to try a few problems in Python, which turned out to be a lot of fun.

I started with Problem 6; to skip ahead to my discussion of other problems you can click [here for Problem 1](#problem-1) or [here for Problem 46](#problem-46).

[Problem 6](https://projecteuler.net/problem=6) is a simple question, which asks:

> Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

That is, we want to calculate $(1+2+...+100)^2-(1^2+2^2+...+100^2)$. Given that 100 is small in computer terms, this problem could easily be solved using a `for` loop. However, calculating sums for $n$ and $n^2$ reminded me of the maths I was teaching not so long ago.  I decided to use the formulae for these sums to make my solution efficient, and easily able to be scaled up to numbers much larger than 100. The two formulae[$^1$](#footnote) are as follows:

- $\displaystyle\sum_1^n n = \frac{n(n+1)}{2}$
- $\displaystyle\sum_1^n n^2 = \frac{n(n+1)(2n+1)}{6}$

The first formula, for summation of the first $n$ natural numbers, is famously attributed to Gauss. It is said he was asked to calculate $1+2+...+100$ as a young schoolboy; though his teacher expected the problem to keep him occupied for a long time, Gauss cleverly noticed a pattern and solved the problem quite quickly. Using the sum $1+2+...+n$, we can visualise it as follows. First, we put the numbers 1 to $n$ in columns.
![Sum of integers 1](assets/images/posts/sum_natural_numbers_1.png)
Then, we take another copy of the numbers 1 to $n$. Put this copy in reverse order, and place it below the first.
![Sum of integers 2](assets/images/posts/sum_natural_numbers_2.png)
Now each column adds up to a total of $n+1$.
![Sum of integers 3](assets/images/posts/sum_natural_numbers_3.png)
Therefore, we have a total of $n(n+1)$. However, since we added two copies of each integer instead of just one, we need to halve our answer to obtain $\displaystyle\sum_1^n n = \frac{n(n+1)}{2}$. Pretty cool, huh?

Getting back to our code, we have two functions to write. To calculate $\displaystyle\sum_1^n n$ we have:

```python
def sum(n):
  ans = (n*(n + 1)) / 2
  return ans
```

Then, to calculate $\displaystyle\sum_1^n n^2$ we have:

```python
def squares_sum(n):
  ans = (n*(n + 1)*(2*n + 1)) / 6
  return ans
```

Calculating the final solution is then simply a matter of squaring the result of the first function, and subtracting the result of the second. Thus we end up with

```python
def square_sums_difference(n):
  ans = sum(n) ** 2 - squares_sum(n)
  return ans
```

and so Problem 6 of the Euler Project is complete.

The next problem I looked at was [Problem 1](https://projecteuler.net/problem=1), which can also make use of our `sum(n)` function. A statement of the problem is below.

> Find the sum of all the multiples of 3 or 5 below 1000.

To solve this problem, we need to make two observations:

- The sum $3+6+...+999$ is the same as the sum $3(1+2+...+333)$.
- If we add each multiple of 3 and then each multiple of 5, we will have counted each multiple of 15 twice.

Using the first observation, we see that we can find the sum of all multiples of $n$ up to and including 999 by evaluating the sum $1+2+...+(999/n)$ and multiplying it by $n$. This gives us the following function:

```python
def sum_one_factor(n, maximum):
	occurences = maximum / n
	ans = n * sum(occurences)
	return ans
```

Turning our attention to the second observation, we can find the multiples of 3 or 5 by adding the multiples of 3 to the multiples of 5, then subtracting the multiples of 15 to compensate for having double counted them:

```python
def sum_two_factors(fact_one, fact_two, maximum):
	ans = sum_one_factor(fact_one, maximum) + sum_one_factor(fact_two, maximum)\
	- sum_one_factor(fact_one*fact_two, maximum)
	return ans
```

All we need to remember is that, given the problem specifies _below_ 1000 and our functions include the maximum in their sum, we should call `sum_two_factors(3,5,999)` to get the correct answer.

The final problem I coded for this post is [Problem 46](https://projecteuler.net/problem=46), titled "Goldbach's Other Conjecture". The goal of this problem is to find the first counterexample to the following statement:

> Every odd composite number can be written as the sum of a prime and twice a square.

Recall that a composite number is an integer greater than 1 that is not prime. We will begin our solution by writing a function to check whether a number is prime. Python doesn't have an inbuilt function for this; although libraries with prime checkers exist, it is simple enough for us to write our own function. Intuitively, we need to know whether the given number $n$ has any factors between $2$ and $n-1$. However, notice that if $n$ has a factor greater than or equal to $\sqrt{n}$, it must also have a factor less than or equal to $\sqrt{n}$. Therefore, we only need to check for factors between 2 and $\sqrt{n}$:

```python
def is_prime(n):
	for i in range(2, int(math.sqrt(n)+1)):
		if n%i == 0:
			return False
	return True
```

Note that we have added 1 to `math.sqrt(n)` because `range()` excludes the upper bound.

Since the question relates to odd numbers and all primes are odd except for 2, we will treat 2 as a special case and add it manually to a list called `primes`. We then find the solution by iterating through odd numbers, starting with 3, and either adding them to our `primes` list or checking whether it satisfies the conjecture. The code for this is as follows:

```python
def disprove_goldbachs_other_conjecture():
	found = False
	current = 3
	primes = [2]
	while not found:
		if is_prime(current):
			primes.append(current)
		else:
			if create_sum(current, primes) == 0:
				return current
		current = current + 2
```

What remains is to write a function `create_sum(n, primes)` to check Goldbach's conjecture. We know that if a number $n$ is to be written as the sum of a prime and twice a square, then the prime must be smaller than $n$. In our case, the list `primes` already contains the potential candidates, so we will pass that to the function. We then check each prime $p$ in the list to see whether the difference between $n$ and $p$ is 2 times a perfect square. To do that, we can use the following:

```python
def create_sum(n, primes):
	for p in primes:
		if math.floor(math.sqrt((n-p)/2)) == math.sqrt((n-p)/2):
			return p
	return 0
```

So there we have it, problem solved! There are hundreds of questions on the Project Euler website, each with a different balance of coding skills and mathematical know-how. My next blog post is about [Sum of Squares]({% post_url 2019-09-21-sum-of-squares %}), another problem from Project Euler that turned out to be mathematically challenging and worthy of a separate post. To see the Python files, visit [my GitHub repository](https://github.com/jenniferanneaus/project_euler_code).

 $1.$ Note the use of sigma notation in sums:

• $\displaystyle\sum_1^n n$ is equivalent to $1+2+...+n$, and

• $\displaystyle\sum_1^n n^2$ is equivalent to $1^2+2^2+...+n^2$. [↩](#return-from-footnote)


text:
# Stachybotrys breviuscula McKenzie, 1991 SPECIES

#### Status
ACCEPTED

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

#### Published in
Mycotaxon 41(1): 180 (1991)

#### Original name
Stachybotrys breviuscula McKenzie, 1991

### Remarks
null

repository: mdoering/backbone

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: mdoering/backbone


text:
VirusTotal public and private APIv2 Full support - VT APIv3
===================

* __My pypi VT package was transfered to VirusTotal ownership__

Before using the tool you must set your api key in one of this file or you can start without creating it and you will be prompted to provide the data:
* Home Directory:
    * __~.vtapi__, __~vtapi.conf__
* or current directory where vt script placed
    * __.vtapi__, __vtapi.conf__

* ~.vtapi file content:
```python
[vt]
apikey=your-apikey-here
type=public
intelligence=False
#coma separated engine list, can be empty
engines=
timeout=60
# as for weblogin, this only required for rule management
username=
password=
```
* your type of api access, if private: type=private, if public, you can leave it empty, it will be automatically recognized as public
* if you have access to VT Intelligence, you need set intelligence=True

**Dependencies:**
 *  requests
 *  texttable
 *  python-dateutil

These can be installed via PIP or a package manager.
Example of installing all dependencies using pip:
```python
pip install -r requirements.txt
```

* Thanks to @kellewic and @urbanski
* Special thanks to @Seifreed for testing and reporting bugs

### Example of usage as library can be found [here](https://github.com/doomedraven/VirusTotalApi/wiki)

Few public API functions taken from Chris Clark script

And finally has been added full public and private API support by Andriy Brukhovetskyy (doomedraven)

Small manual with examples
http://www.doomedraven.com/2013/11/script-virustotal-public-and-private.html

* ___BEAR IN MIND THIS IS AN OLD EXAMPLE, use -h for current help___
```
vt -h
usage: value [-h] [-fi] [-udb USERDB] [-fs] [-f] [-fr] [-u] [-ur] [-d] [-i]
             [-w] [-s] [-si] [-et] [-rai] [-itu] [-cw] [-dep] [-eo] [-snr]
             [-srct] [-tir] [-wir] [-rbgi] [-rbi] [-agi] [-dbc] [-ac] [-gc]
             [--get-comments-before DATE] [-v] [-j] [--csv] [-rr] [-rj] [-V]
             [-r] [--delete] [--date DATE] [--period PERIOD] [--repeat REPEAT]
             [--notify-url NOTIFY_URL] [--notify-changes-only] [-wh] [-wht]
             [-pdns] [--asn] [-aso] [--country] [--subdomains]
             [--domain-siblings] [-cat] [-alc] [-alk] [-opi] [--drweb-cat]
             [-adi] [-wdi] [-tm] [-wt] [-bd] [-wd] [-du] [--pcaps] [--samples]
             [-dds] [-uds] [-dc] [-uc] [-drs] [-urs] [-pe]
             [-esa SAVE_ATTACHMENT] [-peo] [-bh] [-bn] [-bp] [-bs] [-dl]
             [-nm NAME] [-dt DOWNLOAD_THREADS] [--pcap] [--clusters]
             [--distribution-files] [--distribution-urls] [--before BEFORE]
             [--after AFTER] [--reports] [--limit LIMIT] [--allinfo] [--rules]
             [--list] [--create FILE] [--update FILE] [--retro FILE]
             [--delete_rule DELETE_RULE] [--share]
             [--update_ruleset UPDATE_RULESET] [--disable DISABLE]
             [--enable ENABLE]
             [value [value ...]]

Scan/Search/ReScan/JSON parse

positional arguments:
  value                 Enter the Hash, Path to File(s) or Url(s)

optional arguments:
  -h, --help            show this help message and exit
  -fi, --file-info      Get PE file info, all data extracted offline, for work
                        you need have installed PEUTILS library
  -udb USERDB, --userdb USERDB
                        Path to your userdb file, works with --file-info
                        option only
  -fs, --file-search    File(s) search, this option, don't upload file to
                        VirusTotal, just search by hash, support linux name
                        wildcard, example: /home/user/*malware*, if file was
                        scanned, you will see scan info, for full scan report
                        use verbose mode, and dump if you want save already
                        scanned samples
  -f, --file-scan       File(s) scan, support linux name wildcard, example:
                        /home/user/*malware*, if file was scanned, you will
                        see scan info, for full scan report use verbose mode,
                        and dump if you want save already scanned samples
  -fr, --file-scan-recursive
                        Recursive dir walk, use this instead of --file-scan if
                        you want recursive
  -u, --url-scan        Url scan, support space separated list, Max 4 urls (or
                        25 if you have private api), but you can provide more
                        urls, for example with public api, 5 url - this will
                        do 2 requests first with 4 url and other one with only
                        1, or you can specify file filename with one url per
                        line
  -ur, --url-report     Url(s) report, support space separated list, Max 4 (or
                        25 if you have private api) urls, you can use --url-
                        report --url-scan options for analyzing url(s) if they
                        are not in VT data base, read preview description
                        about more then max limits or file with urls
  -d, --domain-info     Retrieves a report on a given domain (PRIVATE API
                        ONLY! including the information recorded by
                        VirusTotal's Passive DNS infrastructure)
  -i, --ip-info         A valid IPv4 address in dotted quad notation, for the
                        time being only IPv4 addresses are supported.
  -w, --walk            Work with domain-info, will walk through all detected
                        ips and get information, can be provided ip parameters
                        to get only specific information
  -s, --search          A md5/sha1/sha256 hash for which you want to retrieve
                        the most recent report. You may also specify a scan_id
                        (sha256-timestamp as returned by the scan API) to
                        access a specific report. You can also specify a space
                        separated list made up of a combination of hashes and
                        scan_ids Public API up to 4 items/Private API up to 25
                        items, this allows you to perform a batch request with
                        one single call.
  -si, --search-intelligence
                        Search query, help can be found here -
                        https://www.virustotal.com/intelligence/help/
  -et, --email-template
                        Table format template for email
  -ac, --add-comment    The actual review, you can tag it using the "#"
                        twitter-like syntax (e.g. #disinfection #zbot) and
                        reference users using the "@" syntax (e.g.
                        @VirusTotalTeam). supported hashes MD5/SHA1/SHA256
  -gc, --get-comments   Either a md5/sha1/sha256 hash of the file or the URL
                        itself you want to retrieve
  --get-comments-before DATE
                        A datetime token that allows you to iterate over all
                        comments on a specific item whenever it has been
                        commented on more than 25 times. Token format
<PHONE_NUMBER>0000 or 2012-07-25 17 00 00 or 2012-07-25
                        17:00:00
  -v, --verbose         Turn on verbosity of VT reports
  -j, --dump            Dumps the full VT report to file (VTDL{md5}.json), if
                        you (re)scan many files/urls, their json data will be
                        dumped to separated files
  --csv                 Dumps the AV's detections to file (VTDL{scan_id}.csv)
  -rr, --return-raw     Return raw json, in case if used as library and want
                        parse in other way
  -rj, --return-json    Return json with parts activated, for example -p for
                        passive dns, etc
  -V, --version         Show version and exit

All information related:
  -rai, --report-all-info
                        If specified and set to one, the call will return
                        additional info, other than the antivirus results, on
                        the file being queried. This additional info includes
                        the output of several tools acting on the file (PDFiD,
                        ExifTool, sigcheck, TrID, etc.), metadata regarding
                        VirusTotal submissions (number of unique sources that
                        have sent the file in the past, first seen date, last
                        seen date, etc.), and the output of in-house
                        technologies such as a behavioural sandbox.
  -itu, --ITW-urls      In the wild urls
  -cw, --compressedview
                        Contains information about extensions, file_types,
                        tags, lowest and highest datetime, num children
                        detected, type, uncompressed_size, vhash, children
  -dep, --detailed-email-parents
                        Contains information about emails, as Subject, sender,
                        receiver(s), full email, and email hash to download it
  -eo, --email-original
                        Will retrieve original email and process it
  -snr, --snort         Get Snort results
  -srct, --suricata     Get Suricata results
  -tir, --traffic-inspection
                        Get Traffic inspection info
  -wir, --wireshark-info
                        Get Wireshark info
  -rbgi, --rombios-generator-info
                        Get RomBios generator info
  -rbi, --rombioscheck-info
                        Get RomBiosCheck info
  -agi, --androidguard-info
                        Get AndroidGuard info
  -dbc, --debcheck-info
                        Get DebCheck info, also include ios IPA

Rescan options:
  -r, --rescan          Allows you to rescan files in VirusTotal's file store
                        without having to resubmit them, thus saving
                        bandwidth, support space separated list, MAX 25
                        hashes, can be local files, hashes will be generated
                        on the fly, support linux wildmask
  --delete              A md5/sha1/sha256 hash for which you want to delete
                        the scheduled scan
  --date DATE           A Date in one of this formats (example:<PHONE_NUMBER>0000
                        or 2012-07-25 17 00 00 or 2012-07-25 17:00:00) in
                        which the rescan should be performed. If not specified
                        the rescan will be performed immediately.
  --period PERIOD       Period in days in which the file should be rescanned.
                        If this argument is provided the file will be
                        rescanned periodically every period days, if not, the
                        rescan is performed once and not repeated again.
  --repeat REPEAT       Used in conjunction with period to specify the number
                        of times the file should be rescanned. If this
                        argument is provided the file will be rescanned the
                        given amount of times, if not, the file will be
                        rescanned indefinitely.

File scan/Rescan shared options:
  --notify-url NOTIFY_URL
                        An URL where a POST notification should be sent when
                        the scan finishes.
  --notify-changes-only
                        Used in conjunction with --notify-url. Indicates if
                        POST notifications should be sent only if the scan
                        results differ from the previous one.

Domain/IP shared verbose mode options, by default just show resolved IPs/Passive DNS:
  -wh, --whois          Whois data
  -wht, --whois-timestamp
                        Whois timestamp
  -pdns, --resolutions  Passive DNS resolves
  --asn                 ASN number
  -aso, --as-owner      AS details
  --country             Country
  --subdomains          Subdomains
  --domain-siblings     Domain siblings
  -cat, --categories    Categories
  -alc, --alexa-cat     Alexa category
  -alk, --alexa-rank    Alexa rank
  -opi, --opera-info    Opera info
  --drweb-cat           Dr.Web Category
  -adi, --alexa-domain-info
                        Just Domain option: Show Alexa domain info
  -wdi, --wot-domain-info
                        Just Domain option: Show WOT domain info
  -tm, --trendmicro     Just Domain option: Show TrendMicro category info
  -wt, --websense-threatseeker
                        Just Domain option: Show Websense ThreatSeeker
                        category
  -bd, --bitdefender    Just Domain option: Show BitDefender category
  -wd, --webutation-domain
                        Just Domain option: Show Webutation domain info
  -du, --detected-urls  Just Domain option: Show latest detected URLs
  --pcaps               Just Domain option: Show all pcaps hashes
  --samples             Will activate -dds -uds -dc -uc -drs -urs
  -dds, --detected-downloaded-samples
                        Domain/Ip options: Show latest detected files that
                        were downloaded from this ip
  -uds, --undetected-downloaded-samples
                        Domain/Ip options: Show latest undetected files that
                        were downloaded from this domain/ip
  -dc, --detected-communicated
                        Domain/Ip Show latest detected files that communicate
                        with this domain/ip
  -uc, --undetected-communicated
                        Domain/Ip Show latest undetected files that
                        communicate with this domain/ip
  -drs, --detected-referrer-samples
                        Undetected referrer samples
  -urs, --undetected-referrer-samples
                        Undetected referrer samples

Process emails:
  -pe, --parse-email    Parse email, can be string or file
  -esa SAVE_ATTACHMENT, --save-attachment SAVE_ATTACHMENT
                        Save email attachment, path where to store
  -peo, --parse-email-outlook
                        Parse outlook .msg, can be string or file

Behaviour options:
  -bh, --behaviour      The md5/sha1/sha256 hash of the file whose dynamic
                        behavioural report you want to retrieve. VirusTotal
                        runs a distributed setup of Cuckoo sandbox machines
                        that execute the files we receive. Execution is
                        attempted only once, upon first submission to
                        VirusTotal, and only Portable Executables under 10MB
                        in size are ran. The execution of files is a best
                        effort process, hence, there are no guarantees about a
                        report being generated for a given file in our
                        dataset. a file did indeed produce a behavioural
                        report, a summary of it can be obtained by using the
                        file scan lookup call providing the additional HTTP
                        POST parameter allinfo=1. The summary will appear
                        under the behaviour-v1 property of the additional_info
                        field in the JSON report.This API allows you to
                        retrieve the full JSON report of the files execution
                        as outputted by the Cuckoo JSON report encoder.
  -bn, --behavior-network
                        Show network activity
  -bp, --behavior-process
                        Show processes
  -bs, --behavior-summary
                        Show summary

Download options:
  -dl, --download       The md5/sha1/sha256 hash of the file you want to
                        download or txt file with .txt extension, with hashes,
                        or hash and type, one by line, for example: hash,pcap
                        or only hash. Will save with hash as name, can be
                        space separated list of hashes to download
  -nm NAME, --name NAME
                        Name with which file will saved when download it
  -dt DOWNLOAD_THREADS, --download-threads DOWNLOAD_THREADS
                        Number of simultaneous downloaders

Additional options:
  --pcap                The md5/sha1/sha256 hash of the file whose network
                        traffic dump you want to retrieve. Will save as
                        hash.pcap
  --clusters            A specific day for which we want to access the
                        clustering details, example: 2013-09-10
  --distribution-files  Timestamps are just integer numbers where higher
                        values mean more recent files. Both before and after
                        parameters are optional, if they are not provided the
                        oldest files in the queue are returned in timestamp
                        ascending order.
  --distribution-urls   Timestamps are just integer numbers where higher
                        values mean more recent urls. Both before and after
                        parameters are optional, if they are not provided the
                        oldest urls in the queue are returned in timestamp
                        ascending order.

Distribution options:
  --before BEFORE       File/Url option. Retrieve files/urls received before
                        the given timestamp, in timestamp descending order.
  --after AFTER         File/Url option. Retrieve files/urls received after
                        the given timestamp, in timestamp ascending order.
  --reports             Include the files' antivirus results in the response.
                        Possible values are 'true' or 'false' (default value
                        is 'false').
  --limit LIMIT         File/Url option. Retrieve limit file items at most
                        (default: 1000).
  --allinfo             will include the results for each particular URL scan
                        (in exactly the same format as the URL scan retrieving
                        API). If the parameter is not specified, each item
                        returned will only contain the scanned URL and its
                        detection ratio.

Rules management options:
  --rules               Manage VTI hunting rules, REQUIRED for rules management
  --list                List names/ids of Yara rules stored on VT
  --create FILE         Add a Yara rule to VT (File Name used as RuleName
  --update FILE         Update a Yara rule on VT (File Name used as RuleName
                        and must include RuleName
  --retro FILE          Submit Yara rule to VT RetroHunt (File Name used as
                        RuleName and must include RuleName
  --delete_rule DELETE_RULE
                        Delete a Yara rule from VT (By Name)
  --share               Shares rule with user
  --update_ruleset UPDATE_RULESET
                        Ruleset name to update
  --disable DISABLE     Disable a Yara rule from VT (By Name)
  --enable ENABLE       Enable a Yara rule from VT (By Name)
```

license: MIT

repository: doomedraven/VirusTotalApi

gha_language: Python

gha_license_id: MIT

repo_name: doomedraven/VirusTotalApi


text:
# GraphQL Binding for Swagger/OpenAPI

# Deprecation Notices!

In the last few months, since [the transition of many libraries](https://www.prisma.io/blog/the-guild-takes-over-oss-libraries-vvluy2i4uevs) under [The Guild](http://the-guild.dev)'s leadership, We've reviewed and released many improvements and versions to [graphql-cli](https://github.com/Urigo/graphql-cli), [graphql-config](https://github.com/kamilkisiela/graphql-config) and [graphql-import](https://github.com/ardatan/graphql-import).

We've reviewed `graphql-binding`, had many meetings with current users and engaged the community also through the [roadmap issue](https://github.com/dotansimha/graphql-binding/issues/325).

What we've found is that the new [GraphQL Mesh](https://the-guild.dev/blog/graphql-mesh) library is covering not only all the current capabilities of GraphQL Binding, but also the future ideas that were introduced in the [original GraphQL Binding blog post](https://github.com/prisma-archive/prisma-blog-archive/blob/master/2018-01-12-reusing-and-composing-graphql-apis-with-graphql-bindings.mdx) and haven't come to life yet.

And the best thing - [GraphQL Mesh](https://the-guild.dev/blog/graphql-mesh) gives you all those capabilities, even if your source is not a GraphQL service at all!
it can be GraphQL, OpenAPI/Swagger, gRPC, SQL or any other source!
And of course you can even merge all those sources into a single SDK.

Just like GraphQL Binding, you get a fully typed SDK (thanks to the protocols SDKs and the [GraphQL Code Generator](https://github.com/dotansimha/graphql-code-generator)), but from any source, and that SDK can run anywhere, as a connector or as a full blown gateway.
And you can share your own "Mesh Modules" (which you would probably call "your own binding") and our community already created many of those!
Also, we decided to simply expose regular GraphQL, so you can choose how to consume it using all the awesome [fluent client SDKs out there](https://hasura.io/blog/fluent-graphql-clients-how-to-write-queries-like-a-boss/).

If you think that we've missed anything from GraphQL Binding that is not supported in a better way in GraphQL Mesh, please let us know!

Embed any Swagger/OpenAPI endpoint as GraphQL API into your server application.

Both yaml and json specifications are supported.

## Install

```sh
yarn add graphql-binding-openapi
```

## How it works

A service endpoint that uses the Swagger/OpenAPI specification contains a definition file (in either JSON or YAML format). This definition file has the following structure:
```json
{
    "swagger": "2.0",
    "info": { },
    "host": "petstore.swagger.io",
    "basePath": "/v2",
    "tags": [ ],
    "schemes": [ "http" ],
    "paths": { },
    "securityDefinitions": {},
    "definitions": { },
    "externalDocs": { }
}
```
An example for the petstore endpoint can be found [here](./example/petstore.json).

This endpoint definition is transformed into a GraphQL schema, with all the paths from the endpoint translated into queries and mutations. The query and mutation names are based on the unique `operationName` found in the definition for each path. This schema looks like this:
```graphql
type Query {
  # GET /pet/findPetsByStatus
  findPetsByStatus(status: [String]): [findPetsByStatus_items]

  # GET /pet/findPetsByTags
  findPetsByTags(tags: [String]): [findPetsByTags_items]

  # GET /pet/{petId}
  getPetById(petId: String): getPetById

  # other queries
}

type Mutation {
  # POST /pet
  addPet(body: param_addPet_body): addPet

  # PUT /pet
  updatePet(body: param_updatePet_body): updatePet

  # PUT /pet/{petId}
  updatePetWithForm(petId: String, name: String, status: String): updatePetWithForm

  # DELETE /pet/{petId}
  deletePet(api_key: String, petId: String): deletePet

  # other mutations
}
```
The full schema for the petstore endpoint can be found [here](./petstore.graphql).

The remote executable GraphQL schema (containing all the resolvers for querying the original endpoint) is exposed as a binding by `graphql-binding-openapi`, making each query and mutation available as a method on the binding class, for example:
```js
petstore.query.findPetsByStatus({ status: "available" })
petstore.mutation.addPet({ /* mutation arguments */ })
```

## Example

### Standalone
See [example directory](example) for a standalone example.

### With `graphql-yoga`
```js
const { OpenApi } = require('graphql-binding-openapi')
const { GraphQLServer } = require('graphql-yoga')

const resolvers = {
  Query: {
    findAvailablePets: async (parent, args, context, info) => {
      return context.petstore.query.findPetsByStatus({ status: "available" }, context, info)
    }
  }
}

const server = new GraphQLServer({
  resolvers,
  typeDefs,
  context: async req => {
    ...req,
    petstore: await OpenApi.init('./petstore.json', 'http://petstore.swagger.io/v2')
  }
})

server.start(() => console.log('Server running on http://localhost:4000'))
```

## graphql-config support

OpenAPI bindings are supported in `graphql-config` using its extensions model. OpenAPI bindings can be added to the configuration like this:
```yaml
projects:
  petstore:
    schemaPath: src/generated/petstore.graphql
    extensions:
      openapi:
        definition: petstore.json
```
This will enable running `graphql get-schema` to output the generated schema from the definition to the defined schemaPath.

## Static bindings
Static binding support coming soon.

repository: graphql-binding/graphql-binding-openapi

gha_language: TypeScript

repo_name: graphql-binding/graphql-binding-openapi


text:
# History

## v1.1.0 2016 May 10
- Added about 150 additional text extensions
	- Thanks to [FelipeBB](https://github.com/FelipeBB) for [pull request #3](https://github.com/bevry/textextensions/pull/3)

## v1.0.2 2016 May 2
- Updated meta files

## v1.0.1 2014 December 17
- Added `yml` extension
	- Thanks to [Jamy Timmermans](https://github.com/JamyDev) for [pull request #2](https://github.com/bevry/textextensions/pull/2)

## v1.0.0 2013 December 10
- Extracted from [bal-util](https://github.com/balupton/bal-util/blob/6501d51bc0244fce3781fc0150136f7493099237/src/lib/paths.coffee#L48-L79)

license: MIT,ISC

detected_licenses: MIT ISC


text:
# Tranzschelia discolor (Fuckel) Tranzschel & M.A. Litv., 1939 SPECIES

#### Status
ACCEPTED

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

#### Published in
J. Bot. , Paris 24(3): 248 (1939)

#### Original name
Puccinia discolor Fuckel, 1868

### Remarks
null


text:
# awesome-blockchain-summary
main about program language and consensus. top 200 At present.

| project name | program language | consensus | GitHub link    |website|
| ------------ | ---------------- | --------- | --------------------------------------- | ---------------- |
| Bitcoin | c++ | pow | https://github.com/bitcoin/ | https://bitcoin.org/ |
| Ethereum | go | pow | https://github.com/ethereum | https://www.ethereum.org/ |
| Ripple | c++ |  | https://github.com/ripple | https://ripple.com/ |
| Bitcoin Cash | c++ | pow | https://github.com/bitcoincashorg/ | https://www.bitcoincash.org/ |
| Litecoin | c++ | pow | https://github.com/litecoin-project/litecoin | https://litecoin.com |
| Cardano | haskell | pos | https://github.com/input-output-hk/cardano-sl/ | https://www.cardano.org |
| NEO | c# | dbft | https://github.com/neo-project | https://neo.org/ |
| Stellar | c |  | https://github.com/stellar | https://www.stellar.org |
| EOS | c++ | dpos | https://github.com/eosio | https://eos.io/ |
| NEM | java |  | https://github.com/NemProject | http://nem.io |
| Dash | c++ | pow | https://github.com/dashpay/dash | https://www.dash.org/ |
| Monero | c++ | pow | https://github.com/monero-project/monero | http://www.monero.cc |
| IOTA | java |  | https://github.com/iotaledger | https://iota.org/ |
| Tether |  |  |  | https://tether.to |
| TRON | java |  | https://github.com/tronprotocol | https://tron.network/ |
| VeChain |  |  |  | https://www.vechain.org/ |
| Ethereum Classic | go | pow | https://github.com/ethereumproject | https://ethereumclassic.github.io/ |
| Nano | c++ |  | https://github.com/nanocurrency | http://nano.org/en |
| Lisk | javascript | dpos | https://github.com/LiskHQ/ | https://lisk.io/ |
| OmiseGO | go |  | https://github.com/omise/omise-go | https://omg.omise.co/ |
| Qtum | c++ | pos | https://github.com/qtumproject/qtum/ | https://qtum.org/ |
| Bitcoin Gold | c++ | pow | https://github.com/BTCGPU/BTCGPU | https://bitcoingold.org/ |
| ICON | python | bft | https://github.com/theloopkr/loopchain | https://www.icon.foundation/ |
| Binance Coin |  |  |  | https://www.binance.com/ |
| Zcash | c++ | pow | https://github.com/zcash/zcash | https://z.cash/ |
| DigixDAO | solidity |  | https://github.com/digixglobal | https://digix.io/ |
| Populous |  |  | https://github.com/bitpopulous | http://populous.co/ |
| Steem | c++ | dpos | https://github.com/steemit/steem | https://steem.io/ |
| Waves | scala |  | https://github.com/wavesplatform/ | https://wavesplatform.com/ |
| Bytecoin | c++ |  | https://github.com/bcndev | https://bytecoin.org/ |
| Maker |  |  |  | https://makerdao.com/ |
| Stratis | c++ |  | https://github.com/stratisproject | http://stratisplatform.com/ |
| Verge | c++ | pow | https://github.com/vergecurrency | http://vergecurrency.com/ |
| RChain | c++ | pos | https://github.com/rchain/ | https://www.rchain.coop/ |
| Dogecoin | c++ | pow | https://github.com/dogecoin/dogecoin | http://dogecoin.com/ |
| Siacoin | go | pow | https://github.com/NebulousLabs/Sia | https://sia.tech/ |
| Status |  |  | https://github.com/status-im | http://status.im/ |
| Aeternity | erlang | dpos | https://github.com/aeternity | https://www.aeternity.com/ |
| BitShares | c++ | dpos | https://github.com/bitshares | https://bitshares.org |
| Decred | go |  | https://github.com/decred | https://www.decred.org/ |
| Augur | typescript |  | https://github.com/AugurProject | http://www.augur.net/ |
| Bytom | go | pow | https://github.com/Bytom/bytom | http://bytom.io/ |
| Waltonchain |  |  |  | http://www.waltonchain.org/ |
| Komodo |  |  | https://github.com/KomodoPlatform | https://komodoplatform.com/ |
| Ark |  |  | https://github.com/ArkEcosystem | http://ark.io/ |
| Ardor | java | n | https://bitbucket.org/Jelurida/ardor/src | https://www.ardorplatform.org/ |
| Zilliqa | c++ | pow | https://github.com/Zilliqa/Zilliqa | https://www.zilliqa.com/ |
| Veritaseum |  |  | https://github.com/veritaseum | http://veritas.veritaseum.com/ |
| Electroneum |  |  | https://github.com/electroneum | http://electroneum.com/ |
| 0x | typescript |  | https://github.com/0xProject | https://0xproject.com/ |
| Cryptonex |  |  | https://github.com/Cryptonex | https://cryptonex.org/ |
| KuCoin Shares |  |  |  | https://www.kucoin.com/ |
| Aion |  |  | https://github.com/aionnetwork | https://aion.network/ |
| Hshare | go | pow,pos | https://github.com/HcashOrg/hcashd | https://h.cash/ |
| MonaCoin |  |  | https://github.com/monacoinproject/monacoin | http://monacoin.org |
| DigiByte |  |  | https://github.com/digibyte | http://www.digibyte.io/ |
| PIVX | c++ | pow | https://github.com/PIVX-Project/PIVX/ | http://www.pivx.org |
| Basic Attenti... |  |  |  | https://basicattentiontoken.org/ |
| Factom |  |  | https://github.com/FactomProject | http://factom.org/ |
| QASH |  |  |  | https://liquid.plus/ |
| Golem | python |  | https://github.com/golemfactory/golem | https://golem.network/ |
| Ethos |  |  |  | https://www.ethos.io/ |
| Revain |  |  | https://github.com/Revain | https://revain.org/ |
| Dragonchain | python |  | https://github.com/dragonchain/dragonchain | https://dragonchain.com/ |
| Gas |  |  |  | https://neo.org/ |
| Syscoin | c++ | pow | https://github.com/syscoin/ | http://syscoin.org |
| Nebulas | go | pos | https://github.com/nebulasio | https://nebulas.io/ |
| Loopring | go |  | https://github.com/loopring | https://loopring.org |
| FunFair |  |  |  | https://funfair.io/ |
| GXChain | c++ | dpos | https://github.com/gxchain | https://gxs.gxb.io/ |
| ReddCoin | c++ | pow | https://github.com/reddcoin-project/reddcoin | http://www.reddcoin.com/ |
| ChainLink |  |  |  | https://smartcontract.com/ |
| IOStoken | go | pos |  | http://iost.io/ |
| Dentacoin |  |  | https://github.com/Dentacoin | http://www.dentacoin.com/ |
| SALT |  |  |  | https://www.saltlending.com/ |
| ZCoin |  |  | https://github.com/zcoinofficial/zcoin/ | https://zcoin.io |
| aelf | c# | dpos | https://github.com/aelfProject | http://aelf.io/ |
| Kin |  |  |  | http://kinecosystem.org/ |
| SmartCash |  |  | https://github.com/SmartCash/smartcash | https://smartcash.cc/ |
| Kyber Network |  |  | https://github.com/kybernetwork | https://kyber.network/ |
| Power Ledger |  |  |  | https://powerledger.io/ |
| Byteball Bytes | javascript |  | https://github.com/byteball/byteball | https://byteball.org/ |
| Polymath |  |  | https://github.com/PolymathNetwork | https://www.polymath.network/ |
| Nxt | java |  | https://bitbucket.org/JeanLucPicard/nxt/src | https://nxt.org/ |
| Bancor |  |  | https://github.com/bancorprotocol/ | https://bancor.network/ |
| Emercoin |  |  | https://github.com/emercoin/ | http://emercoin.com/ |
| MaidSafeCoin |  |  | https://github.com/maidsafe | http://maidsafe.net |
| Neblio |  |  | https://github.com/NeblioTeam | https://nebl.io/ |
| Particl |  |  | https://github.com/particl | http://particl.io/ |
| SIRIN LABS Token |  |  | https://github.com/sirin-labs | http://www.sirinlabs.com/ |
| TenX |  |  |  | https://www.tenx.tech/ |
| Request Network |  |  | https://github.com/RequestNetwork/ | https://request.network/ |
| Dent |  |  |  | https://www.dentcoin.com/ |
| Bitcore |  |  | https://github.com/LIMXTEC/BitCore | http://bitcore.cc/ |
| Enigma |  |  | https://github.com/enigmampc | https://enigma.co/ |
| Iconomi |  |  |  | https://www.iconomi.net/ |
| Blocknet |  |  | https://github.com/BlocknetDX/ | http://blocknet.co/ |
| SingularityNET |  |  | https://github.com/singnet/singnet | https://singularitynet.io/ |
| Pillar |  |  | https://github.com/pillarwallet | https://pillarproject.io/ |
| Storj |  |  | https://github.com/Storj/ | https://storj.io/ |
| Nexus |  |  | https://github.com/Nexusoft/ | http://www.nexusearth.com/ |
| BitcoinDark |  |  | https://github.com/jl777/btcd | http://bitcoindark.com/ |
| Substratum |  |  |  | https://substratum.net/ |
| Cindicator |  |  |  | https://cindicator.com/ |
| Gnosis |  |  |  | https://gnosis.pm/ |
| Civic |  |  |  | https://www.civic.com/ |
| Vertcoin |  |  | https://github.com/vertcoin/vertcoin | http://vertcoin.org/ |
| XPA |  |  |  | https://xpa.io/ |
| Monaco |  |  |  | https://www.mona.co/ |
| Dynamic Tradi... |  |  |  | http://www.tokens.net/ |
| Achain | c++ | dpos | https://github.com/Achain-Dev/Achain | https://www.achain.com/ |
| Quantstamp |  |  | https://github.com/quantstamp | https://quantstamp.com/ |
| GameCredits |  |  |  | http://gamecredits.com |
| Theta Token |  |  | https://github.com/thetatoken | https://www.thetatoken.org/ |
| Raiden Networ... | python |  | https://github.com/raiden-network/raiden/ | https://raiden.network/ |
| MinexCoin |  |  | https://github.com/minexcoin/minexcoin | https://minexcoin.com/ |
| Genesis Vision |  |  | https://github.com/GenesisVision | https://genesis.vision/ |
| Enjin Coin |  |  | https://github.com/enjin/contracts | https://www.enjin.com/ |
| Aragon |  |  |  | https://aragon.one/ |
| Skycoin |  |  | https://github.com/skycoin | http://skycoin.net/ |
| Decentraland |  |  | https://github.com/decentraland | https://decentraland.org/ |
| iExec RLC |  |  | https://github.com/iExecBlockchainComputing | http://iex.ec/ |
| Storm |  |  | https://github.com/StormX-Inc/crowdsale | https://stormtoken.com/ |
| SaluS |  |  | https://github.com/saluscoin/SaluS | http://saluscoin.info/ |
| Santiment Net... |  |  | https://github.com/santiment | https://santiment.net/ |
| Metal |  |  |  | https://www.metalpay.com/ |
| PayPie |  |  |  | https://www.paypie.com/ |
| Ignis |  |  |  | https://www.jelurida.com/ico |
| NavCoin |  |  | https://github.com/NAVCoin | http://www.navcoin.org/ |
| Ubiq |  |  | https://github.com/ubiq/go-ubiq | http://ubiqsmart.com/ |
| Einsteinium |  |  | https://github.com/emc2foundation/einsteinium | https://www.emc2.foundation/ |
| Po.et |  |  | https://github.com/poetapp | https://po.et/ |
| Credits |  |  | https://gist.github.com/Credits-com/ | https://credits.com/en |
| Arcblock |  |  | https://github.com/arcblock | https://www.arcblock.io/ |
| DigitalNote |  |  | https://github.com/xdn-project/ | http://digitalnote.org/ |
| WAX |  |  | https://github.com/waxio | https://wax.io/ |
| BridgeCoin |  |  |  | https://www.crypto-bridge.org/ |
| Asch | javascript | dpos | https://github.com/AschPlatform | https://www.asch.io/ |
| Genaro Network |  |  | https://github.com/GenaroNetwork | https://genaro.network/en |
| ZenCash | c++ | pow | https://github.com/ZencashOfficial | https://zencash.com/ |
| Pura |  |  | https://github.com/PURAcore/ | http://www.pura.one/ |
| High Performa... |  |  |  | http://www.gxn.io/ |
| Edgeless |  |  | https://github.com/EdgelessCasino | https://edgeless.io/ |
| Time New Bank |  |  | https://github.com/fanxiong/crowdsale-contracts | http://tnb.fund/ |
| Oyster |  |  | https://github.com/oysterprotocol | https://oysterprotocol.com/ |
| DEW |  |  |  | https://dew.one/ |
| Envion |  |  |  | https://www.envion.org |
| BLOCKv |  |  | https://github.com/BLOCKvIO/documentation | https://blockv.io/ |
| Nuls | java |  | https://github.com/nuls-io/nuls | https://nuls.io/ |
| SophiaTX |  |  |  | https://www.sophiatx.com/ |
| MediBloc |  |  | https://github.com/Medibloc | https://medibloc.org/en/ |
| Fusion |  |  | https://github.com/FUSIONFoundation | https://fusion.org/ |
| ION |  |  | https://github.com/ionomy/ion | https://ionomy.com/ |
| AdEx |  |  | https://github.com/AdExBlockchain | https://www.adex.network/ |
| CRYPTO20 |  |  | https://github.com/cryptotwenty | https://crypto20.com/ |
| ETHLend |  |  |  | https://ethlend.io/ |
| Bluzelle |  |  |  | https://bluzelle.com/ |
| Bibox Token |  |  | https://github.com/bibox365/bixtoken | https://www.bibox.com/ |
| POA Network |  |  | https://github.com/poanetwork | https://poa.network/ |
| SpaceChain |  |  |  |  |
| SONM | go |  | https://github.com/sonm-io | https://sonm.io/ |
| Jibrel Network |  |  | https://github.com/jibrelnetwork | https://jibrel.network/ |
| SpankChain |  |  | https://github.com/spankchain | https://spankchain.com/ |
| Telcoin |  |  | https://github.com/telcoin | https://www.telco.in/ |
| MediShares |  |  | https://github.com/MediShares | http://www.medishares.org/ |
| Streamr DATAcoin |  |  | https://github.com/streamr-dev | https://www.streamr.com/ |
| Ripio Credit ... |  |  | https://github.com/ripio/rcn-token | https://ripiocredit.network/ |
| BitBay |  |  |  | http://bitbay.market/ |
| Peercoin |  |  | https://github.com/peercoin | http://www.peercoin.net |
| Simple Token |  |  | https://github.com/OpenSTFoundation | https://simpletoken.org/ |
| Feathercoin |  |  | https://github.com/FeatherCoin/Feathercoin | http://feathercoin.com |
| Experience Po... |  |  | https://github.com/eXperiencePoints/XPCoin/ | http://www.xpcoin.io/ |
| XTRABYTES |  |  | https://github.com/borzalom/XtraBYtes | https://www.xtrabytes.global/ |
| OriginTrail |  |  | https://github.com/origintrail | https://origintrail.io/ |
| Ambrosus |  |  | https://github.com/ambrosus | http://ambrosus.com/ |
| VIBE |  |  | https://github.com/amack2u/VibeHub | https://www.vibehub.io/ |
| Wagerr |  |  | https://github.com/wagerr | https://www.wagerr.com/ |
| AirSwap |  |  |  | https://www.airswap.io/ |
| Wings |  |  |  | https://wings.ai/ |
| SmartMesh |  |  | https://github.com/SmartMeshFoundation | https://smartmesh.io/ |
| Melon |  |  | https://github.com/melonproject | https://melonport.com/ |
| KickCoin |  |  | https://github.com/kickico | https://www.kickico.com/ |
| Universa |  |  | https://github.com/UniversaBlockchain/ | https://www.universa.io/ |
| Red Pulse |  |  |  | https://www.red-pulse.com/landing |
| MobileGo |  |  |  | https://mobilego.io/ |
| Quantum Resistant Ledger |  |  | https://github.com/theQRL | https://theqrl.org/ |
| Eidoo |  |  |  | https://eidoo.io/ |
| Gifto |  |  | https://github.com/GIFTO-io | https://gifto.io/ |
| UTRUST |  |  |  | https://utrust.io/ |
| Burst |  |  | https://github.com/PoC-Consortium | https://www.burst-coin.org |
| TaaS |  |  |  | https://taas.fund/ |
| Ink | go |  | https://github.com/inklabsfoundation | https://ink.one/ |
| SingularDTV |  |  |  | https://singulardtv.com/ |
| LBRY Credits |  |  | https://github.com/lbryio | https://lbry.io/ |
| HTMLCOIN |  |  | https://github.com/HTMLCOIN | http://www.htmlcoin.com/ |
| NAGA |  |  |  | https://www.thenagacoin.com/ |
| BlockMason Cr... |  |  |  | https://blockmason.io/ |
| Gulden |  |  |  | https://gulden.com/ |
| INS Ecosystem |  |  | https://github.com/ins-ecosystem | https://ins.world/ |
| AppCoins |  |  |  | https://appcoins.io/ |

repository: kaidiren/awesome-blockchain-summary

repo_name: kaidiren/awesome-blockchain-summary


text:
# Introduction to Daniel
## Part 1: General Introduction

### Outline of Daniel

1. Daniel and his friends in the court of Nebuchadnezzar (1:1–21)
1. Daniel interprets Nebuchadnezzar’s first dream (2:1–49)
1. Daniel’s friends delivered from the fiery furnace (3:1–30)
1. Daniel interprets Nebuchadnezzar’s second dream (4:1–37)
1. Belshazzar’s feast and the writing on the wall (5:1-31)
1. Daniel in the den of lions (6:1–28)
1. Daniel’s vision of four beasts (7:1–28)
1. Daniel’s vision of a ram and a goat (8:1–27)
1. Daniel prays and Gabriel answers (9:1–23)
1. Daniel’s vision of seventy weeks (9:24–27)
1. Daniel’s vision of a man (10:1–11:1)
1. The kings of the south and north (11:2–20)
1. An evil king exalts himself (11:21-39)
1. The time of the end (11:40–12:13)

### What is the Book of Daniel about?

The first part of the Book of Daniel (chapters 1–6) is a narrative about Daniel and his friends. They were young men from Jerusalem who were taken to Babylon as prisoners. These chapters tell how they were faithful to Yahweh while living in a pagan land serving a pagan king. And it tells how God rewarded them because they were faithful.

The rest of the Book of Daniel is a series of prophetic visions. Chapters 7 and 8 deal with images representing the kingdoms and kings of the major nations. Chapters 9–11 are prophecies and visions about wars and a type of the great enemy of God appearing. Chapter 12 is a vision that describes end times.

### How should the title of this book be translated?

The traditional title of this book is “The Book of Daniel” or just “Daniel.” Translators may call it “The Book About Daniel” or “The Book About the Deeds and Visions of Daniel.” (See: [[translate-names]])

### Who wrote the Book of Daniel?

Daniel was a Jew who became a Babylonian government official during the exile. He may have written the book himself. Or he may have written the parts of the book and someone else put the parts together at a later time.

## Part 2: Important Religious and Cultural Concepts

### Is there a missing week in Daniel’s prophecy?

Scholars disagree about what may appear to be a missing week in 9:24-27. It is best for translators to allow apparent mysteries such as this to remain in the text. (See: [[writing-apocalypticwriting]])

### When did the seventy weeks begin?

The seventy weeks in 9:24-27 began when a decree was issued to rebuild the city of Jerusalem. But there were several decrees that allowed this to happen. Translators do not need to understand how prophecies were or will be fulfilled to translate the text.

### Who was Darius the Mede?

Darius the Mede was a Babylonian king who sent Daniel into a den of lions. People have not found his name in history outside of the Book of Daniel. Scholars have tried to explain who Darius was, but they are not certain.

## Part 3: Important Translation Issues

### How does Daniel use the word “king”?

Many kings are in the Book of Daniel, but not all of the kings ruled over all of Babylon or Persia. Some of the kings may have ruled over regions or cities.

### How many chapters does Daniel have?

Daniel has twelve chapters. Some Bible versions include stories called “Bel and the Dragon” and “The Prayer of Azariah.” However, few people think that these stories have the same authority as the rest of scripture. Therefore, there is no need to translate them.

repository: mandolyte/uw-obsidian

branch_name: refs/heads/main

repo_name: mandolyte/uw-obsidian


text:
# DragonBones Cocos2d-x Library

English         中文版

## [Demos](./Demos/)

## How to use
1. Create a Cocos2d-x C++ project and import [Demos files](./Demos/) to override the project files.
2. Import the [DragonBones common source code](../DragonBones/src/) to project classes.
3. Import the [DragonBones Cocos2d-x source code](./src/) to project classes.
4. Import the [3rdParty source code](../3rdParty/) to project classes.
5. Build project and have fun.

## Notice
* In Xcode: Add Files To "project" > Options > Added folders: Create groups > Add to targets: "all"
* Use [rapidjson/msinttypes](../3rdParty/rapidjson/msinttypes) headers only with Microsoft Visual C++ compilers.
* Cocos2dx also include rapidjson, if you use the cocos2dx related json function, make sure only include rapidjson once time.
* If compiler can not find headers, add Classes to project Header Search Paths, make sure project structure like this:
```
Classes (Include Path)
    |-- rapidjson
        |-- ...
    |-- dragonBones
        |-- ...
```


text:
# Build Status

[![Join the chat at https://gitter.im/izmailoff/Spray-mongo-record](https://badges.gitter.im/izmailoff/Spray-mongo-record.svg)](https://gitter.im/izmailoff/Spray-mongo-record?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/izmailoff/Spray-mongo-record.png?branch=master)]
(https://travis-ci.org/izmailoff/Spray-mongo-record)

# Spray-mongo-record
A helper library for using Lift-record in Spray. Includes marshalling and testing utilities.

This is WORK IN PROGRESS. Hopefully a dev ready version will be available by the end of Sep 2014.

## Projects that use Spray-mongo-record:
  * ...
  * ...

More documentation is coming soon...

repository: izmailoff/Spray-mongo-record

gha_language: Scala

repo_name: izmailoff/Spray-mongo-record


text:
# homebrew-drunkcase

homebrew tap for drunkcase

What is homebrew? [homebrew](https://brew.sh)

What is drunkcase? [drunkcase](https://github.com/bbriano/drunkcase)

## Install

```bash
brew install bbriano/drunkcase/drunkcase
```

repository: bbriano/homebrew-drunkcase

gha_language: Ruby

repo_name: bbriano/homebrew-drunkcase


text:
---
title: "[자료구조] 03. ADTs Unsorted List and Sorted List"
layout: article
aside: false
sidebar: false
categories: [KyungHee Univ., C++, Data Structure]
license: false
show_subscribe: false
show_title: true
mathjax : true
---

### List Definitions
- __Linear relationship__ Each element except the first has a unique predecessor, and each element except the last has a unique successor.
- __Length__ The number of items in a list; the length can vary over time.
- __Unsorted list__ A list in which data items are placed in no particular order; the only relationship between data elements is the list predecessor and successor relationships.
- __Sorted list__ A list that is sorted by the value in the key; there is a semantic relationship among the keys of the items in the list.
- __Key__ The attributes that are used to determine
the logical order of the list.

선형성 관계를 가진다. 즉, 첫번째 요소를 제외한 모든 요소는 앞에 있는 요소가 하나이다.

어떠한 방식으로든 요소들 사이에 순서(관계)가 존재하는 경우 Sorted list라하고, 아닌 경우 Unsorted list라 한다.

Key는 리스트의 논리적 순서 결정에 기여한다.

### Sorted and Unsorted Lists
- Unsort List : Elements are placed into the list in no particular order.
- Sorted List : List elements are in an order that is sorted in some way -- either numerically or alphabetically by the elements themselves, or by a component of the element (called a __KEY__ member) .

### ADT List Operations
- Transformers
  - MakeEmpty
  - InsertItem
  - DeleteItem
- Observers
  - IsFull
  - LengthIs
  - RetrieveItem
- Iterators
  - ResetList
  - GetNextItem

### What is a Generic Data Type?
- A __generic data type__ is a type for which the operations are defined but the types of the items being manipulated are not defined.

One way to simulate such a type for our UnsortedList ADT is via a user-defined class __ItemType__ with member function __ComparedTo__ returning an __enumerated type__ value __LESS, GREATER, or EQUAL__.

generic data type을 통해 정의한 하나의 자료형에서만 동작하는 것이 아닌 자료형에 관계없이 대해서 동작이 가능하도록 해준다.

사용자가 정의한 ItemType를 비교했을 때 enumerated type인 LESS, CREATER 또는 EQUAL와 같은 값을 리턴.

### Class Constructor
- A special member function of a class that is __implicitly invoked__ when a class object is defined.

### Class Constructor Rules
-  A __constructor cannot return a function value__, and has no return value type.
- A __class may have several constructors__. The compiler chooses the appropriate constructor by the number and types of parameters used.
- __Constructor parameters__ are placed in a parameter list __in the declaration of the class object__.
- The __parameterless constructor is the default constructor__.
- If a class has at least one constructor, and __an array of class objects is declared, then one of the constructors must be the default constructor__, which is invoked for each element in the array.

### Class Interface Diagram
사진 13, 32, 33
제목 변경

### Member functions
- Which member function specifications and implementations must change to ensure that any instance of the Sorted List ADT remains sorted at all times?

Unsorted list에서 Sorted list로 바꿀 때 멤버함수 중 반드시 바뀌어야만 하는 함수는 InsertItem과 DeleteItem함수이다. 정렬이 되어 있어야 하기때문에.

### InsertItem algorithm for SortedList ADT
- Find proper location for the new element in the sorted list.
- Create space for the new element by __moving down__ all the list elements that will follow it.
- Put the new element in the list.
- Increment length.

중간에 요소를 넣기 위해 한칸씩 내려(moving down) 공간을 만든다.

### DeleteItem algorithm for SortedList ADT
- Find the location of the element to be deleted from the sorted list.
- Eliminate space occupied by the item being deleted by moving up all the list elements that follow it.
- Decrement length.

중간에 요소를 제거하기 위해 반대로 한칸씩 올려(moving up) 공간을 제거한다.

### Improving member function RetrieveItem
Recall that with the Unsorted List ADT we examined each list element beginning with info[ 0 ], until we either found a matching key, or we had examined all the elements in the Unsorted List.

길이가 n인 리스트에서 데이터를 찾기위해서 최대 n번을 비교해봐야한다. 이를 어떻게 개선할 수 있을까?

### Binary Search in a Sorted List
- __Examines the element in the middle of the array__. Is it the sought item? If so, stop searching. Is the middle element too small? Then start looking in second half of array. Is the middle element too large? Then begin looking in first half of the array.
- __Repeat the process in the half of the list__ that should be examined next.
- Stop when item is found, or when there is nowhere else to look and item has not been found.

2진 탐색을 이용.

계속해서 중간을 확인하여 반씩 범위를 좁혀나가며 데이터를 찾는다.

### Comparision of Algorithms
- When there are more than one algorithm that perform the same task, __how do we choose the best algorithm?__
  - The amount of work that the computer does
- Objective measures for efficiency
  - Execution time
  - Number of statements
  - Number of fundamental operations

동일한 일을 하는 서로 다른 알고리즘에서 어떻게 더 좋은 알고리즘을 고를 수 있을까?

### Order of Magnitude of a Function
The __order of magnitude__, or __Big-O notation__, of a function expresses the computing time of a problem as the term in a function that increases most rapidly relative to the size of a problem.

최악의 경우에 대하여 크기에 대하여 계산시간을 가장 급격하게 증가하게 만드는 부분의 계산시간을 나타내는 방식.

### Names of Orders of Magnitude
- O(1) : bounded (by a constant) time
- O($log_2 N$) : logarithmic time
- O(N) : linear time
- O($N log_2 N$) : $N log_2 N$ time
- O($N^2$) : quadratic time
- O($2^N$) : exponential time

### Big-O Comparision of List Operations
사진 53


text:
# Erlang bindings for NaCl

This library provides bindings for the NaCl cryptographic library for Erlang. Several such libraries exist, but this one is a re-write with a number of different requirements, and foci:

### INSTALL/Requirements:

* Erlang/OTP 17.3. This library *needs* the newest dirty scheduler implementation.
* *Requires* the libsodium library. *Note:* libsodium is not packaged in Debian/Ubuntu by default. You need to use something to handle the installation for you. E.g., `checkinstall` or `stow` are good tools for this. For other systems, consult your package manager on how to install the package. Make sure you also get "development" packages containing the header file `libsodium.h`.

To build the software execute:

	make

or

	rebar compile

### Features:

* Complete NaCl library, implementing all default functionality.
* Implements a small set of additional functionality from libsodium. Most notably access to a proper CSPRNG random source
* Tests created by aggressive use of Erlang QuickCheck.
* NaCl is a very fast cryptographic library. That is, crypto-operations runs quickly on modern CPUs, with ample security margins. This makes it highly useful on the server-side, where simultaneous concurrent load on the system means encryption can have a considerable overhead.

This package draws heavy inspiration from "erlang-nacl" by Tony Garnock-Jones, and started its life with a gently nod in that direction. However, it is a rewrite and it alters lots of code from Tony's original work.

In addition, I would like to thank Steve Vinoski, Rickard Green, and Sverker Eriksson for providing the Dirty Scheduler API in the first place.

# USING:

In general, consult the NaCl documentation at

	http://nacl.cr.yp.to

but also note that our interface has full Edoc documentation, generated by executing

	rebar doc

## Hints

In general, the primitives provided by NaCl are intermediate-level primitives. Rather than you having to select a cipher suite, it is selected for you, and primitives are provided at a higher level. However, their correct use is still needed in order to be secure:

* Always make sure you obey the scheme of *nonce* values. If you ever reuse a nonce, and an attacker figures this out, the system will leak the XOR difference of messages sent with the same nonce. Given enough guessing, this can in turn leak the encryption stream of bits and every message hereafter, sent on the same keypair combination and reusing that nonce, will be trivially breakable.
* Use the beforenm/afternm primitives if using the `box` public-key encryption scheme. Precomputing the Curve25519 operations yields much faster operation in practice for a stream. Consult the `enacl_timing:all/0` function in order to see how much faster it is for your system. The authors Core i7-4900MQ can process roughly 32 Kilobyte data on the stream in the time it takes to do the Curve25519 computations. While NaCl is *fast*, this can make it even faster in practice.
* Encrypting very large blocks of data, several megabytes for instance, is problematic for two reasons. First, while the library attempts to avoid being a memory hog, you need at least a from-space and a to-space for the data, meaning you need at least double the memory for the operation.   It is often better to build a framing scheme and encrypt data in smaller chunks, say 64 or 128 kilobytes at a time. In any case, it is important to measure. Especially for latency.
* The library should provide correct success type specifications. This means you can use the dialyzer on your code and get hints for incorrect usage of the library.
* Note that every "large" input to the library accepts `iodata()` rather than `binary()` data. The library itself will convert `iodata()` to binaries internally, so you don't have to do it at your end. It often yields simpler code since you can just build up an iolist of your data and shove it to the library. Key material, nonces and the like are generally *not* accepted as `iodata()` however but requires you to input binary data. This is a deliberate choice since most such material is not supposed to be broken up and constructed ever (except perhaps for the Nonce construction).
* The `enacl:randombytes/1` function provides portable access to the CSPRNG of your kernel. It is an *excellent* source of CSPRNG random data. If you need PRNG data with a seed for testing purposes, use the `random` module of Erlang or Kenji Rikitake's `sfmt` bindings instead. But do note these do not provide cryptographically secure random numbers. The other alternative is the `crypto` module, which are bindings to OpenSSL with all its blessings and/or curses.
* Beware of timing attacks against your code! A typical area is string comparison, where the comparator function exits early. In that case, an attacker can time the response in order to guess at how many bytes where matched. This in turn enables some attacks where you use a foreign system as an oracle in order to learn the structure of a string, breaking the cryptograhic system in the process.

# TODO

* Write simple correctness unit tests for the different NaCl primitives. This will verify the integrity towards the underlying NaCl system.

# Versions

### v0.14.0

* Add support for libsodiums `box_seal` functions (Amir Ghassemi Nasr)
* Add support for libsodiums `crypto_sign_detached` (Joel Stanley, Parnell Springmeyer)
* Switch the tag names to the form `0.14.0` rather than `v0.14.0`. For this release both tags are present, but
  from the next release on, it won't be the case.

### v0.13.0

* Quell warnings from the C code
* Add Ed 25519 utility API (Alexander Færøy)
* Add FreeBSD support for the NIF compilation (Ricardo Lanziano)

### v0.12.1

* Provide the `priv` directory for being able to properly build without manual intervention.

### v0.12.0

* Introduce an extension interface for various necessary extensions to the eNaCl system for handling the Tor network, thanks to Alexander Færøy (ahf).
* Introduce Curve25519 manipulations into the extension interface.
* Write (rudimentary) QuickCheck tests for the new interface, to verify its correctness.

### v0.11.0

* Introduce NIF layer beforenm/afternm calls.
* Introduce the API for precomputed keys (beforenm/afternm calls).
* Use test cases which tries to inject `iodata()` rather than binaries in all places where `iodata()` tend to be accepted.
* Fix type for `enacl:box_open/4`. The specification was wrong which results in errors in other applications using enacl.

### v0.10.2

Maintenance release. Fix some usability problems with the library.

* Do not compile the C NIF code if there are no dirty scheduler support in the Erlang system (Thanks to David N. Welton)
* Fix dialyzer warnings (Thanks Anthony Ramine)
* Fix a wrong call in the timing code. Luckily, this error has not affected anything as it has only replaced a verification call with one that does not verify. In practice, the timing is roughly the same for both, save for a small constant factor (Thanks to the dialyzer)
* Improve documentation around installation/building the software. Hopefully it is now more prominent (Thanks to David N. Welton)

### v0.10.1

This small patch-release provides tests for the `randombytes/1` function call, and optimizes EQC tests to make it easier to implement `largebinary`-support in EQC tests. The release also adds an (experimental) scrambling function for hiding the internal structure of counters. This is based on an enlarged TEA-cipher by Wheeler and Needham. It is neccessary for correct operation of the CurveCP implementation, which is why it is included in this library.

### v0.10.0

Ultra-late beta; tuning for the last couple of functions which could be nice to have. Added the function `randombytes/1` to obtain randombytes from the operating system. The system uses the "best" applicable (P)RNG on the target system:

* Windows: `RtlGenRandom()`
* OpenBSD, Bitrig: `arc4random()`
* Unix in general: `/dev/urandom`

Do note that on Linux and FreeBSD at the *least*, this is the best thing you can do. Relying on `/dev/random` is almost always wrong and gives no added security benefit. Key generation in NaCl relies on `/dev/urandom`. Go relies on `/dev/urandom`. It is about time Erlang does as well.

### v0.9.0

Ultra-late beta. Code probably works, but it requires some real-world use before it is deemed entirely stable.

Initial release.

# Overview

The NaCl cryptographic library provides a number of different cryptographic primitives. In the following, we split up the different generic primitives and explain them briefly.

*A note on Nonces:* The crypto API makes use of "cryptographic nonces", that is arbitrary numbers which are used only once. For these primitives to be secure it is important to consult the NaCl documentation on their choice. They are large values so generating them randomly ensures security, provided the random number generator uses a sufficiently large period. If you end up using, say, the nonce `7` every time in communication while using the same keys, then the security falls.

The reason you can pick the nonce values is because some uses are better off using a nonce-construction based on monotonically increasing numbers, while other uses do not. The advantage of a sequence is that it can be used to reject older messages in the stream and protect against replay attacks. So the correct use is up to the application in many cases.

## Public Key cryptography

This implements standard Public/Secret key cryptography. The implementation roughly consists of two major sections:

* *Authenticated encryption:* provides a `box` primitive which encrypts and then also authenticates a message. The reciever is only able to open the sealed box if they posses the secret key and the authentication from the sender is correct.
* *Signatures:* allows one party to sign a message (not encrypting it) so another party can verify the message has the right origin.

## Secret key cryptography

This implements cryptography where there is a shared secret key between parties.

* *Authenticated encryption:* provides a `secret box` primitive in which we can encrypt a message with a shared key `k`. The box also authenticates the message, so a message with an invalid key will be rejected as well. This protects against the application obtaining garbage data.
* *Encryption:* provides streams of bytes based on a Key and a Nonce. These streams can be used to `XOR` with a message to encrypt it. No authentication is provided. The API allows for the system to `XOR` the message for you while producing the stream.
* *Authentication:* Provides an implementation of a Message Authentication Code (MAC).
* *One Time Authentication:* Authenticate a message, but do so one-time. That is, a sender may *never* authenticate several messages under the same key. Otherwise an attacker can forge authenticators with enough time. The primitive is simpler and faster than the MAC authenticator however, so it is useful in some situations.

## Low-level functions

* *Hashing:* Cryptographically secure hashing
* *String comparison:* Implements guaranteed constant-time string comparisons to protect against timing attacks.

# Rationale

Doing crypto right in Erlang is not that easy. For one, the crypto system has to be rather fast, which rules out Erlang as the main vehicle. Second, cryptographic systems must be void of timing attacks. This mandates we write the code in a language where we can avoid such timing attacks, which leaves only C as a contender, more or less. The obvious way to handle this is by the use of NIF implementations, but most C code will run to its conclusion once set off for processing. This is a major problem for a system which needs to keep its latency in check. The solution taken by this library is to use the new Dirty Scheduler API of Erlang in order to provide a safe way to handle the long-running cryptographic processing. It keeps the cryptographic primitives on the dirty schedulers and thus it avoids the major problem.

Focus has first and foremost been on the correct use of dirty schedulers, without any regard for speed. The plan is to extend the underlying implementation, while keeping the API stable. We can precompute keys for some operations for instance, which will yield a speedup.

Also, while the standard `crypto` bindings in Erlang does a great job at providing cryptographic primitives, these are based on OpenSSL, which is known to be highly problematic in many ways. It is not as easy to use the OpenSSL library correctly as it is with these bindings. Rather than providing a low-level cipher suite, NaCl provides intermediate level primitives constructed as to protect the user against typical low-level cryptographic gotchas and problems.

## Scheduler handling

To avoid long running NIFs, the library switches to the use of dirty schedulers for large encryption tasks. The target is roughly set at 1/10th of the 1ms budget at 100μs. That is, we have a threshold set such that work taking more than roughly 100μs will invoke the dirty scheduler. We currently care much more about the *progress* of the system rather than the *precision*. We care that another Erlang process gets to use the core so one process is unable to monopolize the scheduler thread. On the other hand, the price that a process pays to use encryption is something we care less about. A process may get a free ride or it may get penalized more than it should if it invokes crypto-code.

We currently use measurements to obtain some rough figures on the reduction counts different operations take. You can run these measurements by invoking:

	enacl_timing:all().

The current "typical modern machine" is:

	Intel Core i7-4900QM

When running benchmarks, we warm the CPU a bit before conducting the benchmark. Also, the script `benchmark.sh` can be used (altered to your CPU type), to disable the powersave mode of CPUs in order to obtain realistic benchmarks. Do note nothing was done to get a realistic disable of Intel's Turbo Boost functionality and this is a one-core benchmark. The numbers given are used as an input to the reduction budget. If a task takes roughly 134μs we assume it costs `134*2` reductions.

I'm interested in machines for which the schedules end up being far off. That is, machines for which the current CPU schedule takes more than 250μs. This is especially interesting for virtual machines, and machines with ARM cores. If you are running on very slow machines, you may have to tune the reduction counts and threshold sizes to get good latency on the system.

# Testing

Every primitive has been stress-tested through the use of Erlang QuickCheck with both *positive* and *negative* testing. This has been used to check against memory leaks as well as correct invocation. Please report any error so we can extend the test cases to include a randomized test which captures the problem so we generically catch every problem in a given class of errors.

Positive and negative testing refers to Type I and Type II errors in statistical testing. This means false positives—given a *valid* input the function rejects it; as well as false negatives—given an *invalid* input the functions fails to reject that input.

The problem however, is that while we are testing the API level, we can't really test the strength of the cryptographic primitives. We can verify their correctness by trying different standard correctness tests for the primitives, verifying that the output matches the expected one given a specific input. But there is no way we can show that the cryptographic primitive has the strength we want. Thus, we opted to mostly test the API and its invocation for stability.

Also, in addition to correctness, testing the system like this makes sure we have no memory leaks as they will show themselves under the extensive QuickCheck test cases we run. It has been verified there are no leaks in the code.

repository: trifork/enacl

gha_language: Erlang

repo_name: trifork/enacl


text:
# _Sass Quiz Page_

![screenshot of page](img/screen-shot.png)

#### _Third CSS solo project for Epicodus, 12.2.2016_

#### By _**Larry Dean Tunseth II**_

## Description

_This website is a custom made quiz site. This project shows my skills with Sass. It is my third solo CSS project for Epicodus_

## Setup/Installation Requirements

* _Clone this repository_
* _Open an HTTP server in the cloned directory_
* _Repo Link: https://github.com/larrytun/Sass_Quiz-Page_

## Known Bugs

_No Known bugs_

## Support and contact details

_If you run into problems contact Larry Tunseth at<EMAIL_ADDRESS>
## Technologies Used

_Sass_
_HTML_
_CSS_
_GitHub_
_Git_

### License

*This software is licensed under the MIT license.*

Copyright (c) 2016 **_Larry Tunseth & Epicodus_**


text:
# How to push files to a (GitHub) remote repository

In this example, we will push a file to a remote repository.

After creating your GitHub repository, follow the steps below:

1. Open your favorite terminal application;
2. Create an empty folder;
3. Inside the created folder, type:

    ```
    git init
    ```

4. Create a file called README.md (see information about this file type
[here](https://help.github.com/articles/markdown-basics/));
5.  Add a remote (called "origin"):

```
git remote add origin https://github.com/YourGitHubUsername/YourGitHubRepo.git
```

Finally, push your local modifications to the remote repository:

```
git push -u origin master
```

You can optionally add a version tag to your commit by using:

```
git tag 0.1.0
git push origin master --tags
```

For more information about Git, take a look at
[Git Documentation](http://git-scm.com/doc).

repository: saulotoledo/GitCourse-GitSetup

repo_name: saulotoledo/GitCourse-GitSetup


text:
---
layout: post
title: Simultaneous Localization And Mapping
visible: 1
---

## Introduction
We want to solve the SLAM (Simultaneous Localization And Mapping) problem with detection of moving objects, but in this article, we are only going to consider a very simple detection of moving objects.

First, we are going to use a grid based representation of the map, for the static and dynamic enviroment. We are going to solve SLAM with the maximum likelihood method. Because we can't have the complete map, we are going to consider in the solutions only a local map that is updated incrementally. Then, we can calculate the location of the vehicle with a fast grid-based scanning method, and knowing the location we can update the local map. Once we have the map with the static information of the enviroment, we can calculate the dynamic information, by detecting the moving objects.

## Dataset
We are obtaining the dataset from <https://www.nuscenes.org/>. It contains LIDAR data, camera images, odometry information, ... But here, for now we are only going to use LIDAR data and odometry information of the vehicle.

### LIDAR
The first step is to get the LIDAR data for each timestep and clean up the data. We can get a list of detection points, which are 3D points in space. We need to first calibrate the data, which can be done easily because be can get the calibration quaternions from the same dataset and the translation vector. First, we rotate the points and then we translate them. The translation is easy, but to rotate a point given the quaternion numbers, we can build the rotation matrix and apply this rotation to the point. There is plenty of information on the internet on how to do this. For reference, this is the code to calculate the rotation matrix:

{% raw %}
```cpp
Quaternion(double* q) {
     double norm = 0;
     for (int i = 0; i < 4; i++) {
          q_[i] = q[i];
          norm += q[i] * q[i];
     }
     norm = sqrt(norm);
     for (int i = 0; i < 4; i++) {
          q_[i] /= norm;
     }

     double q_matrix[4][4] = {{q_[0], -q_[1], -q_[2], -q[3]},
                                        {q_[1],  q_[0], -q_[3],  q[2]},
                                        {q_[2],  q_[3],  q_[0], -q[1]},
                                        {q_[3], -q_[2],  q_[1],  q[0]}};
     double q_bar_matrix[4][4] = {{q_[0], -q_[1], -q_[2], -q[3]},
                                             {q_[1],  q_[0],  q_[3], -q[2]},
                                             {q_[2], -q_[3],  q_[0],  q[1]},
                                             {q_[3],  q_[2], -q_[1],  q[0]}};

     // Transpose q_bar_matrix.
     for (int i = 0; i < 4; i++) {
          for (int j = i + 1; j < 4; j++) {
               std::swap(q_bar_matrix[i][j], q_bar_matrix[j][i]);
          }
     }

     // Dot product.
     for (int i = 1; i < 4; i++) {
          for (int j = 1; j < 4; j++) {
               rotation_matrix_[i - 1][j - 1] = 0.0;
               for (int k = 0; k < 4; k++) {
                    rotation_matrix_[i-1][j-1] +=
                         q_matrix[i][k] * q_bar_matrix[k][j];
               }
          }
     }
}
```
{% endraw %}

Once we have the LIDAR data calibrated, we need to remove unnecessary points, which consists of, the detection points of the own vehicle, the detection points of the ground plane, when the LIDAR beams hit the ground. And we will also remove the points that are too far away, because they have low quality. The first point is easy, we can remove all points that are inside some polygon, or easier, that are at a distance smaller than, for example, 1.5 meters from the detector, is also a good approximation.

Removing the points on the ground is a little more complex. We are going to use the RANSAC algorithm to find the equation of the ground plane, and then we can remove all points that are on the ground.

#### Ransac

The algorithms is:
1. Define number of iterations. I use a fixed number, but in the literature you can find the formula:

     $$eps = 1 - forseeable\_support / point\_list.size$$

     $$N = round(\frac{log(1 - alpha) }{ log(1 - pow(1 - eps, 3))})$$
2. For each iteration, select 3 points randomly, and find the plane through those points.
3. Count the number of points inside the plane (the distance to the plane is less than a certain value)
4. Choose the plane which contains the maximum number of points, and has the less standra deviation.
5. Remove all points inside the best plane.

## Grid Based Bayesian Filtering

### Notation

Z: Perception Measurements
U: Vehicle Motion Measurements

X: Vehicle State
M: Static Objects
O: Moving Obkects

### Updating the Occupancy Probability

Bayesian filters are used to estimate quantities with sensor data. Sensor data only contains partial information, and the measurements are corrupted with noise. We use probabilistic state estimation methods to recover state variables.

When the sensor is Gaussian and the dynamics model is linear with Gaussian noise then the sequential Bayesian filtering algorithm leads to the known kalman Filter.

For non-linear and non-Gaussian situations, it exists the Extended Kalman Filter. The Unscented Kalman Filter has a higher accuracy.

To handle highly nonlinear and non-Gaussian models, particle filters are more accurate than Kalman-based methods.

This equation describes how to update the occupancy probability of a grid map given sensor inputs.

$$ P(m|x_{1:t},z_{1:t}) = \left[ 1 + \frac{1 -P(m|x_{t},z_{t}) }{P(m|x_{t},z_{t})}\cdot\frac{P(m)}{1-P(m)}\cdot \frac{1 -P(m|x_{1:t-1},z_{1:t-1}) }{P(m|x_{1:t-1},z_{1:t-1})} \right]^{-1}$$

The probability $P$ $P(m \| x_{1:t-1},z_{1:t-1})$ is the occupancy probability estimated previously from measurements in the past. So we need to know $P(m \|x_{t},z_{t})$ and $P(m)$. $P(m)$ is the prior occupancy probability of the grid map cell, which in an unknown state has a value of 0.5. $P(m \|x_{t},z_{t})$ expreses the probability that a single cell m is occupied based on a single sensor measurement $z_t$ at a location $x_t$.

We are going to assume the occupancy probability at a cell m is going to be independent for all sensor measurements.

In the case of a laser sensor, we are going to consider a laser beam. If the laser beam gives a distance l, then we need to update all the grid cells inside the beam less than a distance l from the origin of the beam as free, and the grid cell at a distance l, as occupied.

$$
 P(m|x_t,z_t) =
\left \{

\begin{array}{c l}
     P_{free} & |f(x_t,n,k)|< z_t^n \\
     P_{occ} & |f(x_t,n,k)| = z_t^n \\
     P_{prior} & otherwise
\end{array}

\right \}

$$

We will use $P_{free}=0.2$, $P_{occ}=0.8$.

$$ f(c_{occ}, c_{free}) = \frac{exp(c_{occ}P_{occ} + c_{free}R_{free})}{1 + exp(c_{occ}P_{occ} + c_{free}R_{free})} $$

## Grid-based Scan Matching

To update the occupancy grid map over time given laser measurements, we need to know the vehicle location.  However, to obtain a good vehicle localization we can't use odometry sensors, as the error would be too large. We are going to use the incremental maximum likelihood SLAM method.

The idea is to mantain a series of maximum likelihood maps, M1, M2, ... along a series of maximum likelihood vehicle poses x1, x2, ...

$$ \left< x_t, M_t \right> = argmax_{x_t,M_t} \left[ P(z_t|x_t,M_t)P(x_t,M_t|u_t,x_{t-1}, M_{t-1}) \right] $$

Since usually the map Mt is uniquely determined by the pose xt, it suffices to search the space of poses xt.

$$ \left< x_t, M_t \right> = argmax_{x_t} \left[ P(z_t|x_t,M_t)P(x_t,M_t|u_t,x_{t-1}) \right] $$

Here, $P(z_t \|x_t,M_t)$ is the probability of observing the most recent measurement $z_t$ given the pose $x_t$ and the map $M_{t-1}$ constructed so far. The term $P(x_t,M_t \|u_t,x_{t-1})$ is the probability that the vehicle is at location $x_t$ given that previously it was at position $x_{t-1}$.

### Dynamics model

In a two-dimensional space, the pose can be described by the position in the coordinate frame, along its angular orientation.

$$
\left (

\begin{array}{c l}
     x \\
     y \\
     \theta
\end{array}

\right )
$$

#### Probabilistic Kinematics

The model is

$$ P(x_t|u_t,x_{t-1}) $$

There are two types of models, velocity models and odometry models. The first model assumes that the motion data $u_t$ specifies the velocity commands. The second model assumes that we are provided with odometry information. Odometry models tend to be more accurate, because most robots don't execute velocity commands with the same level of accuracy that can be obtained by odometry, but this last one is only obtained after the fact, so it can't be used for motion planning. Odometry models are used for estimation and velocity models are used for probabilistic motion planning.

In this case we are going to use odometry models for this problem.

#### Algorithm motion_model_odometry

$$ \delta_{rot1} = atan2(\bar y'-\bar y, \bar x' - \bar x) - \bar \theta$$
$$ \delta_{trans} = \sqrt{ (\bar x - \bar x')^2 + (\bar y - \bar y')^2}$$
$$ \delta_{rot2} = \bar \theta' -  \bar \theta -\delta_{tor1} $$

$$ \hat \delta_{rot1} = atan2( y'- y,  x' -  x) - \bar \theta$$
$$ \hat \delta_{trans} = \sqrt{ ( x -  x')^2 + ( y -  y')^2}$$
$$ \hat \delta_{rot2} =  \theta' -   \theta -\delta_{tor1} $$

$$ p1 = prob(\delta_{rot1} - \hat \delta_{rot1}, \alpha_1 \hat \delta_{rot1} + \alpha_2 \hat \delta _{trans})$$

$$ p2 = prob(\delta_{trans} - \hat \delta_{trans}, \alpha_3 \hat \delta_{trans} + \alpha_4 (\hat \delta _{rot1} + \hat \delta _{rot2}))$$

$$ p3 = prob(\delta_{rot2} - \hat \delta_{rot2}, \alpha_1 \hat \delta_{rot2} + \alpha_2 \hat \delta _{trans})$$

$$ return \; p1 \cdot p2 \cdot p3$$

Where $\bar x_{t-1} = (\bar x, \bar y, \bar \theta)$ and $\bar x_{t} = (\bar x', \bar y', \bar \theta')$ are taken from the odometry.

The motion information is given by the pair

$$
u_t = \left (

\begin{array}{c l}
     \bar x_{t-1} \\
     \bar x_t \\
\end{array}

\right )
$$

#### Algorithm sample_motion_model_odometry

$$ \delta_{rot1} = atan2(\bar y'-\bar y, \bar x' - \bar x) - \bar \theta$$
$$ \delta_{trans} = \sqrt{ (\bar x - \bar x')^2 + (\bar y - \bar y')^2}$$
$$ \delta_{rot2} = \bar \theta' -  \bar \theta -\delta_{tor1} $$

$$ \hat \delta_{rot1} = \delta_{rot1} - sample(\alpha_1\delta_{rot1} + \alpha_2\delta_{trans})$$
$$ \hat \delta_{trans} = \delta_{trans} - sample( \alpha_3 \hat \delta_{trans} + \alpha_4 (\hat \delta _{rot1} + \hat \delta _{rot2}))$$
$$ \hat \delta_{rot2} =  \delta_{rot2} - sample(\alpha_1 \hat \delta_{rot2} + \alpha_2 \hat \delta _{trans})) $$

$$ x' = x + \hat \delta_{trans}\cos({\theta + \hat \delta_{rot1}})$$
$$ y' = y + \hat \delta_{trans}\sin({\theta + \hat \delta_{rot1}})$$
$$ \theta' = \theta + \hat \delta_{rot1} + \hat \delta_{rot2} $$

$$return \; x_t = (x', y', \theta ')^T$$

The outcome of $\delta_{rot2} - \hat \delta_{rot2}$ must be truncated to lie in $[-\pi,\pi]$

The function $prob(a,b)$ implements an error distribution over a with zero mean and variance b.

The sample function is a random number generator according to a gaussian distribution with mean 0 and variance b.
We show two possible implementations to get a normal function using a uniform distribution random number generator:

sample(b) = $\frac{b}{6}\sum_{i=1}^{12} rand(-1, 1)$

sample(b) = $b\cdot rand(-1, 1)\cdot rand(-1, 1)$

And prob(a, b) computes the probability of its arguments a under a zero-centered distribution with variance b.

* From Probabilistic Robotics, Sebastian Thrun, Wolfram Burgard, Dieter Fox, 2005

## Probability of Scan Measurement Given Vehicle Pose

Now, for each of the predictions of the localitation of the vehicle we need to calculate the probability of the scan measurement given that vehicle pose. The formula is:

$$ P(z_t|x_t,M_{t-1}) ~ \sum_{n=1}^{N}{P(M_{t-1}^{hit_t^n}) such that M_{t-1}{hit_t^n} is occupied}$$

And we will use the pose that maximizes the previous probability.

## Update Map

Once we know the location of the vehicle, we can update the values of the occupancy probabilities of the local map using the formulas we have defined earlier. But, what happens we the position is outside this local map? We need to create a new local map, that we will make so it overlaps slightly with the current one. With this, we will have a list of local map, that overlaps with each other, and will call this list the global map. We don't create a new local map when the localtion of the vehicle is outside the current maps, but when it is in the border.

For each iteration, we won't update only one map, but all of the local maps that contain the position of the vehicles. We do this to help mantain a coherent global map, and close the loop if we return to the same place. So for each iteration, we look over the list of local maps, and find every relevant one that we need to use to calculate the likelihood probability, and that we will need to update.

# Moving Object Detection

There are both static and dynamic objects that we will detect in the map with the previous approach. Moving objects in the mapping process will decrease the quality of the constructed map, so we need to detect these moving objects and differentiate them from the static objects.

The principal idea we are going to follow is that, if we detect an object in a space that was free previously, we are quite certain that it is a moving object. If we detect it in a occupied space, then it's probably a static object. On the other hand, if we detect an object in a previously unknown space, we can't say anything about it.

Another idea we can use is, if there is some space where there are frequently moving objects, we can use this information to improve our detection of dynamics objects. For this, we are going to define a new map, dynamic map, that is going to contain information about previously found dynamic objects. The dynamic map contains the number of observations that a dynamic object has been detected at that cell.

The first step is, given the dynamic map, static map, and measurements, decide the state of each grid, if it is free or occupied by a static or dynamic object:

$$
 state(z^n) =
\left \{

\begin{array}{c l}
     static & :M_{hit^n}=occupied \\
     dynamic & :M_{hit^n}= free \ or \ D_{hit^n} > \alpha \\
     unknown & :M_{hit^n}=unknown
\end{array}

\right \}

$$

The second state is, after determining the dynamic measurements, clustering the objects into separate groups. Two points are considered to belong to the same object if the distance is less than 0.3m.

Measurements detected to be from dynamic objects are not used to update the map in SLAM. For unknown measurements, we will first assume to be static objects until we find latter evidence.


text:
Webcam recording app that is supposed to enable users to choose from the library of webcam
shaders on shadertoy.com (at some point).

## Development notes

Note that running `start:dev` requires a cert.pfx (a certificate without password) in the root
directory. (See e.g. [here](https://github.com/webpack/webpack-dev-server/pull/1425/files) for how to
create them)

## Notes on architecture

- Web workers enable processing of the recording in separate threads
- Due to the size of ffmpeg, preloading and compression was very important

## Notes on browsers

- Chrome has a [Texture upload bug](https://bugs.chromium.org/p/chromium/issues/detail?id=92388) that
makes the app very slow on machines that use IGPs.

## TODO

- Will probably have to convert this into an Electron app. Keeping more than 5 Minutes of HD footage in RAM doesn't make browsers happy (MB
are webm video file sizes, not RAM use):

#### Chrome
Works: 4 minutes, 82 MB
Tab crash @ 100 MB / 4m8s of processed video

#### Firefox
Works: 3:30 minutes, 140 MB
ffmpeg reports "out of memory" @ 278 MB / 6m34s of video

- Actually make shaders from shadertoy available...

- Check whether pathetic frame rates mostly stem from capturing streams. I can't do anything about
that but at least then I know that IF maybe stream capturing ran on a different thread (web workers
won't work - no access to DOM), performance would be better. (GPU scores as per passmark)

#### i7-2600K @ 4.8 Ghz (7970 GHz Edition - 5248)
CH: 1280x720@30fps // 60 fps (Microsoft HD-3000)
FF: 1280x720@29fps // 60 fps (DroidCam)

#### i5-4440 (GPU 711), Logitech C270
FF: 1280x960@30fps // ~30 fps

#### Celeron G3900T (GPU 616), Microsoft HD-3000
FF: 1280x720@30fps // ~30 fps (50-60 when not doing stream capturing)
CH: 1280x720@30fps // ~24 fps ([Texture upload bug](https://bugs.chromium.org/p/chromium/issues/detail?id=92388))

#### Samsung S7
FF: 1920x1080@30fps // ~10 fps
CH: 1920x1080@30fps // ~4 fps

repository: s-h-a-d-o-w/shadertoy-webcam-recorder

gha_language: JavaScript

repo_name: s-h-a-d-o-w/shadertoy-webcam-recorder


text:
# Assignment 1
## Description

This assignmebt was given from **STIN2024 -Logic Programmins** as Assignemnet 1 from the series of Assignments. We were asked to
build a small program to translate list of English words into Malay and vice versa. For this, first, I created list of facts which
consists of 19 english words with its meaning in Malay. Then I created 2 rules to simulate the program.

**The first rule:**
```prolog
translate(Malay, English):-
means(Malay, English).

```
translates Malay words to english. You can test this by simply typing "translate(any malay word from the list of 19 words, X ).

### Example
```
translate(makan, X).
```
![image](https://user-images.githubusercontent.com/33327894/36486332-3c14594c-1759-11e8-87f2-3da3caf2b9c0.png)

**The second rule:**

```prolog
translate(Malay, English):-
means(English, Malay).
```
translates English words to Malay. You can test this by simply typing "translate(any english word from the list of 19 words, X ).

![image](https://user-images.githubusercontent.com/33327894/36488405-56eeb118-175e-11e8-94ac-124dca36e7db.png)

*If you have other solutions, suggestions or feedbacks you are welcome to comment*

repository: narzullaev/Prolog-

gha_language: Prolog

repo_name: narzullaev/Prolog-