text:
Part One: [About xAPI Profiles](./xapi-profiles-about.md#partone)
   *  1.0. [Introduction](./xapi-profiles-about.md#introduction-partone)
   *  2.0. [How to Use This Document](./xapi-profiles-about.md#2.0)
      *  2.1. [MUST / SHOULD / MAY](./xapi-profiles-about.md#def-must-should-may)
      *  2.2. [Guidelines for Interpreting Descriptive Text and Tables]./xapi-profiles-about.md#interpret-text-table)
   *  3.0. [Definitions](./xapi-profiles-about.md#definitions)
Part Two:	[xAPI Profiles Document Structure Specification](./xapi-profiles-structure.md#parttwo)
   *	1.0.	[Reference Specifications](./xapi-profiles-structure#1.0)
   *	2.0.	[Technical Foundations](./xapi-profiles-structure#2.0)
   *  3.0.  [Structure](./xapi-profiles-structure#3.0)
   *  4.0.  [Document Interpretation and General Restrictions](./xapi-profiles-structure.md#4.0)
   *  5.0.  [Using Profiles in Statements](./xapi-profiles-structure.md#5.0)
   *  6.0.  [Profile Properties](./xapi-profiles-structure.md#6.0)
      *  6.1.  [Profile Version Objects](./xapi-profiles-structure.md#6.1)
      *  6.2.  [Organizations and Persons](./xapi-profiles-structure.md#6.2)
   *  7.0.  [Concepts](./xapi-profiles-structure.md#7.0)
      *  7.1.  [Verbs, Activity Types, and Attachment Usage Types](./xapi-profiles-structure.md#7.1)
      *  7.2.  [Extensions](./xapi-profiles-structure.md#7.2)
      *  7.3.  [Document Resources](./xapi-profiles-structure.md#7.3)
      *  7.4.  [Activities](./xapi-profiles-structure.md#7.4)
   *  8.0.  [Statement Templates](./xapi-profiles-structure.md#8.0)
      *  8.1.  [Statement Template Rules](./xapi-profiles-structure.md#8.1)
   *  9.0.  [Patterns](./xapi-profiles-structure.md#9.0)
   *  10.0. [The Context](./xapi-profiles-structure.md#10.0)
Part Three:	[xAPI Profiles Communication and Processing Specification](./xapi-profiles-communication.md#partthree)
 * 1.0. [Profile Server](./xapi-profiles-communication#1.0)
    * 1.1. [Profile Versions](./xapi-profiles-communication#profile_versions)
    * 1.2. [Best Practices](xapi-profiles-communication#profile_server_best_practices)
    * 1.3. [Example SPARQL Queries](xapi-profiles-communication#1.3)
 * 2.0. [Algorithms](./xapi-profiles-communication#2.0)
    * 2.1. [Statement Template Validation](./xapi-profiles-communication#2.1)
    * 2.2. [Pattern Validation](./xapi-profiles-communication#2.2)
 * 3.0. [Libraries](./xapi-profiles-communication#3.0)

# Part Three: Communication and Processing

In addition to the ability to host Profiles as documents, there will be infrastructure
for querying and manipulating Profiles. This document describes the algorithms for
processing Profiles, including the exact rules by which Statement Templates and Patterns
are validated against Statements. It also describes a “Profile Server” to make it easier
to manage and answer questions about Profiles from a centralized location, including
implementing the algorithms.

## 1.0 Profile Server

A Profile Server manages xAPI Profiles from a centralized location. [An RDF triple store](https://en.wikipedia.org/wiki/Triplestore) is responsible for the storage of Profiles.
A Profile Server will allow administrators to add Profiles by their contents or by URI to the Profile Server

A Profile Server will host a SPARQL endpoint containing the RDF information from the
contained Profiles at the path /sparql. This enables xAPI Profiles to be queried. SPARQL
servers have the ability to divide information into multiple datasets, or graphs, and
offer separate querying on them. One of these is the default graph, which is queried
when no other graph is specified. The default graph at this SPARQL endpoint will
contain all the current versions of Profiles.

### 1.1 Profile Versions

Every Profile version will be in a [Named Graph](https://www.w3.org/TR/sparql11-query/#namedGraphs)
with a URI equal to the Profile version's URI.  Non-current (and current) versions of
Profiles are required to be in named graphs with URIs of their version.  This means
they can be queried directly by specifying the URI. Additionally, the current version
in the default graph has the versioning information, making it possible to traverse
them without knowing their URIs in advance. Reasons why one would query versions
of xAPI Profiles include retrieving a version used by an xAPI Statement, and/or
understanding when a concept was deprecated or removed.

The URI of the named graph is always the URI of the Profile version. Note: The URI of the
named graph doesn't mean the URI it is retrieved at, it means the URI used to refer to it
within SPARQL/the RDF store.

In summary: by default, queries will only operate on up to date
information; if historical Profile information is needed, it is available.

### 1.2 Best Practices

Some best practices are recomended when adding a Profile to a Profile Server. A technical
review process is warranted to check Profiles for following the specification. As well,
analysis is recommended to ensure the contents of a Profile are of the highest quality.
Upon following these practices, a Profile should be added to a Profile server.

As Profiles support localizations to multiple languages and localities, it is advisable to
provide mechanisms to encourage contribution of xAPI Profile translations. To promote and
to protect the use of an xAPI Profile made publicly available, it is strongly encouraged
that any xAPI Profile provided through a Profile Server be open-licensed.

### 1.3 Example SPARQL Queries

Here are a selection of questions and the SPARQL queries that answer them, for retrieving
commonly needed information from the server. All these SPARQL queries can also be run
locally by loading one or more Profiles into an RDF library and running SPARQL queries
against them directly, with minor modifications depending on how the data is loaded.

All queries start with the following block of prefixes:

```sparql
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xapi: <https://w3id.org/xapi/ontology#>
PREFIX profile: <https://w3id.org/xapi/profiles/ontology#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX schemaorg: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
```

“What profiles are on the server?”

```sparql
select
    ?profile,
    ?prefLabel,
    ?definition
where {
    ?profile a profile:Profile ;
             skos:prefLabel ?prefLabel ;
             skos:definition ?definition .
}
```

Depending on some modeling choices, it may be necessary to add a line that prevents
retrieving the versions as well.

“What verbs and activity types does this Profile describe?”

```sparql
select
    ?concept,
    ?prefLabel,
    ?definition
where {
    (?concept a xapi:Verb || ?concept a xapi:ActivityType) .
    ?concept skos:inScheme <http://example.org/profiles/sports> ;
             skos:prefLabel ?prefLabel ;
             skos:definition ?definition .
}
```

“What Statement Templates are available in this Profile?”, “What Patterns are available
in this Profile?”

Virtually identical to the above, just replace being a Verb or Activity Type with Statement
Template or Pattern. We're able to use inScheme because the server includes semantic
metadata letting it know that being a Statement Template, being a Concept, and being a
Pattern are all forms of being inScheme, which is a general inclusion predicate.

## 2.0 Algorithms

This section specifies two primary algorithms. The first, given a Statement and a set of
Statement Templates, validates the Statement against all applicable Statement Templates in
those provided and returns the Statement Templates that match, or an error if any of the
matching Statement Templates does not validate against the Statement. The second, given a
collection of Statements and a set of Patterns, validates if the Statements follows any of
the Patterns.

### 2.1 Statement Template Validation

To validate a Statement against the Statement Templates of a Profile, call the `validates`
function described in pseudocode below with the Statement and all the Statement Templates
from the Profile. This function returns an outcome and an array of Statement Templates. To
interpret the results, consult the table after the algorithm definition.

```
function validates(statement, templates):
    matching_templates = []
    failing_templates = []
    outcome = success
    for template in templates:
        if matches_determining_properties(statement, template):
            if follows_rules(statement, template):
                matching_templates.append(template.id)
            else:
                outcome = invalid
                failing_templates.append(template.id)
    if outcome is success:
        if length of matching_templates > 0:
            return success, matching_templates
        else:
            return unmatched, []
    else:
        return invalid, failing_templates

function follows_rules(statement, template):
    if template.objectStatementRefTemplate is specified:
        if statement.object is a StatementRef:
            if a Statement with id == statement.object.id is available to the checking system:
                if validates(that other statement, templates)[1] does not intersect with template.objectStatementRefTemplate:
                    return false
        else:
            return false
    if template.contextStatementRefTemplate is specified:
        if statement.context.statement is a StatementRef:
            if a Statement with id == statement.context.statement.id is available to the checking system:
                if validates(that other statement, templates)[1] does not intersect with template.contextStatementRefTemplate:
                    return false
        else:
            return false
    for rule in template.rules:
        if follows_rule(statement, rule):
            continue
        else:
            return false
    return true

function matches_determining_properties(statement, template):
    for each specified Determining Property in the template:
        if the corresponding Statement locations equal or are a superset of that Determining Properties values:
            continue
        else:
            return false
    return true

function follows_rule(statement, rule):
    strict = true
    values = apply_jsonpath(statement, rule.location)
    if rule.selector:
        originals = values
        values = []
        for value in originals:
            selection = apply_jsonpath(value, rule.selector)
            if selection is empty:
                values.append(UNMATCHABLE)
            else:
                values = values concatenated with selection
    if rule.presence is specified:
        if rule.presence is "included":
            if values contains UNMATCHABLE:
                return false
            if values is empty:
                return false
        if rule.presence is "excluded":
            if values is not empty and any members are not UNMATCHABLE:
                return false
        if rule.presence is "recommended":
            strict = false
    if rule.any is specified:
        if strict or values is not empty:
            if values does not intersect with rule.any:
                return false
    if rule.all is specified:
        if strict or values is not empty:
            if values contains UNMATCHABLE:
                return false
            for value in values:
                if rule.all does not contain value:
                    return false
    if rule.none is specified:
        if strict or values is not empty:
            for value in values:
                if rule.none contains value:
                    return false

function apply_jsonpath(statement, path):
    The definition of this is beyond the scope of this document, but it follows
    the JSONPath specification as constrained by the requirements in this
    specification. If a single value is found in the Statement matching the
    path, it is returned in an array (even if the single value is already an array). If
    multiple values are found, they are returned in an array.
    If no values are found, an empty array is returned.
```

This table summarizes the possible return values of `validates` and what they indicate.

outcome   | templates | outcome
--------- | --------- | -------
success   | non empty | one or more Statement Templates matched and all their rules are followed. The templates array contains all matched Statement Templates.
invalid   | non empty | one or more Statement Templates matched but not all their rules were followed. The templates array contains all Statement Templates that matched but had some rules unfollowed.
unmatched | empty     | no Statement Templates matched

### 2.2 Pattern Validation

To validate a series of Statements sharing a registration (and, if applicable, subregistration)
follows a specified Profile, apply the `follows` algorithm described below, which returns
simple success or failure. For more nuanced interpretation, examine the `matches` algorithm,
which is used by `follows`. A table for interpreting the return values of the `matches`
algorithm is provided following the pseudocode for the algorithms.

```

function follows(statements, templates, patterns):
    for statement in statements:
        outcome, templates = validates(statement, templates)
        if outcome is not success:
            return failure
        statement.templates = templates
    for pattern in patterns:
        outcome, remaining = matches(statements, pattern)
        if outcome is success and remaining is empty:
            return success
    return failure

function matches(statements, element):
    if element is a template:
        if statements is empty:
            return partial, []
        if statements[0].templates includes element:
            return success, statements[1:]
        else:
            return failure, statements
    else if element is a sequence:
        next statements = statements
        for next element in element.sequence:
            next matches, next statements = matches(next statements, next element)
            if next matches is failure:
                return failure, statements
            if next matches is partial:
                return partial, []
        return success, next statements
    else if element is a alternates:
        next matches, next statements = failure, statements
        for next element in element.alternates:
            maybe matches, maybe statements = matches(statements, next element)
            if maybe matches is success:
                next matches = success
                if maybe statements is shorter than next statements:
                    next statements = maybe statements
            if maybe matches is partial and next matches is failure:
                next_matches = partial
        if next_matches is partial:
            return partial, []
        return next matches, next statements
    else if element is a oneOrMore:
        next matches = failure
        last statements = next statements = statements
        while true:
            continue, next statements = matches(last statements, element.oneOrMore)
            if continue is success:
                next matches = success
            else if next matches is failure and continue is partial:
                return partial, []
            else:
                if continue is partial and last statements is not empty:
                    return partial, last statements
                return next matches, last statements
            if next statements is the same size as last statements:
                return success, next statements
            last statements = next statements
    else if element is a zeroOrMore:
        last statements = statements
        while true:
            continue, statements = matches(last statements, element.zeroOrMore)
            if continue is failure:
                return success, last statements
            if continue is partial and statements is not empty:
                return partial, statements
            if statements is the same size as last statements:
                return success, statements
            last statements = statements
    else if element is a optional:
        if statements is empty:
            return success, []
        next matches, next statements = matches(statements, element.optional)
        if next matches is success or partial:
            return next matches, next statements
        else:
            return success, statements
```

This table summarizes the possible return values of `matches` and what they indicate:

outcome | remaining statements | outcome
------- | -------------------- | -------
success | empty                | Pattern validates for these Statements
success | non empty            | Pattern matches some of the Statements, but not all
partial | empty                | Pattern was in the middle of matching and ran out of Statements
partial | non empty            | outcome could be interpreted as success with non empty remaining, but Pattern could also continue matching
failure | original statements  | Pattern failed to match Statements. Note: if an optional or zeroOrMore Pattern is directly inside an alternates Pattern, it is possible for failure to be returned when partial is correct, due to decidability issues.

A Pattern only matches if it matches greedily. That is, each optional, zeroOrMore, oneOrMore,
and alternate Pattern MUST always be considered to match the maximum length possible before
considering any Patterns later in a sequence. No backtracking is allowed. This constrains
useful Patterns, but guarantees efficient processing, as once a Statement is matched it does
not need to be reconsidered (except in cases where it is part of an ultimately unmatched
alternate).

When checking previously collected Statements for matching a Pattern, ordering MUST be based
on timestamp. In the event two or more Statements have identical timestamps, any order within
those Statements is allowed.

When checking Statements for matching a Pattern upon receipt, ordering MUST be based on receipt
order insofar as that can be determined. If Statements are received in the same batch and they
are being checked upon receipt, within the batch Statements MUST be ordered first by timestamp,
and if timestamps are the same, by order within the Statement array, with lower indices earlier.

## 3.0 Libraries

Any programming library that implements the algorithms given here, exposing all of the listed
functions, will be an xAPI Profile Processor library.

For each of the `validates`, and `follows`, the Profile Server will provide web APIs that are
strongly Not Recommended for production usage, but are suitable for experimentation and
demonstration. Code on the critical path (such as validating Statements against Profiles on LRS
intake), or that might be used when internet access is not available (such as when using an
authoring tool), should not use these APIs, and should use their own code or an xAPI Profile
Processor Library as appropriate.

Additionally, the pseudocode above isn't written to support processing as data is received,
as that both adds complication and needs to be adapted to the exact capabilities of the
implementing system.

Their URL paths will be /validate_templates and /validate_patterns, respectively. The first
will take a single xAPI Statement and a Profile specified by id, specified in POST variables
as “statement” and “profile”. The second will take an array of xAPI Statements and a Profile
specified by id, both specified in POST variables as “statements” and “profile”.

Both will perform the algorithms above and return 204 on successful validation and 400 on
failure, with descriptive comments that provide information as to which rule was violated (in
the case of statement template processing) or which part of the pattern was violated (in the
case of pattern processing.


text:
# Hashmap

## Java

hashtable thread secure

hashmap = arr +  linked-list(red black tree > 8)
hashmap double hash key(hashtable one time hash)

load factor: 0.75, double the size if bigger than it

linked list ->8(6<-) red black tree (in case of threshing)

[TODO] red black tree

## Cpp

map: black-red tree (logN)
unordered_map: hashtable(bucket(arr) + linked-list) (1 - n)

repository: wfnuser/CruelFundamental

branch_name: refs/heads/main

extension: md

license_type: permissive

repo_name: wfnuser/CruelFundamental


text:
Follow the steps below to start the project:
 - Download Expo Client (ios) / Expo (android) on your mobile device

 In terminal
 - npm install expo-cli --global
 - cd GetSchooled/
 - yarn
 - expo start

 Documentation on Expo
 https://docs.expo.io/versions/latest/get-started/installation/?redirected

license: MIT

branch_name: refs/heads/master


text:
# Random Forest notes

Below are the parameters which we need to pay attention to when we are building a new model:

- `n_estimators` — the number of trees in the forest;
- `criterion` — the function used to measure the quality of a split;
- `max_features` — the number of features to consider when looking for the best split;
- `min_samples_leaf` — the minimum number of samples required to be at a leaf node;
- `max_depth` — the maximum depth of the tree.

# Rules of thumb

While building decision trees using Random Forest, for each split, we first randomly pick $m$ features from the $d$ original ones and then search for the next best split only among the subset.

For classification problems, it is advisable to set $m = \sqrt{d}$. For regression problems, we usually take $m = \frac{d}{3}$, where $d$ is the number of features.

It is recommended to build each tree until all of its leaves contain only $n_{min}=1$ examples for classification and $n_{min}=5$ examples for regression.

```python
import pandas as pd
from sklearn.model_selection import cross_val_score, StratifiedKFold, GridSearchCV
from sklearn.metrics import accuracy_score

# Initialize a stratified split of our dataset for the validation process
skf = StratifiedKFold(n_splits=5, shuffle=True)

# Initialize the classifier with the default parameters
rfc = RandomForestClassifier(n_jobs=-1, oob_score=True)

# Train it on the training set
results = cross_val_score(rfc, X, y, cv=skf)

# Evaluate the accuracy on the test set
print(f"CV accuracy score: {results.mean()*100}".)
```


text:
---
layout: post
title: CSAW QUALS 2016 - WTF.SH [WEB]
author: pimps
tags: [ctf, csaw, web, burp, bash]
---

 * Competition: CSAW 2016
 * Challenge Name: WTF.SH
 * Type: Web
 * Points: flag1 (150 pts) + flag2 (400 pts)
 * URL: http://web.chal.csaw.io:8001/

I would like to start this write-up saying that this web challenge is one of the coolest and best web challenges that I have ever played in a CTF...  **Srly... WTF!?!?** I Guess this is why he gave this name to the challenge :-P (hahahaha).
 * It's different from the usual web challenges that we see around in other competitions, even though the first main bug was a path traversal/LFI the context where it was applied, at least for me, was completely new.
 * To solve this challenge you had to think and learn the behaviours of the bash script language. . For me this was the cherry on the cake in this challenge.

After finishing the challenge, just to satisfy my curiosity, I went to the IRC channel of the competition just to ask _Hyper_ how long it took to come up with this challenge. He answered me: "Well, let me see... I guess it was around 4 months working 1-2h per day"... So for that I want to say thanks to the CSAW team and mad props to _Hyper_ for coming up with this challenge.

Ok... With that said now lets get to the business:

## Flag 1

```
================================================
$ man 1 wtf.sh
WTF.SH(1)               Quals               WTF.SH(1)

NAME
       wtf.sh - A webserver written in bash

SYNOPSIS
       wtf.sh port

DESCRIPTION
       wtf.sh is a webserver written in bash.
       Do I need to say more?

FLAG
       You can get the flag to this first part of the
       problem by getting  the  website  to  run  the
       get_flag1  command. I heard the admin likes to
       launch it when he visits his own profile.

ACCESS
       You can find wtf.sh at http://web.chal.csaw.io:8001/

AUTHOR
       Written  by  _Hyper_  http://github.com/Hypersonic/

SUPERHERO ORIGIN STORY
       I have deep-rooted problems
       That  involve  childhood  trauma  of  too many
       shells
       It was ksh, zsh, bash, dash
       They just never stopped
       On that day I swore I would have vengeance
       I became
       The Bashman

REPORTING BUGS
       Report  your  favorite  bugs  in   wtf.sh   at
       http://ctf.csaw.io

SEE ALSO
       wtf.sh(2)

CSAW 2016           September 2016          WTF.SH(1)
================================================
```

The description says that wtf.sh is a web server written in bash and to get the flag1 we should run the command get_flag1. The description also says that the admin user runs this command when he visits his own profile. My first thought was to exploit a XSS vulnerability in order to session hijack the admin user. I actually managed to find a XSS bug in this challenge registering a username as an XSS payload. But after some minutes I realized that this isn't the objective of this challenge.

So, after some time the first bug that I found in the app was the source code leak of the main script wtf.sh by visiting http://web.chal.csaw.io:8001/wtf.sh. This can be seen in the following image:

![Source Code Leaking](http://image.prntscr.com/image/6a19a6f49e894667bb7b11f5bbbdea0d.png)

Reading the source code we spotted that a functionality to create the sandboxes leaked the name of the other files:

```bash
[... code snip ...]

# if we know the IP (via an X-Forwarded-For header), stick the user in a sandbox
# (Cloudflare will fill in this IP in prod, we can also have nginx fill it in in dev if we want)
if contains "X-Forwarded-For" "${!HTTP_HEADERS[@]}"
then
sandbox_dir="$((cksum <<< ${HTTP_HEADERS["X-Forwarded-For"]}) | cut -d\ -f1).sandbox";
# create sandbox if it doesn't exist
if [[ ! -e "${sandbox_dir}" ]]
then
mkdir "${sandbox_dir}";
# copy anything that isn't itself a sandbox to the dir
cp -R css index.wtf lib.sh login.wtf logout.wtf new_post.wtf new_user.wtf post.wtf post_functions.sh posts profile.wtf reply.wtf spinup.sh user_functions.sh users users_lookup wtf.sh "${sandbox_dir}";
fi
cd "${sandbox_dir}";
else
log "WARNING: Not sandboxing: no X-Forwarded-For header found!"
fi

[... code snip ...]
```

Using this information we are able to get the source code of all *.sh files. However we could not get the *.wtf files because they are parsed by the wtf.sh web server. I'll not paste the source code of the whole challenge here to keep this write-up clean, but Hyper already uploaded it to his GitHub account and you can read all the source from there. I'll only post here code snippets of important parts to solve the challenge.

After reading the source code we understood how the application works. Basically it create files to represent users and posts. The files generated to represent users are created inside of the {web_root}/users/ directory and the post files inside of the {web_root}/posts/ directory. So, fuzzing the parameters of the app that access users and posts files we found 2 path traversal vulnerabilities. The first one was in http://web.chal.csaw.io:8001/profile.wtf?user=../../../../../../etc/passwd but it only leaks the first line of the included file as shown in the following image:

![LFI via path traversal](http://image.prntscr.com/image/87d5a78cae8f4844bb9616781c2d406c.png)

And the second one was in http://web.chal.csaw.io:8001/post.wtf?post=../ Which leaks the full content of all files inside of the included directory as shown in the following image:

![LFI via path traversal 2](http://image.prntscr.com/image/d0d10cceff2b40f4852bfaaeb8ba2510.png)

Using the second LFI/Path Traversal bug we were able to leak the source code of all `*.wtf` files inside of the web root directory as well as other directories on the server (ex: /etc, /usr/bin, etc...).

Since we already knew that the app creates the user files inside of the `{web_root}/users` directory, using the second vulnerability we just injected the path /../users to force the application into getting the contents of the user's files as shown in the following image:

![User sessions and password hashes](http://image.prntscr.com/image/85cc2a74663b4159a7b1cbe963cae212.png)

Using this information, the next step was to perform the usual session hijacking attack to impersonate the admin user and get the first flag. This is shown in the following screenshots:

![Change session cookie](http://image.prntscr.com/image/2bb0eb863ed84002a34e4aa053fd94a6.png)

![Session Hijacked and getting first flag](http://image.prntscr.com/image/2601a496c9d84778a16736ea5f78cfad.png)

`Flag: flag{l00k_at_m3_I_am_th3_4dm1n_n0w}`

## Flag 2

```
$ man 2 wtf.sh
WTF.SH(2)               Quals               WTF.SH(2)

NAME
       wtf.sh - A webserver written in bash

SYNOPSIS
       wtf.sh port

DESCRIPTION
       wtf.sh is a webserver written in bash.
       Do I need to say more?

FLAG
       You  can  get  the flag to this second part of
       the problem by getting the website to run  the
       get_flag2 command. Sadly, I can't seem to find
       anything in the code that does that :( Do  you
       think you could take a look at it for me?

ACCESS
       You can find wtf.sh at http://web.chal.csaw.io:8001/

AUTHOR
       Written  by  _Hyper_  http://github.com/Hyperâ€
       sonic/

SUPERHERO ORIGIN STORY
       I have deep-rooted problems
       That involve  childhood  trauma  of  too  many
       shells
       It was ksh, zsh, bash, dash
       They just never stopped
       On that day I swore I would have vengeance
       I became
       The Bashman

REPORTING BUGS
       Report   your   favorite  bugs  in  wtf.sh  at
       http://ctf.csaw.io

SEE ALSO
       wtf.sh(1)

CSAW 2016           September 2016          WTF.SH(2)

===================================================
```

This challenge was the one that almost drove me crazy (lol). Initially we tried to use both the LFI in post.wtf and profile.wtf to read the second flag. In the first attempt we read the /etc/passwd and discovered two users: flag1 (/home/flag1) and flag2 (/home/flag2). We tried to read the .bash_history files and other stuff inside of those users directories, but no success.

We also discovered that inside of those user's directories existed the files /home/flag1/flag1.txt and /home/flag2/flag2.txt but we couldn't read them as well. So finally we read the /usr/bin directory to find 2 binaries get_flag1 and get_flag2. They had some string references to those flag files and we assumed that those binaries had some kind of permission to read the flags smashing any hopes of getting the flag without RCE.

Reading the source of the files again I assumed that the spinup.sh file was giving us some hints with the comment: We don't do whole webroot since we want the people to be able to create files in webroot, but not overwrite existing files.

So the next step was to read the source code again, and again, looking for pieces of code that could allow us to create files in the application. Eventually I spotted that the reply function inside of post_functions.sh also had a path traversal vulnerability via the post_id parameter that comes from the reply.wtf page leading us to control the directory where the reply file was saved. As a proof of concept I injected the path ../../../../tmp to force the app to create the reply file inside of the /tmp directory and used the first LFI vulnerability to verify if the file was created. It was successfully created! The reply function code can be seen below:

```bash
function reply {
    local post_id=$1;
    local username=$2;
    local text=$3;
    local hashed=$(hash_username "${username}");

    curr_id=$(for d in posts/${post_id}/*; do basename $d; done | sort -n | tail -n 1);
    next_reply_id=$(awk '{print $1+1}' <<< "${curr_id}");
########## That's the important line! ############
    next_file=(posts/${post_id}/${next_reply_id});
##################################################
    echo "${username}" > "${next_file}";
    echo "RE: $(nth_line 2 < "posts/${post_id}/1")" >> "${next_file}";
    echo "${text}" >> "${next_file}";

    # add post this is in reply to to posts cache
    echo "${post_id}/${next_reply_id}" >> "users_lookup/${hashed}/posts";
}
```

So the next step was force the app create a file inside of our webroot and verify if it was create with success as can be seen in the following screenshots:

![Creating a reply file inside of the webdir](http://image.prntscr.com/image/bad638682aa247e4808252ab8f17829a.png)

![File create with success! YOLO](http://image.prntscr.com/image/3154169deb5248b3b2eae0e074338c48.png)

Nice!!  "... My first thinking was obvious: "Maybe a null byte can do the job!?" but my plans were frustrated one more time :-(. So I decided to share my ideas with the team to get some input. Lanjelot, a team mate, knew that using a space character in the ${post_id} parameter would transform the expression (posts/${post_id}/${next_reply_id}) in an array containing two elements: post/ and /1. In bash, when you have an array of two or more elements and you don't define the index of that array, it will always return the first element. So he sent the following code to me as proof of concept:

```
Scorpius:csaw_2016 pimps$ cat teste.sh
next_file=(xxxx yyyy)
echo ${next_file}
Scorpius:csaw_2016 pimps$ sh teste.sh
xxxx
Scorpius:csaw_2016 pimps$
```

## EUREKA!!!

So, to get RCE and consequently the flag I just injected a filename with the wtf extension and a space character on the end of the filename forcing the app to get only the first element of the array (/../xxx.wtf /1). In the text field I inserted a get_flag2 command with a $ symbol at the beginning of the line to force the app to parse it as a command line. This is shown in the following images:

![Creating the malicious page](http://image.prntscr.com/image/c2c7935e99de43e98b73b16fd89a9b1f.png)

![Getting the flag](http://image.prntscr.com/image/c2c7935e99de43e98b73b16fd89a9b1f.png)
![Getting the flag 2](http://image.prntscr.com/image/c450b8e295b04ad2a3217c9c42f8cd39.png)

`Flag: flag{n0b0dy_exp3c75_th3_p4r3nth3s1s_1nqu1s1t10n}`

That's all folks!!

FLAAAAAAAAAGS](http://i.imgur.com/Lkq3r1F.jpg)

gha_language: CSS

gha_license_id: MIT


text:
# MyCalculator
> This a calculator that does basic arithmetic operations.

## Table of contents
* [General info](#general-info)
* [Screenshots](#screenshots)
* [Technologies](#technologies)
* [Setup](#setup)
* [Features](#features)
* [Status](#status)
* [Inspiration](#inspiration)
* [Contact](#contact)

## General info
This a basic calculator that is able to get data from the user interface, pass it to the backend logic and the answer is displayed to the user. This calcultor will allow me to learn how user interface and business logic interact.The motivation behind building a basic calculator is to finally understand how calculations are done behind the scenes and displayed to the user.

## Screenshots
Screenshots and GIFs of how the apps looks like and function will go here.

## Technologies
* HTML5
* Javascript
* Jquery
* CSS3
* Bootstrap - version 4.0

## Setup
To run this project:

```
$ git clone https://github.com/Breens-Thomas/Calculator.git
$ cd calculator
```
Link to live project:"link will go here"

## Features
Features available
* Addition of numbers
* Division of numbers
* Subtraction of numbers
* Remainder of number
* Multiplication of numbers

To-do list:
* Add a user interface
* Add complex arithmetic operations

## Status
Project is: _in progress_ because there are technologies I'm learning to implement certain features.The technologies include Javascript,Jquery and Bootstrap.

## Inspiration
Inspiration is from using my personal phone calculator.

## Contact
Created by [Breens Mbaka](https://www.linkedin.com/in/breens-mbaka-b447781b9/) - feel free to contact me!

## copyright and license information
[MIT](https://github.com/Breens-Thomas/Calculator/blob/master/LICENSE.txt) (c) 2020 Breens Mbaka

repository: Breens-Mbaka/Calculator

repo_name: Breens-Mbaka/Calculator


text:
# GraphQL API sample using GQLGen
Simple app written in Go using [GQLGen](https://github.com/vektah/gqlgen) library.

## Generate schema
To generate schema, simply run:
```bash
go generate ./...
```

## Run
Run app by executing:
```bash
go run main.go
```

repository: pkosiec/golang-graphql-samples

repo_name: pkosiec/golang-graphql-samples


text:
# My Vim Configuration

Based on [The Vim Configuration of Champions](https://github.com/mutewinter/dot_vim)

## Installation

1. git clone http://github.com/gmerzu/dot_vim.git
2. cd dot_vim
3. ./scripts/setup.sh


text:
# http-www-redirector
Go app to redirect root level domains to www.[root domain]

## Installation

```
$ go get github.com/patjack/http-www-redirector
$ sudo http-www-redirector

repository: patjack/http-www-redirector

repo_name: patjack/http-www-redirector


text:
<!---
Group:observation period
Name:OP14 Distribution of age, stratified by gender
Author:Patrick Ryan
CDM Version: 5.0
-->

# OP14: Distribution of age, stratified by gender

## Description
This query is used to provide summary statistics for the age across all observation records stratified by gender (gender_concept_id): the mean, the standard deviation, the minimum, the 25th percentile, the median, the 75th percentile, the maximum and the number of missing values. The age value is defined by the earliest observation date. Age is summarized for all existing gender_concept_id values.

## Query
```sql
WITH t AS /* person, gender, age */
     ( SELECT person_id, ISNULL( concept_name, 'MISSING' ) AS gender
            , YEAR(first_observation_date ) - year_of_birth AS age
         FROM -- person, first observation period date
            ( SELECT person_id
                   , min( observation_period_start_date ) AS first_observation_date
                FROM @cdm.observation_period
               GROUP BY person_id
            )
         JOIN @cdm.person USING( person_id )
         LEFT OUTER JOIN @vocab.concept ON concept_id = gender_concept_id
        WHERE year_of_birth IS NOT NULL
     )
SELECT gender
     , count(*) AS num_people
     , min( age ) AS min_age
     , max( age ) AS max_age
     , round( avg( age ), 2 ) AS avg_age
     , round( STDEV( age ), 1 ) AS STDEV_age
     , (SELECT DISTINCT PERCENTILE_DISC(0.25) WITHIN GROUP( ORDER BY age ) over ()
                                     AS percentile_25 FROM t)
     , (SELECT DISTINCT PERCENTILE_DISC(0.5)  WITHIN GROUP (ORDER BY age ) over ()
                                     AS median FROM t)
     , (SELECT DISTINCT PERCENTILE_DISC(0.75) WITHIN GROUP (ORDER BY age ) over ()
                                     AS percential_75 FROM t)
  FROM t
GROUP BY gender
```

## Input

None

## Output

|  Field |  Description |
| --- | --- |
|  gender |  Gender concept name |
|  num_people |  Number of people with specific gender |
|  min_age |  Minimum age across observation of people with specific gender |
|  max_age |  Maximum age across observation of people with specific gender |
|  avg_age |  Average age across observation of people with specific gender |
|  STDEV_age |  Standard deviation of age across observation within specific gender |
|  percentile_25 |  25th percentile age across observation within specific gender |
|  median |  Median age across observation within specific gender |
|  percentile_75 |  75th percentile age across observation within specific gender |

## Sample output record

|  Field |  Description |
| --- | --- |
|  gender |  MALE |
|  num_people |  1607472 |
|  min_age |  0 |
|  max_age |  103 |
|  avg_age |  40.78 |
|  STDEV_age |  18.60 |
|  percentile_25 |  29 |
|  median |  45 |
|  percentile_75 |  55 |

## Documentation
https://github.com/OHDSI/CommonDataModel/wiki/

repository: mi-erasmusmc/QueryLibrary

gha_language: HTML

repo_name: mi-erasmusmc/QueryLibrary


text:
+++
title = "Step 3 - Querying all the employees of a city"
date = 2019-12-02T12:16:25-08:00
weight = 3
+++

Now, you have a new GSI you can use for query employees by state. Run the following Python application:
```bash
python query_city_dept.py employees TX --citydept Dallas
```
Output:
```txt
List of employees . State: TX
    Name: Grayce Duligal. City: Dallas. Dept: Development
    Name: Jere Vaughn. City: Dallas. Dept: Development
    Name: Valeria Gilliatt. City: Dallas. Dept: Development
  ...
  Name: Brittani Hunn. City: Dallas. Dept: Support
    Name: Oby Peniello. City: Dallas. Dept: Support
Total of employees: 47. Execution time: 0.21702003479 seconds
```

repository: danielsyoder/amazon-dynamodb-labs

repo_name: danielsyoder/amazon-dynamodb-labs


text:
---
title: Activate license on an air-gapped cluster using Cluster UUID
linkTitle: Enable using Cluster UUID
description: Learn about the Portworx Enterprise
keywords: enterprise license, license sharing, transfer license, air-gapped license, Saas Key, Licensing, Portworx Enterprise, upgrade Portworx, activate license
weight: 200
aliases:
    - /reference/licensing/portworx-enterprise/cluster-uuid-air-gapped/
---
1. Get your Cluster UUID and contact Portworx.
The `Cluster UUID` information is available via `pxctl cluster list` command.

    ```text
    pxctl cluster list
    ```

    ```output
    Cluster ID: MY_FAVORITE_PX_CLUSTER
    Cluster UUID: f987ad4b-987c-4e7e-a8bd-788c89cc40f1
    Status: OK [...]
    ```

2. Upon supplying the Cluster UUID, you receive your license file.
Upload this file on one of the Portworx nodes, and activate the license by running the following command:

    ```text
    pxctl license add license_file.bin
    ```

{{<info>}}
**Note:**

 * The license installation is a non-obtrusive process, which does not interfere with the data stored on the Portworx volumes, nor interrupts the active IO operations.

 * If you’re running Portworx on an air-gapped cluster that has no outbound connectivity, refer to [this page](/operations/licensing/portworx-enterprise/pay-as-you-go-air-gapped) for enabling pay-as-go billing.

 * Once you enable a pay-as-you-go license on an air-gapped cluster with no outbound connectivity, you currently can't switch to any other license.
{{</info>}}


text:
This is a project made in react.
You can find amazing tutorials created by @StephenGrider at https://www.udemy.com/react-redux/learn/v4/overview

####Getting started#####
Checkout this repo, install dependencies, then start the npm process with the following:

```
  > git clone https://github.com/alvarorc/react-postsapp
  > cd ReduxSimpleStarter
  > npm install
  > npm start
```

repository: alvarorc/react-postsapp

repo_name: alvarorc/react-postsapp


text:
# Download the Android Library

We have an Android Library available for you to download to make native development on Android even easier.

### Download Android Library
[v.0.6.5 (3.6mb, September 29th, 2014)](http://staticweb.cloudmine.me/cloudmine-android-v0.6.5.zip)

### Download Java Library
[v.0.6.3 (1.3mb, August 11th, 2014)](http://staticweb.cloudmine.me/cloudmine-java-v0.6.3.zip)

Check out the [Android Library documentation](/docs/javadocs/index.html).

The Library is open-source and under the MIT license.

Maven

You can also add the Android library as a Maven repository. This requires you to add the CloudMine repository to your pom.xml file

```xml
<repositories>
    <repository>
        <id>cloudmine-releases</id>
        <url>https://github.com/cloudmine/maven/raw/master/releases</url>
    </repository>
</repositories>
```

And then in your dependencies section, you need to add

```xml
<dependencies>
  <dependency>
      <groupId>com.cloudmine.api</groupId>
      <artifactId>cloudmine-android</artifactId>
      <version>0.6.5</version>
  </dependency>
</dependencies>
```

### Github

We're actively developing and invite you to fork and send pull requests on GitHub.

* [cloudmine/cloudmine-android](https://github.com/cloudmine/cloudmine-android)

* [cloudmine/cloudmine-java](https://github.com/cloudmine/cloudmine-javasdk)

Before you can begin using the Android / Java Library, you must first [create an application](/dashboard/app/create) in the CloudMine dashboard.

repository: cloudmine/CloudMineSDK-Android

branch_name: refs/heads/dev

gha_language: Java

repo_name: cloudmine/CloudMineSDK-Android


text:
# Dibs Client
[![Build Status](https://travis-ci.org/inteleon/dibs-client.svg)](https://travis-ci.org/inteleon/dibs-client)

For making requests to Dibs webservice. You need an account for Dibs.

This package supports the **D2 Platform/DIBS Payment Window** hosted payment window and server-to-server API.

## Documentation

...

## Todo

- Documentation
- Testsing for `Inteleon\Dibs\DibsPaymentWindow`

repository: inteleon/dibs-client

repo_name: inteleon/dibs-client


text:
# Population structure and genetic diversity of invasive Fall Armyworm after 2 years of introduction in India

This repo contains R code used for analysis in the above paper which is published in the journal _Scientific Reports_.

CITATION: Nayyar, N., Gracy, R.G., Ashika, T.R. et al. Population structure and genetic diversity of invasive Fall Armyworm after 2 years of introduction in India. _Sci Rep_ 11, 7760 (2021).
DOI: https://doi.org/10.1038/s41598-021-87414-5
LINK: https://rdcu.be/cijdA

gha_language: R


text:
# User Alert
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)

User Alert is a test for sweetalert use on a personal project.

## Installation

Write install notes here

```bash
write install nodes
```

## Usage

```bash
write install notes

```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

repository: raminhoodeh/useralert

repo_name: raminhoodeh/useralert


text:
## Further information on executables in bin/

* [Further information on executables in bin/](#Furtherinformationonexecutablesinbin)
* [Bam stats estimation](#Bamstatsestimation)
	* [idxdepth](#idxdepth)
* [Read counts on graph](#Readcountsongraph)
	* [paragraph](#paragraph)
* [Genotyper](#Genotyper)
	* [multigrmpy.py](#multigrmpy.py)
	* [grmpy](#grmpy)
* [Other tools](#Othertools)
	* [vcf2paragraph.py](#vcf2paragraph.py)
	* [addVariants.py](#addVariants.py)
	* [compare-alignments.py](#compare-alignments.py)
	* [findgrm.py](#findgrm.py)
	* [msa2vcf.py](#msa2vcf.py)
	* [paragraph2dot.py](#paragraph2dot.py)

## Bam stats estimation

### idxdepth

A brief index-based depth estimation for BAM and CRAM.
Idxdepth will rapidly provide depth estimates for all chromosomes in a
BAM / CRAM file. When passed a human genome, idxdepth will also guess which
chromosomes are in the autosome and provide an autosome depth estimate and
a guess for the read length.

Basic usage:

```bash
bin/idxdepth -b \<bam/cram> -r \<reference fasta> -o \<output>
```

The output will be a json file with depth across whole genome and on each chromosome:
```javascript
{
    "autosome": {
        "contigs": [
            "chr1"
        ],
        "depth": 1
    },
    "bam_path": "fake_path.bam",
    "contigs": [
        // ...
    ],
    "read_length": 50,
    "reference": "fake_reference.fa",
    "unaligned_reads": 0
}
```

## Read counts on graph

### paragraph

core program used in grmpy to calculate read counts on sequence graphs.
The main idea in this tool is to support read-based calling and disambiguation
of reads between different paths in a graph.

The input for `paragraph` are a graph model JSON file and a BAM file + reference
fasta to retrieve reads from.

The output file contains:

* read counts for every node and edge in the graph (for uniquely-aligning reads)
* locations and read counts for variants (i.e. non-match alignments)
* (optional) individual read alignments for every read

## Genotyper

### multigrmpy.py

Wrapper for the graph tool genotyper. Transform multiparagraph output to grmpy (graph genotyper) input format then run grmpy.

Basic Usage:

```bash
python3 bin/multigrmpy.py -i \<input\> -m \<manifest> -r \<reference fasta> -o \<output directory>
```

* **input**: VCF file with variants or JSON file with graphs

* **manifest**: a list of BAM files or alignments to use.

Example using BAM files and known depth + read length:
```
id      path          read length  depth
sample1 sample1.bam   150          50
sample2 sample2.bam   150          50
```

Idxdepth JSON files may be used instead of read length and depth estimates:
```
id      path          idxdepth
sample1 sample1.bam   sample1.idxdepth.json
sample2 sample2.bam   sample2.idxdepth.json
```

When paragraph alignments have been computed beforehand, these may be passed instead of a BAM file:
```
id      paragraph      idxdepth
sample1 sample1.paragraph.json   sample1.idxdepth.json
sample2 sample2.paragraph.json   sample2.idxdepth.json
```

If the BAM index isn't in a standard location that can be derived from a file name (e.g.
when the BAM is located on remote storage and accessed via a pre-signed URL that may be
different from the one of the index), the `index_path` column can be added to specify the
index location for each BAM file.

* **reference fasta**: Fasta reference to use. This must be the correct reference both for input BAM/CRAM files and the input graphs.

* **output directory**: This directory will contain the following files:
    - *variants.json.gz*: A JSON file with all input variants.
    - *genotypes.json.gz*: A JSON file with breakpoint and genotype information.
    - *genotypes.vcf.gz*: When the input file is in VCF format, then multigrmpy.py will write an annotated version which contains genotypes as computed by grmpy. In addition to the genotypes, this file also contains the following new fields:
        + `INFO/GRMPY_ID`: This value can be used to match the genotypes to the JSON records in *genotypes.json.gz* (where it matches record.graphinfo.ID) and *variants.json.gz* (where it matches record.ID).
        + `FORMAT/GT`: genotype computed by grmpy. Note that the `SAMPLE` column in the VCF file must match a sample id from the manifest shown above.
        + `FORMAT/AD`, `FORMAT/ADF`, `FORMAT/ADR`: depth for each allele (including the reference), total and by strand.
        + `FORMAT/DP`: Total depth used to genotype.
        + `FORMAT/FT`: grmpy filter status for each call, in each sample.
        + `FORMAT/PL`: phred-scaled genotype likelihood.
    - *grmpy.log*: log file from grmpy with progress and diagnostic information.
    - *alignments/\*.json.gz*: when multigrmpy.py is run with the `-A` option, this folder will contain a paragraph alignment for each graph.

### grmpy

Core executable for graph genotyper. Process one site at a time. Executed within multigrmpy.py

Paragraph output cannot be directly used for grmpy unless file format conversion has been done manually or through multigrmpy.py.

An example input for grmpy:

```javascript
    "model_name": "Variant1"
    // ... original graph specification
    "samples": {
        "sample1": {
            "read_counts_by_edge": {
                // ...
            }
        },
        "sample2": {
            // ...
        }
    },
    // ...
```

## Other tools

### vcf2paragraph.py

VCF2Paragraph can convert a subset of the [VCF specification](https://samtools.github.io/hts-specs/VCFv4.3.pdf) into a labelled sequence graph.

It supports two different conversion modes:

* **Allele graphs**: each VCF record creates a path for the reference and each alternate allele. When two alleles overlap on the reference, their paths will not be compatible in the graph. When two alleles are subsequent on the reference, their respective reference / alternate paths can be combined. Sequence labels for each allele in the form *vcfID*:*AlleleNumber*, e.g. *var1:0* for the reference allele of a VCF variant with ID *var1*.
* **Haplotype graphs**: Each VCF sample is used to create one haplotype path by specifying haploid genotypes. Reference paths may be included using `0` genotypes, variants can be undetermined on a haplotype (allowing any allele) using `.`. Alt alleles that are not used in any haplotype are excluded from the graph. One sequence label is created for each haplotype, defining a *path family* for all paths consistent with the haplotype.

The script supports standard sequence alleles (REF/ALT), as well a subset of symbolic ALT alleles:

*  Sequence alleles: SNPs and small indels / substitutions produce subgraphs with two paths: one for the reference, and one for the alternate sequence.
*  Deletions: explicit deletions or symbolic `<DEL>` alleles segment the reference sequence into three parts. The middle part can be bypassed using an edge. The `END` INFO field can be used to indicate the length of the deletion for long deletions.
* Forward breakends on the same chromosome, e.g. REF: `A`; ALT: `AC[chr1:10000[`, can be used to encode
  long deletions with short inserted sequence (swaps / substitutions).
* Insertions with symbolic `<INS>` allele: must have a field in INFO field indicating insertion sequence (no padding base, default key `SEQ`). The `END` INFO field may contain the end of the reference sequence that is replaced with the inserted sequence. Note that our convention is to assume that the first reference base in the record is a padding base, and that this base is not present in the value of `INFO/SEQ`.
* When variants have an ID value then it must be unique and will be used to label the variant edges in the graph. A VCF file with non-unique IDs or other problematic INFO/FORMAT fields can be cleaned up using bcftools:
```bash
bcftools annotate --set-id '.' -x 'INFO,FORMAT,^FORMAT/GT' \
        input.vcf.gz -o input-for-vcf2paragraph.py
```

All variants in one VCF passed to VCF2paragraph.py must be on the same chromosome. Our
other wrapper scripts (e.g. `multigrmpy.py`) will split up the VCF file into individual records or superloci (clusters of close-by variants) before conversion.

Paragraph doesn't support cycles in the graphs, and VCF2paragraph will raise an error if the resulting
graph contains a cycle (e.g. created by a breakend). To break cycles, vcf2paragraph may split long reference nodes and remove long reference stretches (our graph alignments start from BAM files, so realignments to long reference stretches are not necessary).

Run `vcf2paragraph.py -h` for full list of command line options.

### addVariants.py

addVariants takes a graph (in paragraph JSON format) and a set of paragraph variant calls on that graph, to produce a new graph with the variants included explicitly as nodes and edges. Reads can then be re-aligned to that new graph for accurate genotyping of the variants.

Variants can be in any node (ref or alt) and are relative to the sequence of that node. addVariants will split the node into a left-flank, the variant and a right-flank (either flank maybe empty). For the variant part two nodes will be created one with the original node sequence, one with the alternative sequence (either maybe empty in case of insertions / deletions). The new nodes are connected to the flanks and the whole subgraph replaces the original node in the graph. Existing sequence labels are maintained, but no labels are added to the new edges for the added variant; It has to be halplotyped in a later alignment (paragraph) step.

Run `addVariants.py -h` for full list of command line options.

### compare-alignments.py

This is a helper script to compare two paragraph alignment JSON files.

### findgrm.py

This is a helper script / module which is used by the other scripts to find the installation base directory and set up Python library path for a paragraph installation.

### msa2vcf.py

This script converts multiple sequence alignment Fasta files (Fasta files where sequences may contain `-` characters to denote gaps) into VCF files which can then be converted into graphs.

### paragraph2dot.py

This script is used to convert paragraph graph JSON files to dot files for visualisation.

repository: Yanglv-rookie/paragraph

repo_name: Yanglv-rookie/paragraph


text:
theme: Simple
autoscale: true

# Exceptions

```
Object
  |
Throwable
  |----------------|
  |                |
Exception         Error
  |
RuntimeException
```

---

## Checked vs Unchecked

- all exceptions occur at runtime
- checked: handle or declare: compiler forces us
- unchecked or _runtime_: we don't need to handle or declare
    - because they're too common: NullPointerException, ArrayIndexOutOfBoundsException, etc.

---

## Should I "catch" Errors? 🤔

- never, ever
- never
- really
- don't do it
- ever
- I'm serious
- don't

---

## Exception on OCP

- study! (page 288)

---

## Try-catch-finally

```java

try {
	// do something that can throw
} catch (Exception e) {
    // do something if this exception is injected
} finally {
    // do this always
}

```

---

## Try-catch gotchas

* Error! Needs a block

```java
try
	int i = 0;
catch (Exception e) ;
```

---

## Try-catch gotchas

* Error! Try need a catch / finally

```java
try  {
    System.out.println("2");
}   // error!
```

* This is fine

```java

try {
	int i = 0;
} catch (Exception e) { }
```

---
## Try-catch gotchas

Just __one__ try, please

```java

try {

} try {

} catch (Exception e) {}
```

---

## Try-catch gotchas

```java
// we can have a try-catch with Throwable
try {
	int i = 0;
} catch (Throwable t) {
    //  Pokémon catch: Gotta catch'em all!
}

try {
	int i = 0;
} catch (Exception t) {
	// i++;               Error: i - local to try block
}

```

---

## Try-catch gotchas

```java
// can have more than one catch
try {
	int i = 0;
} catch (Exception e) {

} catch (Throwable t) {

}

try {
	int i = 0;
} catch (Throwable t) {

} catch (Exception e) { // error: Exception has already been caught

}
```

---

## Finally always gets called

```java
static void print(String s) {
    try  {
        System.out.println("2");
        if (s == null) return;
    } finally {
        System.out.println("3");
    }
    System.out.println("1");

    System.out.println("2");
}
```

---

## Creating your own exceptions

```java
// Runtime, non-checked Exception
class NonCheckedException extends RuntimeException {
    public NonCheckedException() {  // typical constructors
    }

    public NonCheckedException(String message) {
        super(message);
    }

    public NonCheckedException(Exception cause) {
        super(cause);
    }
}

// Compile-time, checked exception, handle or declare rule
class CheckedException extends Exception {

}

```

---

## Catch-Or-Declare rule (Checked exceptions)

```java
public class Main {
    public static void main(String[] args) {
        throwsNonChecked(); // no problem with non-checked
        try {
            throwsChecked();
        } catch (CheckedException e) {
            e.printStackTrace();
        }
    }

    static void throwsNonChecked() {
        throw new NonCheckedException();
    }

    static void throwsChecked() throws CheckedException {
        throw new CheckedException();
    }
}

```

---

## What does this prints? 😈

```java
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try {
            System.out.println("DogeBegin");
            new Main().saveToDisk();
        } catch (IOException e) {
            System.out.println(e.getMessage());
        } finally {
            System.out.println("DogeFinally");
        }
    }

    void saveToDisk() throws IOException{
        throw new IOException("Such litte space. Much files. Wow");
    }
}
```

---

## What does this prints?

```
DogeBegin
Such litte space. Much files. Wow
DogeFinally
```

---
## What does this prints? 😈

```java
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try {
            System.out.println("DogeBegin");
            new Main().saveToDisk();
        } catch (IOException e) {
            System.out.println("IODoge" + e.getMessage());
        } catch (Exception e) {
            System.out.println("ExceptionDoge"+ e.getMessage());
        } finally {
            System.out.println("DogeFinally");
        }
    }

    void saveToDisk() throws IOException{
        throw new IOException("Such litte space. Much files. Wow");
    }
}
```

---

## What does this prints?

```
DogeBegin
IODogeSuch litte space. Much files. Wow
DogeFinally

```

---

## What does this prints? 😈

```java
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        try {
            System.out.println("DogeBegin");
            saveToDisk();
        } catch (IOException e) {
            System.out.println("IODoge" + e.getMessage());
            return;
        } finally {
            System.out.println("DogeFinally");
        }
        System.out.println("DogeReturn");
    }

    void saveToDisk() throws IOException{
        throw new IOException("Such litte space. Much files. Wow");
    }
}
```
---

## What does this prints?

```

DogeBegin
IODogeSuch litte space. Much files. Wow
DogeFinally
```

---
## What does this prints? 😈

```java
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        try {
            System.out.println("DogeBegin");
            saveToDisk();
        } catch (IOException e) {
            System.out.println("IODoge" + e.getMessage());
            return;
        } finally {
            System.out.println("DogeFinally");
        }
        System.out.println("DogeReturn");
    }

    void saveToDisk() throws IOException{
        throw new RuntimeException("Such litte space. Much files. Wow");
    }
}

```

---

```
Exception in thread "main" java.lang.RuntimeException: Such litte space. Much files. Wow
DogeBegin
	at Main.saveToDisk(Main.java:22)
DogeFinally
	at Main.run(Main.java:11)
	at Main.main(Main.java:5)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
```

---

## Multicatch

```java
try {

} catch (ArrayIndexOutOfBoundsException | ArithmeticException e) {
    // can't use parent & child here
} finally {

}

try {

} catch (Exception | ArithmeticException e) {   // won't compile

} finally {

}

```

---

## Multicatch is effectively final

```java
try {

} catch (ArithmeticException  | ArrayIndexOutOfBoundsException e) {
    e = new ArithmeticException();  // error: e is final
}
```

- but this compiles!

```java
try {

} catch (ArithmeticException  e) {
    e = new ArithmeticException();
} finally {

}
```

---

## Remember we can catch something that can be thrown

```java
static void print(String s) {
    try {
        thrower();
    } catch (SQLException e) {

    }
}

static void thrower() throws ArrayIndexOutOfBoundsException {

}
```

---

## Try-with-resources

- need that Connection and Statement implement AutoCloseable
- AutoCloseable implemented by more that 150 classes!

```java
try (Connection connection = DriverManager.getConnection(url);
    Statement statement = connection.createStatement()) {

}
```

---

## Try-with-resources

- no need for that try
- here's how this magic works

```java
try (Connection connection = DriverManager.getConnection(url);
    Statement statement = connection.createStatement()) {

} finally {
    statement.close();  // these are the 1st two lines in the finally block
    connection.close(); // like super / this in a constructor

    // can't use the statement here: closed!
}
```

---

## AutoCloseable

```java
try(MyFile file = new MyFile()) {

}
// ...
class MyFile implements AutoCloseable {
    public MyFile() {
        super();

        System.out.println("Creating " + this);
    }

    @Override
    public void close() {
        System.out.println("Closing " + this);
    }
}

```

---

## Autocloseable is a functional interface...

```java
try (AutoCloseable c = new AutoCloseable() {
    @Override
    public void close() {

    }
}) {

} catch (Exception e) {

}
```

- as lambda

```java
try (AutoCloseable c = () -> {

}) {

} catch (Exception e) {

}

```

---

## Assertions

- conditions that can never happen while the program is running
- they're absurd, but we want to catch them while developing
- we need to enable assertions (-ea) Edit Configurations > VM Options

---

## Useful asserts

- we're on the main thread, or in a background thread
- check exhaustive switch (with assert that fails in default)
- check an else is never met
- check some object that shouldn't be null is never null...

```java
// check we're running on Main Thread

assert (Thread.currentThread().getName().equals("main"));
```

url: https://raw.githubusercontent.com/temnur/ocp-java8-notes/6a8fc49467579b0563e05dccb5bf06d237ec2155/6 - Exception and Assertions.md

path: /6 - Exception and Assertions.md

filename: 6 - Exception and Assertions.md


text:
---
title: Citrus chia ‘frogs eggs’
author: Kim Heenan
type: post
date: 2014-08-23T23:31:31+00:00
url: /2014/08/23/2014-7-27-citrus-chia-frogs-eggs/
featuredImage: chia-goup.jpg
categories:
  - Recipes
tags:
  - Dairy/lactose-free friendly
  - Drinks
  - Nut-free friendly
  - 'Quick & easy'
  - Snacks
  - Vegan friendly
  - Vegetarian

---

![](chia-goup.jpg)

**DOES NOT CONTAIN FROG**

This snack idea is so simple I almost didn’t post it; doing so feels a bit like writing a recipe for a cup of tea. However, I’ve had at least five people ask me about this concoction in the space of a week so here it is.

<!--more-->

I particularly like chia prepared this way because it’s an energy source that’s light enough that I can drink it then proceed to exercise 15 minutes later without feeling remotely ill – even if that exercise is teaching Body Attack with it’s tuck-jump-burpees. There are not many foods for which I can say the same.

Now for the credits: idea courtesy of my sister, and the name… inspired by my mother who came close to convincing her squad of swimmers, using post-exercise nutritional arguments, that she was in fact drinking frogs eggs!

Serves 1

  * 2 tablespoons chia seeds (any colour)
  * juice of half a lemon or lime (if you like stronger citrus flavours, add juice from the whole fruit)
  * 300mL water

Combine all ingredients in a jar. Secure lid and shake well. Shake a couple of times over the next 5-10 minutes so the chia doesn’t clump together too densely. Refrigerate or allow to sit for at least 30 minutes and you’re done.

repository: freshanddelish/fresh-and-delish-blog

repo_name: freshanddelish/fresh-and-delish-blog


text:
# Elastic APM: PHP Agent

[![Build Status](https://travis-ci.com/philkra/elastic-apm-php-agent.svg?branch=master)](https://travis-ci.org/philkra/elastic-apm-php-agent)
[![Total Downloads](https://img.shields.io/packagist/dt/philkra/elastic-apm-php-agent.svg?style=flat)](https://packagist.org/philkra/elastic-apm-php-agent)

This is a community PHP agent for Elastic.co's [APM](https://www.elastic.co/solutions/apm) solution, supporting the `v2` Intake API. Please note: This agent is not offically supported by [Elastic](https://www.elastic.co/).

## Documentation
* [Installation](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/install.md)
* [Configuration](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/config.md)
* [Knowledgebase](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/knowledgebase.md)

## Examples
* [Agent Initialization](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/agent-init.md)
* [Basic Usage](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/basic-usage.md)
* [Capture Throwable](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/capture-throwable.md)
* [Spans](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/spans.php)
* [Parent Transactions](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/parent-transactions.php)
* [Metricset](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/metricset.php)
* [Getting the Server Info](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/server-info.php)
* [Distributed Tracing](https://github.com/philkra/elastic-apm-php-agent/blob/master/docs/examples/distributed-tracing.md) -- Incomplete (TODO)

## Tests
```bash
vendor/bin/phpunit
```

## Contributors
A big thank you goes out to every contributor of this repo, special thanks goes out to:
* [dstepe](https://github.com/dstepe)
* [georgeboot](https://github.com/georgeboot)
* [alash3al](https://github.com/alash3al)
* [thinkspill](https://github.com/thinkspill)
* [YuZhenXie](https://github.com/YuZhenXie)

gha_language: PHP


text:
---
title: Connect your app to Azure Active Directory (Classic Portal)
description: How to obtain a ClientId and Client Secret for a Microsoft Azure Active Directory with the Classic Portal.
crews: crew-2
toc: true
topics:
    - connections
    - enterprise
    - azure
    - active-directory
    - microsoft
contentType:
    - index
    - how-to
useCase:
    - customize-connections
    - add-idp
---

# Connect your app to Azure Active Directory (Classic Portal)

::: version-warning
This document covers the Azure Active Directory Classic Portal.
:::

To allow users to login using a Microsoft Azure Active Directory account, you must register your application through the Microsoft Azure portal. If you don't have a Microsoft Azure account, you can [signup](http://www.windowsazure.com/en-us/pricing/free-trial) for free.

::: note
There is no way to create an application that integrates with Microsoft Azure AD without having **your own** Microsoft Azure AD instance.
:::

## 1. Create a new Microsoft Azure Active Directory instance

Log in to Microsoft Azure, and select **Active Directory** from the Dashboard.

![](/media/articles/connections/enterprise/azure-active-directory/waad-0.png)

Click on **ADD+** at the bottom of the screen.

![](/media/articles/connections/enterprise/azure-active-directory/waad-1.png)

Enter a *subdomain*, such as: **${account.tenant}**. This can be any text. (It does not have to match the Auth0 subdomain and it will be used in the next step.) Also enter your country and a friendly name for your organization.

![](/media/articles/connections/enterprise/azure-active-directory/waad-2.png)

## 2. Create a new application

Once the Microsoft Azure AD instance has been created, you need to create an application. Go to **APPLICATIONS** and click on **ADD AN APPLICATION**.

![](/media/articles/connections/enterprise/azure-active-directory/waad-3.png)

Select **Add an application my organization is developing**.

![](/media/articles/connections/enterprise/azure-active-directory/waad-3b.png)

Enter a friendly name for the application and select **WEB APPLICATION AND/OR WEB API**.

![](/media/articles/connections/enterprise/azure-active-directory/waad-4.png)

Proceed to the next screen and enter the following:

* **SIGN-ON URL**: your application URL
* **APP ID URI**: https://**${account.tenant}**.onmicrosoft.com/yourapp

::: note
The **APP ID URI** is just a logical identifier, not a real URL. It is important to use the value as specified above in the **APP ID URI** field. For example, if the Microsoft Azure AD you've just created is **myorg.onmicrosoft.com**, you would enter https://**myorg.onmicrosoft.com***/yourapp* here.
:::

![](/media/articles/connections/enterprise/azure-active-directory/waad-5.png)

## 3. Configure the application

Once the application has been created, you have to configure it. Click **CONFIGURE** to continue. On this screen you can customize the logo and the application URL that you entered before, if needed.

Enter the following values on **KEYS** and **REPLY URL**, and click **Save**.

* **KEYS**: Select 1 or 2 years (the key will be displayed when these settings are saved)
* **REPLY URL**: https://${account.namespace}/login/callback

![](/media/articles/connections/enterprise/azure-active-directory/waad-8.png)

The next step is to modify permissions so your app can read the directory. Select the *Read Directory Data* and *Enable sign-on and read users' profiles* delegated permissions.

![](/media/articles/connections/enterprise/azure-active-directory/waad-8b.png)

::: note
If you want to enable extended attributes (like *Extended Profile* or *Security Groups*) you will also need to enable the following permissions: **Application Permissions:** *Read directory data*, **Delegated Permissions:** *Access your organization's directory*.
:::

Click **Save** at the bottom of the screen and the key will be displayed. Make sure to copy the value of this key before leaving this screen.

![](/media/articles/connections/enterprise/azure-active-directory/waad-9.png)

## 4. Copy the Client ID and Secret to Auth0

Go to [Auth0 Dashboard > Authentication > Enterprise](${manage_url}/#/connections/enterprise), and select **Microsoft Azure AD**.

Copy the Client ID and the Key generated by Microsoft Azure in the [previous step](#configure-the-application) into the *Client ID* and *Client Secret* fields in Auth0.

![](/media/articles/connections/enterprise/azure-active-directory/waad-10.png)

**Congratulations!** You are now ready to accept Microsoft Azure AD users.

## Troubleshooting

* When granting access, make sure to use an *Incognito/InPrivate* window  and a Global Administrator user.

* If you get *Access cannot be granted to this service because the service listing is not properly configured by the publisher*, try selecting the **Application is Multi Tenant** option in the Windows Azure AD application in the Azure Dashboard.

## Signing Key Rollover in Azure Active Directory

Signing keys are used by the identity provider to sign the authentication token it issues, and by the consumer application (Auth0 in this case) to validate the authenticity of the generated token.

For security purposes, Azure AD’s signing key [rolls on a periodic basis](https://azure.microsoft.com/en-us/documentation/articles/active-directory-signing-key-rollover/). If this happens, **you do not need to take any action**. Auth0 will use the new key automatically.

<%= include('../../../_quickstart-links.md') %>

gha_language: JavaScript


text:
# Data Structures and Algorithms

See [setup instructions](https://codefellows.github.io/setup-guide/code-301/3-code-challenges), in the Code 301 Setup Guide.

## Repository Quick Tour and Usage

### 301 Code Challenges

Under the `data-structures-and-algorithms` repository, at the top level is a folder called `code-challenges`

Each day, you'll add one new file to this folder to do your work for the day's assigned code challenge

### 401 Data Structures, Code Challenges

- Please follow the instructions specific to your 401 language, which can be found in the directory below, matching your course.

| x     | Description |
| ----------- | ----------- |
| 1      | [Reverse Array](./javascript/Array-Reverse) |
| 2   | [Shift Array](./javascript/Shift-Array) |
| 3   | [Binary Array](./javascript/Binary-Search-Array) |

| x     | Data Srtuctures |
| ----------- | ----------- |
| 1 | [Linked List](./Data-Structures/linkedList) |
| 2 | [Stacks & Queues](./Data-Structures/stacksAndQueues) |
| 3 | [Stacks With Queue](./Data-Structures/queueWithStacks) |
| 4 | [FIFO Animal Shelter](./Data-Structures/fifoAnimalShelter) |
| 5 | [Multi Brackets Valifation](./Data-Structures/multiBracketValidation) |
| 6 | [Tree](./Data-Structures/tree) |
| 7 | [Fizz Buzz Tree](./Data-Structures/fizzBuzzTree) |
| 8 | [Selection Sort Array](./Data-Structures/SelectionSort) |
| 9 | [Merge Sort Array](./Data-Structures/mergeSort) |
| 10 | [Quick Sort Array](./Data-Structures/quickSort) |
| 11 | [Hash Table ](./Data-Structures/hashTable) |
| 12 | [Repeated Word ](./Data-Structures/hashTable/reapeated-word) |
| 13 | [Tree Intersection](./Data-Structures/tree-intersection) |
| 14 | [Left Join](./Data-Structures/leftJoin) |


text:
# webphone-examples

This repository contains two examples using the Teravoz WebRTC library.

The source code can be found at examples/ path.

## Examples

### floating-phone

It implements the UI of a webphone that can be dragged around the window. This example
stands for a dynamic and flexible webphone on your screen. It may be embedded in a CRM.

  * How to run ?

    - Open the examples/floating-phone/index.html file

    - Place your API-KEY [(Teravoz API Documentation)](https://developers.teravoz.com.br/#webrtc) on the embed script

    - Go to examples/floating-phone/assets/js/main.js line 69

    - Insert your peer credentials

    - Execute the following commands in the bash:

    ```shell
      npm install

      npm run examples
    ```

    - Using Docker: Execute the following commands in the bash:

    ```shell
      docker build . -t webphone-examples

      docker run -d --net host webphone-examples
    ```

    - Access the address http://localhost:3068/floating-phone

### using-dialpad

It also implements the UI of a webphone using a dialpad. This example
stands for a more complex way to build an UI using the WebRTC Teravoz Library.

  * How to run ?

    - Open the examples/using-dialpad/index.html file

    - Place your API-KEY [(Teravoz API Documentation)](https://developers.teravoz.com.br/#webrtc) on the embed script

    - Execute the following commands in the bash:

    ```shell
      npm install

      npm run examples
    ```

    - Using Docker: Execute the following commands in the bash:

    ```shell
      docker build . -t webphone-examples

      docker run -d --net host webphone-examples
    ```

    - Access the address http://localhost:3068/using-dialpad

## Important Notes

Those examples are only starting points to build your own UI using the WebRTC Teravoz Library, meaning that it should NOT be used in production environments.

repository: teravoz/webphone-examples

gha_language: Dockerfile

repo_name: teravoz/webphone-examples


text:
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.6.1](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.6.0<EMAIL_ADDRESS>(2019-02-28)

**Note:** Version bump only for package @wetransfer/concorde-cookie

# [1.6.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2019-02-28)

### Bug Fixes

* build packages before publishing ([#45](https://github.com/WeTransfer/concorde.js/issues/45)) ([b6154cb](https://github.com/WeTransfer/concorde.js/commit/b6154cb))

### Features

* expose modules under WT global namespace ([#203](https://github.com/WeTransfer/concorde.js/issues/203)) ([6433238](https://github.com/WeTransfer/concorde.js/commit/6433238))
* implement debounce module ([#26](https://github.com/WeTransfer/concorde.js/issues/26)) ([31c7d99](https://github.com/WeTransfer/concorde.js/commit/31c7d99))

# [1.5.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-08-14)

### Bug Fixes

* build packages before publishing ([#45](https://github.com/WeTransfer/concorde.js/issues/45)) ([b6154cb](https://github.com/WeTransfer/concorde.js/commit/b6154cb))

### Features

* expose modules under WT global namespace ([#203](https://github.com/WeTransfer/concorde.js/issues/203)) ([6433238](https://github.com/WeTransfer/concorde.js/commit/6433238))
* implement debounce module ([#26](https://github.com/WeTransfer/concorde.js/issues/26)) ([31c7d99](https://github.com/WeTransfer/concorde.js/commit/31c7d99))

# [1.4.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-06-14)

# [1.3.2](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-02-14)

### Bug Fixes

* transpile ie9 compatible code ([#67](https://github.com/WeTransfer/concorde.js/pull/67)) ([515e393](https://github.com/WeTransfer/concorde.js/commit/515e393))

# [1.3.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-02-09)

# [1.2.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-01-15)

# [1.1.0](https://github.com/WeTransfer/concorde.js/compare/@wetransfer/concorde-cookie@1.0.0<EMAIL_ADDRESS>(2018-01-12)

# 1.0.0 (2017-12-21)

* Initial release


text:
simple-release-plugin
=====================

Maven plugin for simple releasing. It only updates automatically pom version as be needed.

Usage:

simple-release-plugin set param "newVersion" in execution context, used as input for version:set (maven-version-plugin)

To make release (it is required project version be a snapshot):

com.github.nsd-tools.maven.plugins:simple-release-maven-plugin:simple-release versions:set -DdoRelease=true

To make snapshot (it is required project version be a release):

com.github.nsd-tools.maven.plugins:simple-release-maven-plugin:simple-release versions:set -DdoRelease=false

repository: nsd-tools/simple-release-maven-plugin

repo_name: nsd-tools/simple-release-maven-plugin


text:
# Python function for watermarking images

This is a python function for watermarking images.

Image for watermarking is saved as watermark.png.
Watermark is placed in bottom right corner of the input image with padding of 20px.
Image needs to be wider and higher than watermark + padding.

gha_language: Python


text:
---
templateKey: blog-post
title: 2017 Week 7 Highlights
date: 2017-11-03T23:17:00.000Z
description: 2017 Week 7 Highlights
tags:
  - Fantasy Football 2017
  - Week 7
---
## Bearly Fantasy vs. Imma need abouttreefitty

Bearly Fantasy was feeling themselves after a nice performance last week against the formidable Micheal Scarns. Bearly Fantasy has also felt pretty good after they reevaluated their fantasy strategy by actually playing the players that gave them the most points. They figured that their bench had won enough games for the season, it was about time for the starting group to win. Russell Wilson gave Bearly Fantasy some hope, but then was quickly dashed when Fournette said "screw you guys, im going home" and gave Bearly Fantasy a great big goose egg. Essentially, Jordan Reed and LeSean McCoy double teamed Bearly Fantasy and was all like "imma need abouttreefittyy wants smoosh smoosh" and took advantage of their innocence.

**Imma Need Abouttreefitty wins: 150.8 - 123.6 **

## Let_Me_Cool_That_Down vs. The Micheal Scarns

After a tough loss last week, Anthony learned the hard lesson that people who are suspended and or on bye, have a hard time producing points. So good thing Anthony looked at his lineup and took suspended Zeke Elliot out of his lineup. WRONG. The NFL was all like, "whateva, whateva I do what I want" and for no reason reinstated Elliot. To make matters worse, Zeke disregarded the lube and continued to plow the helpless Anthony with 41 points on his bench.  Carter said I'm an independent fantasy owner who don't need no defense. This was a ballsy move, but proved to show just enough balls for the win.

**The Micheal Scarns Win: 128 - 89.4 **


text:
---
layout: post
title: "Seattle Squeeze"
excerpt: "Personal"
categories: personal
comments: false
share: true
---

![](https://static.seattletimes.com/wp-content/uploads/2019/01/urn-publicid-ap-org-426e8295e4804ed383c3a8c323239ac2Seattle_Traffic_Squeeze_12617-780x384.jpg)

For those who are not familiar with this fact, Seattle has a huge traffic issue. During rush hours, it can literally take 45 minutes to go 1/2 a mile to enter the on ramp to I-5. The issue is almost all major jobs are located in the same area, downtown, so everyone has to journey one of the two major aortae, I-5 or I-90, to get there. This in turn has drove living quarters around the downtown area through the roof because, well, who wants to drive over 2 hours a day to go to your shitty job?

Anyway, this week Seattle is experiencing something known as the 'Seattle Squeeze'; a 3-week long project where the city is tearing down the iconic Alaskan Viaduct (a major highway-ish road that connects west and south Seattle directly to downtown that overlooks the Puget Sound) and re-roading this area to include a tunnel and other various roadways to enter downtown.

Why is this being down? One word: earthquakes. An earthquake would absolutely demolish this viaduct, so safer driving is needed.

And this is true; there is no doubt that the Alaskan Viaduct, albeit beautiful and awesome, is needed to be...say....downsized.

But now through these 3 weeks, we all in the Emerald City have to live through the Seattle Squeeze!!

The city has been trying to prepare people for this 3-week event for over a year. The hype of this has been slowly crescendoing and has hit its apogee this Monday. The city has been pleading with their citizens such things like 'be careful', 'brace yourself', 'use vacation time if you have it', 'work at home', etc. Side note: I find it insulting that the city's official word to their people is 'use vacation time' and 'work at home'. That is not a solution; that is a government completely in disarray and has no solution.

So you may ask two questions:

1. Does the Seattle Squeeze affect me?

2. Is is that bad?

Well, to answer 1., it does tremendously. I take the Viaduct every day for work and this pretty much destroys my commute.

To answer 2., it is. Constant updates on my phone about the commute, continuous warnings about drive times flood my local newsfeed.

So what is my solution: I moved.

Yes my friends, I moved.

I have pitched my proverbial tent to an area near a few other tents that remove me from this Squeeze.

Now my commute time is 15 minutes.

Once the Squeeze is over (they say 3 weeks........yeah right), I may return back to my former life. I may not. It depends on how this goes.  I'm going homeless!


text:
# Furiganize

Furiganize is replace Kanji to Hiragana. Powered by [Yahoo Furigana Service](http://developer.yahoo.co.jp/webapi/jlp/furigana/v1/furigana.html)

## Installation

```
$ gem install furiganize
```

## Usage

Show help

```
$ furiganize -h
```

Basic usage

```
$ furiganize -a [YOUR_YAHOO_APP_ID] -g 3 '小学三年生が書いたこの文章は魑魅魍魎' # => 小学三年生が書いたこのぶんしょうはちみもうりょう
```

or, you can use stdin.

```
$ echo '小学三年生が書いたこの文章は魑魅魍魎' | furiganize -a [YOUR_YAHOO_APP_ID] -g 3
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec furiganize` to use the gem in this directory, ignoring other installed copies of this gem.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/furiganize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

repository: Peranikov/furiganize

repo_name: Peranikov/furiganize


text:
# AntennaPod Single Purpose

## What is AntennaPod SP?

AntennaPod SP is a modified version of AntennaPod which lets podcasters build *single-purpose apps* for their podcast(s).

## What is a single-purpose app?

A single-purpose app is an app that lets the user only do one thing: Listen to a preset list of podcasts. There is absolutely *no* setup or configuration process. As soon as the user starts the app, a list of episodes is presented that can be downloaded and listened to.

## Who is a single-purpose app for?

A single-purpose app that is based on AntennaPod SP is specifically made for people who

- have never listened to podcasts before

- occasionally listen to podcast, but have never used a full-fledged podcatcher before.

AntennaPod SP's main goal is to be *easy to use*. Therefore, it only focuses on the basic features for consuming podcasts and requires absolutely *no configuration* by the user.

## What features does a single-purpose app have?

- Download and playback of episodes
- Automatic download of the most recent episodes
- Automatic update of the feed(s) every n hours
- Automatic deletion of episodes after the amount of space used by the app exceeds a given limit
- Support for displaying shownotes
- Support for chapters (ID3, VorbisComment, Podlove Simple Chapters)
- Sleep timer

All important parameters of these features can be adjusted by the podcaster in a global configuration file.

*Please note that support for multiple feeds is not finished yet, but will be implemented very soon*

There are also plans for adding the following (optional) features:

- support for feeds and episodes that require authentication
- and more...

## But what if the user gets fed up by all these single-purpose apps that you have to install for every single podcast?

Since a single-purpose app are supposed to attract *new* podcast listeners, there should be a way to let them switch to something more sophisticated once they become more interested into podcasts. Therefore, a single-purpose app looks for other installed single-purpose apps on the user's device once it is started. If other single-purpose apps are found, the user is given the choice to install podcatcher (by default, this podcatcher is [AntennaPod](https://github.com/danieloeh/AntennaPod), but this can also be changed in the configuration file by the podcaster). If the user accepts, all feeds from single-purpose apps are subscribed to by the podcatcher once it is installed.

## Who is using AntennaPod SP?

So far, the app for listening to the [Einschlafen Podcast](http://einschlafen-podcast.de/) is based on AntennaPod SP. Its source code can be found [here](https://github.com/danieloeh/EinschlafenPodcastAndroidApp).

## How do i build an app for my podcasts that is based on AntennaPod SP?

Basically, you need to fork this repository, install an Android SDK, modify two configuration files to enter your feeds and the name of your podcast, and add icons and assets for your app. A detailed guide on how to build your very own single-purpose app can be found in the [Wiki](https://github.com/danieloeh/AntennaPodSP/wiki/Building-AntennaPod-SP).

## License

AntennaPod SP is licensed under the MIT License. You can find the license text in the LICENSE file.

## Donate

Bitcoin donations can be sent to this address:
1DzvtuvdW8VhDsq9GUytMyALmsHeaHEKbg

repository: tobybaier/AntennaPodSP

repo_name: tobybaier/AntennaPodSP


text:
# Cocleaning Workflow #

## Description ##

Cocleaning is the process in which Whole Exome Sequencing alignments are optimized by comparing paired tumor/normal samples. The WXS BAM files that are downloadable from the GDC Portal have been co-cleaned after alignment1.

## Overview ##

The DNA-Seq alignment cocleaning workflow comprises two steps:
* Base quality score recalibration (BQSR):  Base quality scores are reassessed based on errors across both samples.
* Indel realignment: Insertion-deletion mutations are realigned to minimize the number of base mismatches.

### Tools ###

Both cocleaning steps are implemented using two functions of the Genome Analysis Toolkit (GATK): BaseRecalibrator and IndelRealigner2.

## References ##
1. [GDC DNA-Seq Pipeline Documentation](https://docs.gdc.cancer.gov/Data/Bioinformatics_Pipelines/DNA_Seq_Variant_Calling_Pipeline/)
2. [GATK Website](https://software.broadinstitute.org/gatk/)

## External Links ##
* N/A

Categories: Workflow Type

repository: NCIP/gdc-docs

branch_name: refs/heads/develop

repo_name: NCIP/gdc-docs


text:
# ViaBTC 📈

[![Build Status](https://img.shields.io/github/actions/workflow/status/krmbzds/viabtc/test.yml?branch=develop)](https://github.com/krmbzds/viabtc/actions/workflows/test.yml) [![Downloaded](https://img.shields.io/gem/dt/viabtc.svg)](https://rubygems.org/gems/viabtc) [![Coveralls](https://img.shields.io/coveralls/github/krmbzds/viabtc/develop)](https://coveralls.io/github/krmbzds/viabtc?branch=develop) [![Gem Version](https://img.shields.io/gem/v/viabtc.svg)](https://rubygems.org/gems/viabtc) [![RubyDoc](https://img.shields.io/badge/rubydoc-info-blue.svg)](https://www.rubydoc.info/gems/viabtc/)

An HTTP client to interface with the open-source [ViaBTC Exchange Server][ViaBTC Exchange Server Repo].

## Installation

Add `viabtc` to your Gemfile and run `bundle` OR install it yourself with `gem install viabtc`.

## Configuration

If using **Rails**, create a file named `viabtc.rb` under `config/initializers` and add the following block of code.

```rb
ViaBTC.configure do |config|
  config.http_base_url = 'http://localhost:18080'
end
```

If not, add it anywhere in your code that runs before a new client is initialized. Read more at: 📖 [Configuration Wiki](https://github.com/krmbzds/viabtc/wiki/Configuration)

## Usage

Create a new instance:

```rb
viabtc_http_client = ViaBTC::HTTP::Client.new
```

Make an API request:

```rb
viabtc_http_client.market_status(market: 'ETHBTC')

#=> {"error"=>nil, "result"=>{"low"=>"0", "period"=>86400, "last"=>"0", "high"=>"0", "open"=>"0", "volume"=>"0", "close"=>"0", "deal"=>"0"}, "id"=>0}
```

## Support

#### Ruby Versions Tested Against

- ✅ `3.2.2` (stable)
- ✅ `3.1.4` (stable)
- ⏳ `3.0.6` (security maintenance)
- 🪦 `2.7.8` (end of life)

#### ViaBTC Exchange Server API Support

- 📖 [HTTP Protocol](https://github.com/krmbzds/viabtc/wiki/API-Support#http-protocol)

| API Method | Corresponding Methods |
|---|---|
| `balance.query` | `#balance` |
| `balance.update` | `#withdraw` `#deposit` |
| `balance.history` | `#balance_history`  |
| `asset.list` | `#asset_list` |
| `asset.summary` | `#asset_summary` |
| `order.put_limit` | `#limit_sell` `#limit_buy` |
| `order.put_market` | `#market_sell` `#market_buy` |
| `order.cancel` | `#cancel_order` |
| `order.deals` | `#order_deals` |
| `order.book` | `#sell_orders` `#buy_orders` |
| `order.depth` | `#order_depth` |
| `order.pending` | `#pending_orders` |
| `order.pending_detail` | `#pending_order_details` |
| `order.finished` | `#finished_orders` `#finished_sell_orders` `#finished_buy_orders` |
| `order.finished_detail` | `#finished_order_detail` |
| `market.last` | `#market_last` |
| `market.deals` | `#market_deals` |
| `market.user_deals` | `#user_executed_orders` |
| `market.kline` | `#market_kline` |
| `market.status` | `#market_status` |
| `market.status_today` | `#market_status_today` |
| `market.list` | `#market_list` |
| `market.summary` | `#market_summary` |

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [RubyGems][RubyGems].

## Contributing

1. [Fork the repository][Fork]
2. Switch to develop branch (`git checkout develop`)
3. Create your feature branch (`git checkout -b my-new-feature`)
4.  Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request

### Donations ❤

You can donate me at [Liberapay][Donation]. Thanks! ☕

## Is it any good?

Yes.

## License

Copyright © 2018-2023 [Kerem Bozdas][Personal Webpage]

This gem is available under the terms of the [MIT License][License].

[Donation]: https://liberapay.com/krmbzds/donate
[Fork]: http://github.com/krmbzds/viabtc/fork
[License]: http://kerem.mit-license.org
[Personal Webpage]: https://kerembozdas.com
[RubyGems]: https://rubygems.org
[ViaBTC Exchange Server Repo]: https://github.com/viabtc/viabtc_exchange_server

repository: krmbzds/viabtc

gha_language: Ruby

repo_name: krmbzds/viabtc


text:
# Heat

##### Editorial
Solution:
	We have to divide a tree (having $N$ nodes) into some number of trees, each of them having exactly $K$ node present in them.
	This follows that number of trees we have in the end should be $N / K$ and for that to happen $N$ should be a multiple of $K$.
	Let $X = N / K$, we root the tree at any node of our choice then we do a DFS from that each subtree returning numbre of nodes
	it has and if it is divisible by $K$ we increse a count variable say $c$ and after the DFS is over we check whether or not $c == X - 1$ (as $X - 1$ number of edges needs to be cut in order to make $X$ partitions).
	If true we print Yes, No otherwise.
	This greedy works because we can't cut any edges in a subtee with number of nodes less than $K$ because the atleast on tree will have less $K$ number of nodes, and when we find a subtree with number of node equal to $K$ we have to cut it other wise we will have atleast one tree with number of nodes greater that $K$.

##### Solution (C++)

```cpp
#include <bits/stdc++.h>
#define MAX (ll)(1e5+3)

using namespace std;

vector <int> gr[MAX];
int n, k, cc = 0;
int subtree (int node, int par) {
    int ss = 1;
    for (int x : gr[node]) {
        if (x != par) {
            int xx = subtree (x, node);
            cc += xx % k == 0;
			ss += xx;
        }
    }
    return ss;
}

int main () {
    bool fl = 1;
    cin >> n >> k;
    set <int> se;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        gr[a].push_back (b);
        gr[b].push_back (a);
    }
    if (n % k) {
        fl = 0;
    }
    if (fl) {
        subtree (1, -1);
    }
    if (fl && (cc == n / k)) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

```
##### Time complexity: O (N)
##### Space complexity:	O (N)


text:
# AREditor
An online code editor based on [CodeMirror](https://codemirror.net/).

---

# Feature
- [x] Support language: Python, Fortran
- [x] Keywords auto-completion
- [x] Code highlight, Current edit line highlight, Match brackets highlight
- [x] Multiple theme support
- [x] Vim mode

---

# TODO
- [ ] Save to disk
- [ ] Support more language
- [ ] Lint
- [ ] Any words hint
- [ ] Search in code

---
# LICENSE
AREditor is released under the MIT license.