text:
# Table of content
* [overview](#overview)

# overview

This file is about "what" the code does and "why", to know "how" read the comments in the code.

Melissa_server is a parallel and independant component that gathers the data from the simulations. The data can arrive in any order, and at any time, from any simulation.
It starts before the first simulation, and stops after the end of the last simulation.
Melissa_server computes the iteratives statistics in parallel from the in-transit data. The MPI processes of the server are mostly independant and not syncronized, except at the begining and at the end of the study.
It checkpoints regularly, and communicates with the launcher about the status of the simulations.
All the available iterative statistics are implemented in the stats folder.
Melissa_server keeps the iteratives statistics in memory until the end of the study.

# server.cxx

## overview

Melissa_server can be decomposed in tree parts:
- melissa_server_init
- melissa_server_run
- melissa_server_finalize

## melissa_server_t

melissa_server_t is a data structure used to carry informations between the calls to the server functions. It contains everything the server needs all along its run time.

## melissa_server_init

This function is called once when the server starts.
It firts allocate the server_handle that will contain every variable that the server needs to run, and initialize some variables.
This data structure will be passed as a pointer to the other functions.

Then the server creates 5 or 6 zetroMQ sockets.
The first one is the connexion_responder, and is a req/rep comunication chanel with the simulations.
The optional deconnexion_responder is an other req/rep comunication chanel with the simulations.
 It should be enabled in the cmake command by -DCHECK_SIMU_DECONNECTION. This option enable the simulation to ask the server befor deconecting.
The data_puller is a pull port for receiving simulation data.
The text_puller and text_puller are one way comunication chanels to and from the launcher.
The text_requester is a req/rep comunication chanel with the launcher.

Melissa_server inits MPI and get the options given by the launcher through the comand line, open the comunication ports.

Each MPI process sends its node names to the launcher, and initialize all the fields and fault tolerance structures.

## melissa_server_run
This is the main loop of Melissa_server.
In this loop, melissa server checks the heartbeats of the simulations and the launcher.
The launcher sends a regular heartbeat, but for the simulations, Melissa Server uses the data messages. That's why one have to estimate the diration of a simulation timestep to define the right timeout.
Melissa Server then checkpoints if it didn't do it for the last check_interval time interval.

Then, it enters the poll on the messages ports.

Melissa server try to get messages on the three or four ports.
If no message is detected after 100 ms, then the loop cycle.
Else, melissa first checks the launcher messages, then the simulation connexion messages, and finaly the data messages.

Only rank 0 can receive simulation connexion messages. It then replies with the server informations.
Before the firs connexion, all the other ranks are blocked in the mpi_bcast. When the rank 0 recieve its first message, it enters the mpi_bcast and unlock the other processes.
At this point, Melissa Server creates the right number of field data structures, but doesn't allocate the memory for the statistics, as it doesn't know the size of the fields yet.

When melissa server receive a data message, it get the corresponding field data structure and allocate it it is the first message from this field.
Then it updates the simulation vector to keep track of which simulations sent which timesteps. It it is the first data message and the server is in a "restart" state, it will try to read the checkpointed statistics from the checkpoint files.
If the message corresponds to a timestep and a simulation that has already be computed, then Melissa Server drops it and continue.
otherwhise, it updates all the statistics required by the user on that field.

After that, the server counts the number of finished simulations and cycle the main loop until all the simulations sent all their messages.

## melissa_server_finalize

Release all the ports and deallocate memory.

repository: melissa-sa/melissa

branch_name: refs/heads/master

extension: md

gha_language: C

license_type: permissive

repo_name: melissa-sa/melissa


text:
# Google Funding Choices

Funding Choices is a Consent Management Platform (CMP) that integrates with Google's advertising services to help you gather your visitors' consent for privacy regulations. More information can be found [on support.google.com](https://support.google.com/fundingchoices/#topic=9437573)

## Closed Beta

The amp-consent configuration for Funding Choices is in a closed Beta, and usage of this feature has been limited to a small batch of publishers. However, Funding Choices is looking to open up access for general availability in the near future!

## Example

```html
<amp-consent id="consent" layout="nodisplay" type="googlefc">
  <script type="application/json">
    {
      "clientConfig": {
        "publisherIdentifier": "id"
      }
    }
  </script>
</amp-consent>
```

## Configuration (`clientConfig`)

| Attribute           |  Type  | Mandatory | Description                                                                                |
| ------------------- | :----: | :-------: | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| publisherIdentifier | String |    yes    | This is your publisher identifier that uniquely identifies your Google publisher account. It will be provided in the generated amp-consent extension. |

repository: ampproject/amphtml

branch_name: refs/heads/main

gha_language: JavaScript

repo_name: ampproject/amphtml


text:
# KiCad Plugins

Collection of self-made KiCad plugins.

## Track Arc Generator

This plugin creates arc tracks based on multiple small segments. Track parameters like net or width are applied to the created arc.

1. Select/Highlight two track segments
2. Execute the plugin by clicking the button
3. Enter (modify) the arc radius and segment count based on your needs
4. Take a look on you new arc track!

Currently, the script does not check, if the arc radius fits the selected trace lengths.

## Installation

Copy the desired plugin folder into KiCads plugin directory and restart KiCad.

license: MIT


text:
# Server Setup

## User Groups

* sudoers
* a3-mission-uploaders
* a3-log-viewers

### a3-mission-uploaders
Read-write access to mpmissions folder

### a3-log-viewers
Read access to logs folder

## Scheduled tasks

A3Server-related tasks are run via crontab from the same user as the A3Server.

repository: HellenicMilsim/serverconfig

repo_name: HellenicMilsim/serverconfig


text:
---
layout: post
title: 'Leetcode 95: Unique Binary Search Trees II'
date: '2018-06-16 15:48'
tags:
  - Leetcode
---

# Question
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n.

Example:
```
Input: 3
Output:
[
  [1,null,3,2],
  [3,2,null,1],
  [3,1,null,null,2],
  [2,1,3],
  [1,null,2,null,3]
]
Explanation:
The above output corresponds to the 5 unique BST's shown below:

   1         3     3      2      1
    \       /     /      / \      \
     3     2     1      1   3      2
    /     /       \                 \
   2     1         2                 3
```

# Solution
```python
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def generateTrees(self, n):
        """
        :type n: int
        :rtype: List[TreeNode]
        """
        if n == 0:
            return []
        return self.generateTree(1, n + 1)

    def generateTree(self, low, high):
        n = high - low
        if n == 0:
            return [None]
        elif n == 1:
            return [TreeNode(low)]
        else:
            res = []
            for root in range(low, high):
                left = self.generateTree(low, root)
                right = self.generateTree(root + 1, high)

                for l in left:
                    for r in right:
                        rNode = TreeNode(root)
                        rNode.left = l
                        rNode.right = r
                        res.append(rNode)
            return res
```

gha_language: HTML

gha_license_id: MIT


text:
> Project Archived: The code works perfectly well but the author is no longer using the library.

---

# GWT QR Code

[![Build Status](https://secure.travis-ci.org/realityforge/gwt-qr-code.svg?branch=master)](http://travis-ci.org/realityforge/gwt-qr-code)
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.realityforge.gwt.qr_code%22)

The library is a GWT port of [QR-Code-generator](https://github.com/nayuki/QR-Code-generator) that
enables the generation of [QR Codes](https://en.wikipedia.org/wiki/QR_code). This original project aims
"... to be the best, clearest QR Code generator library ... The primary goals are flexible options and
absolute correctness". The best place to read about the original project is the project's
[website](https://www.nayuki.io/page/qr-code-generator-library).

Core features:

* Significantly shorter code but more documentation comments compared to competing libraries
* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
* Output formats: Raw modules/pixels of the QR symbol, SVG XML string, HTML5 canvas
* Encodes numeric and special-alphanumeric text in less space than general text

Manual parameters:

* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one
* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
* User can create a list of data segments manually and add ECI segments

## Quick Start

The simplest way to use the library is to add the dependency into the build system. i.e.

```xml
<dependency>
   <groupId>org.realityforge.gwt.qr_code</groupId>
   <artifactId>gwt-qr-code</artifactId>
   <version>0.03</version>
</dependency>
```

Then add the snippet `<inherits name='org.realityforge.gwt.qr_code.QrCode'/>` into the `.gwt.xml` module file. Then
you can generate the svg via:

Render a url qr code as SVG:

```java
// Generate a simple text base url QR Code with High error correction
final QrCode qrCode = QrCodeTool.encodeText( "http://realityforge.org", Ecc.HIGH );

// Render the qr code as a svg element
final Element div = DomGlobal.document.createElement( "div" );
div.setAttribute( "style", "width:200px" );
div.innerHTML = qrCode.toSvgString( 2 );
DomGlobal.document.body.appendChild( div );
```

Render a unicode qr code on canvas element:

```java
// Generate a 🎉 QR Code with medium error correction
final QrCode qrCode = QrCodeTool.encodeText( "\u200E\uD83C\uDF89", Ecc.MEDIUM );

final HTMLCanvasElement canvas = (HTMLCanvasElement) DomGlobal.document.createElement( "canvas" );
final int border = 2;
// 8 pixels per "module"
final double scale = 8;
// Draw the canvas
qrCode.drawCanvas( scale, border, canvas );
DomGlobal.document.body.appendChild( canvas );

```

Manually render a numeric qr code:

```java
// Generate a QrCode using manual process
final QrSegment segment = QrCodeTool.makeNumericSegment( "3141592653589793238462643383" );
final QrCode qrCode = QrCodeTool.encodeSegments( Collections.singletonList( segment ), Ecc.HIGH, 5, 5, 2, false );
for ( int y = 0; y < qrCode.getSize(); y++ )
{
  for ( int x = 0; x < qrCode.getSize(); x++ )
  {
    final boolean isPixelBlack = qrCode.getModule( x, y );
    // paint x, y, isPixelBlack
  }
}
```

# More Information

For the source code and project support please visit the [GitHub project](https://github.com/realityforge/gwt-qr-code).

# Contributing

The library was released as open source so others could benefit from the project. We are thankful for any
contributions from the community. A [Code of Conduct](CODE_OF_CONDUCT.md) has been put in place and
a [Contributing](CONTRIBUTING.md) document is under development.

# License

GWT QR Code Generator is licensed under [MIT License](LICENSE).

# Credit

This library is a reworking of the magnificent [QR-Code-generator](https://github.com/nayuki/QR-Code-generator)
by Nayuki Minase. The changes made the library GWT compatible and made it easier for the GWT compiler to optimize.
Support was also removed for the Kanji optimization. Any bugs are likely caused by the current author while the
credit for the code all goes to the original author.

repository: realityforge/gwt-qr-code

repo_name: realityforge/gwt-qr-code


text:
# PHP
Topic for the second half of the semester

## Resources
  - Official home page: php.net

## Properties
  - Server-side, needs Apache or Nginx, mostly works as a pluggable part
    - Before serving a PHP code, runs it first, and sends the output to the client
  - "hackable", lots of unintended solutions, workarounds
    - pretty much its worse and best property since its poor design
    - Hack is a superset developed by Facebook
  - Modular, features can be turned on and off on a specific server
  - A valid HTML is a valid PHP
  - Difference between single and double quote: single quote makrs a raw string (escapes special characters like \n)
  - Double quote provides string interpolation
  - No variable declaration, assignment is declaration, variables are function scoped and start with dollar sign
  - Types: Booleans, Strings like JS, but numbers are divided into Integers and Floats
  - Bool value is case insensitive, but convention is uppercase
  - PHP arrays are hashmaps where the key is the index
  - `+` is number add operator
  - `.` is string concat operator
  - `<=>` comparator operator, returns with `[-1, 0, 1]` based on two side compare
  - References are not really used, but can be obtained by `@$variable`
  - backtick operator runs bash commands
  - very caothic, no naming conventions whatsoever, many developers contributed to the language

## Resources for the class
  - WinSCP: webprogramozas.inf.elte.hu, pandora credentials (lowercase username)
  - http://webprogramozas.inf.elte.hu/hallgatok/ygdyb2/
  - Add VS Code editor to WinSCP editors as an external editor at the top


text:
<!--
Copyright The Shipwright Contributors

SPDX-License-Identifier: Apache-2.0
-->

---
title: surfacing-errors-to-buildrun
authors:
  - "@dalbar"
reviewers:
  - "@qu1queee"
  - "@HeavyWombat"
approvers:
  - "@adambkaplan"
  - "@sbose78"
creation-date: 2021-09-10
last-updated: 2021-09-10
status: draft

---

## Release Signoff Checklist

- [ ] Enhancement is `implementable`
- [ ] Design details are appropriately documented from clear requirements
- [ ] Test plan is defined
- [ ] Graduation criteria for dev preview, tech preview, GA
- [ ] User-facing documentation is created in [docs](/docs/)

## Summary

This ship provides a mechanism to surface errors in the build process
into BuildRun objects granting more visibility into
without being Tekton/Implementation specific. To
achieve this goal, we introduce two new generic results
`shp-error-reason` and `shp-error-message`, that a TaskRun can emit
and a BuildRun can pick up.

## Motivation
A strategy's container logs differ for their steps and utilized
tooling. Therefore, finding an error message and extracting the error's reason is challenging for machine processing and consumption from
third parties due to the logs' heterogeneous nature and the need to parse
`stdout`.
For a better user experience, we propose that a strategy author
can define the failure reason in a compact way that can
be represented in the BuildRun status, for example, through TaskRun results.
Build strategy authors are already aware of this tooling as they can emit the size
digest of the output image similarly, see [the BuildKit strategy](https://github.com/shipwright-io/build/blob/main/samples/buildstrategy/buildkit/buildstrategy_buildkit_cr.yaml#L65).

Additionally, the proposal enables a user to keep the troubleshooting on the BuildRun level and only descend further into Tekton
specifics when necessary.

### Goals

- Allow build strategy users to define error details that will show up on the BuildRun status.
- Allow our steps like the git step to also use this mechanism to provide additional error details in the BuildRun status

### Non-Goals

- The specifics of errors regarding tooling are not part of this proposal. Neither is their means for reporting them. Errors highly
  depend on each strategy

## Proposal

We propose to introduce two generic results for errors:
`shp-error-message` and `shp-error-reason`.  The result
`shp-error-reason` has a machine-recognizable value that is ideally prefixed
with the problematic technology, for example, `git` in case of missing
a secret. The result `shp-error-message` should be descriptive text to
give the user enough information to troubleshoot the BuildRun.  A task
run emits the new results as Tekton results.
Finally, we must extend the BuildRun controller
logic to propagate the new results into the BuildRun CRD's
`status.failureDetails` property.
Moreover, there exists a pointer to the failed container and pod under `status.failedAt` to give
a user hints for debugging his problem:

```go
 type FailedAt struct {
           Pod       string `json:"pod,omitempty"`
           Container string `json:"container,omitempty"`
   }
```

However, we are worried about the sprawl of our API, and having two failure-related pointers only makes that sprawl worse.
Our proposal for error results is yet another pointer to the underlying reason why a build has failed.
Therefore, we propose to merge the `status.failedAt` property into `status.errorDetails` to achieve a semantic grouping.

BuildRun with new error results and merged `status.failedAt`:

```yaml
status:
    failure:
      reason: git-auth-ssh
      message: Authentication failed for ...
      location:
        pod: aPod
        container: aContainer
```

We do not suggest mutating the `status.conditions.message` field
since it contains valuable hints to troubleshoot on a lower level if
the propagated error message and reason is not sufficient.

### User Stories

#### Story 1 - Developer and direct user of shipwright perspective
As a user of Shipwright and developer, I want to identify why my
BuildRun is in a failed state without going through the lengthy
process of identifying the correct container and manually processing
its logs.
#### Story 2 - Github Actions developer (third party application developer)
As a third-party application developer that uses shipwright under the hood, I want to supply my users with meaningful hints to fix their builds, thus requiring a straightforward API to consume error details.

### Implementation Notes

`tbd in the next phase of the proposal`

### Test Plan

`tbd in the next phase of the proposal`

### Release Criteria

`tbd in the next phase of the proposal`

### Risks and Mitigations
Tekton results are limited in size (4096 bytes) which applies to the
proposed error results (see [code ref](https://github.com/kubernetes/kubernetes/blob/96e13de777a9eb57f87889072b68ac40467209ac/pkg/kubelet/container/runtime.go#L632)).
We should document this limitation.

There is no strict typing that would prevent strategy authors from
using proper error reasons (value has to be a `string`). So two authors can use different names for
the same error reason or use the same name for different errors. To
prevent these issues, we need clear documentation and consistent error reporting in our strategies.

Ideally, this ship requires that TaskRuns emit results in error
cases. However, Tekton currently does not emit any results for failed
TaskRuns. Therefore, I have reached out to the Tekton community to
include that functionality
(https://github.com/tektoncd/pipeline/issues/3749).  For the case that
the request is denied, for example, because of Tekton's API design
philosophy, I have researched a workaround. In every TaskRun step's
status, there is a message property (JSON string), including the step
results. We can extract the failed step and use it to access the correct message property.

Our proposal merges `status.failedAt` and therefore has API breaking changes that third party tools rely on. To mitigate the risks for breaking those applications,
we propose to keep `status.failedAt`. With the release of the surfacing error results feature, we intend to deprecate it and educate our users with a proper migration
strategy that shall be added to our docs.

# Drawbacks
Since we only expose a field for an error's message and reason, we do
not allow strategy authors to introduce additional custom fields for
clarifying the build problem.

We assume that a BuildRun fails after the build throws an error, and
build steps are executed in sequence, thus making it sufficient to have a
single failure slot for a BuildRun.

If the container exits with a non-zero exit code, we ignore error results including the strategy author's contributions to errors.
To surface errors, the container strictly requires a completed TaskRun with failed reason.

## Alternatives
In the first of the alternatives, we used the `status.results` field to publish errors as introduced in ship `0023`.
The drawback is that results are commonly associated with success. Additionally, it makes looking up errors more inconvenient
since `results` is a list of key/value pairs.

Variant 1

```yaml
...
  status:
    results:
      - name: shp-error-reason
        value: git-ssh-auth
      - name: shp-error-message
        value: Authentication failed for ...
```

Having specific structs for individual errors can provide the user
with even more details. However, I did not find any compelling
examples with practical fields while looking into git-based
errors. The user most likely is interested in the error message and
some recognizable error reason (or exit code) only. I am open to
counterexamples.

Variant 2
```yaml
...
   status:
     shpErrors:
        - name: shp-source-git-error
          git:
            message: Authentication failed for ...
            reason: git-ssh-auth
            customFields: ...
```

Variant 3

The third variant is the same proposal for error details without merging `status.failedAt`. One drawback of this variant is that there would be two distinct pointers
to the same failure (sloppy API design-wise). The advantage on the other hand is that we do not introduce any breaking API changes. However, since we are in alpha,
we can afford to introduce breaking API changes for the sake of a cleaner API design.

Variant 4

The fourth variant is adding error results to the conditions field of the `BuildRun` e.g:

```yaml
conditions:
  - lastTransitionTime: "2021-10-12T16:57:07Z"
    message: |
      "step-build-and-push" exited with code 1 (image: "icr.io/obs/codeengine/buildkit/builder@sha256:a11e2348f9ee40822fc28dcb501c57cd02ebd31fb441841bfe5c144cc9d77fc6"); for logs run: kubectl -n baran-test logs apparmor-build-buildrun-gkxld-zrrtv-pod-8qpkt -c step-build-and-push
    reason: Failed
    status: "False"
    type: Succeeded
  - lastTransitionTime: "2021-10-12T16:57:07Z"
    message: |
      The key is invalid for the specified target. Please make sure that the remote source exists, you have sufficient rights and the key is in the right format.
    reason: GitAuthSSH
    status: "False"
    type: ImageBuildSucceded
```

It seems to be the most idiomatic approach in K8s world. Other controllers would be able to consume them without worrying about the specific CRD. Tools like `kubectl` could also use its existing features for conditions to react to failures e.g. wait. Based on the conventions for conditions there are some possible downsides.

Conventions From [community repo](https://github.com/kubernetes/community/blob/4f95b9210536ee62165e0a186ef5fab19a8be63f/contributors/devel/sig-architecture/api-conventions.md):

> Controllers should apply their conditions to a resource the first time they visit the resource, even if the status is Unknown. This allows other components in the system to know that the condition exists and the controller is making progress on reconciling that resource.

Conditions are always present in the status. I don't think it is too noisy, but there was no consensus on this. In fact, reviewers felt providing the failing condition at the top level of the status made it easier for the human user to parse and consume. Also, the distinction of failures being a terminal or ending condition, vs. other conditions being intermediate or not permanent in their outcome, contributed to the desire to isolate the failing condition from the other condition.  For example, during a build run, a given condition would be `Unknown` and for a successful build would change to `False` if it was the reason a build run failed.

> Condition type names should describe the current observed state of the resource, rather than describing the current state transitions. This typically means that the name should be an adjective ("Ready", "OutOfDisk") or a past-tense verb ("Succeeded", "Failed") rather than a present-tense verb ("Deploying"). Intermediate states may be indicated by setting the status of the condition to Unknown.

Good naming would be key to avoid confusion specifically for the `type` property of conditions. The example above includes the current condition of type `Succeded`. As discussed above, we are not mutating it anyway. It then requires us to come up with a new condition type that indicates a failed build. However, that condition has the same meaning as the overall `Succeeded` field. Additionally, it does not solve having two failure pointers in separate places (see `failedAt`).

## Implementation History

tbd

repository: rolfedh/community

repo_name: rolfedh/community


text:
Hello There, Thanks for trying Hydra Music Bot!

*How to use me*
Send or forward a text message containing links and I will:
• In Download mode: download every link I support (or use /dl <links>)
• In Links mode: show direct download URLs for every link (or use /link <links>)
• In Ask mode: scan for supported links and ask you to choose download or links


text:
---
# Course title, summary, and position.
linktitle: Overview
summary: Machine learning is one of the most exciting directions in information technology today, and its application has penetrated into all aspects of life and is closely related to the daily lives of ordinary people. This article is a Learning Note for the newly published "Machine Learning" textbook from Tsinghua University, written by Professor Zhou Zhihua of Nanjing University.
weight: 1

# Page metadata.
title: Natural Language Processing
date: "2020-02-09T00:00:00Z"
lastmod: "2020-02-09T00:00:00Z"
draft: false  # Is this a draft? true/false
toc: true  # Show table of contents? true/false
type: docs  # Do not modify.

# Add menu entry to sidebar.
# - name: Declare this menu item as a parent with ID `name`.
# - weight: Position of link in menu.
menu:
  NLP:
    name: intro
    weight: 1
---

## Named Entity Recognition

- [A Survey on Deep Learning for Named Entity Recognitionarxiv.org](https://arxiv.org/abs/1812.09449)

## Relation Extraction

- [More Data, More Relations, More Context and More Openness: A Review and Outlook for Relation Extraction](https://arxiv.org/abs/2004.03186)

## Text Classification

- [Deep Learning Based Text Classification: A Comprehensive Review](https://arxiv.org/abs/2004.03705)

## Pre-trained Models

- [Pre-trained Models for Natural Language Processing: A Survey](https://arxiv.org/abs/2003.08271)

- [A Survey on Contextual Embeddings](https://arxiv.org/abs/2003.07278)

## Knowlege Graphs

- [A Survey on Knowledge Graphs: Representation, Acquisition and Applications](https://arxiv.org/abs/2002.00388)

- [Knowledge Graphs](https://arxiv.org/abs/2003.02320v2)

repository: litheory/academic-kickstart

repo_name: litheory/academic-kickstart


text:
# Fog of War research

I am [José Antonio Prieto](https://www.linkedin.com/in/japrietogarcia/), student of the
[Bachelor’s Degree in Video Games by UPC at CITM](https://www.citm.upc.edu/ing/estudis/graus-videojocs/).
This content is generated for the second year’s subject Project 2, under supervision of lecturer [Ricard Pillosu](https://es.linkedin.com/in/ricardpillosu).

## Introduction
### A little "sight" to the history of Fog of War
The history says that the terminology of "Fog" of War comes from the battlefield, reference to uncertainty in war.
Later, board games and videogames adopted the term.
### But, what is Fog of War
In board games and videogames, Fog of War is used to hide concrete information to the player, thats it.
Hiding information is a very useful and powerfull way to improve the overall game experience, add strategy components, evolve game mechanics, incentive the player to uncover the game world and much more.
From hide enemy units or buildings, design special items that provides visibility or until your imagination can achieve to create. You are not limited on how the fog of war can be implemented.

> But the technique of Fog of War is not the only one used to hide visual information to the player, at the end of this article you can read a quick look to other types of visibility techniques.

## Types of Fog of War
Before show you some videogames examples, we need to introduce the Fog of War flavors. Fog of War can be overalled on top of the piramid with two "flavors" or types, by one side we have the "chunky" and on the other the "smooth" fog of wars, i show you an examples:

> We talk more in deepth later, but here we go with a little introduction

The chunky one is the most easy to implement and understand of fog of war, we only track a "bool" array or a simple enumerator with the flags visible/not visible (we can have a shroud too, we will talk this later).

The smooth one is more tricky, but we have plenty of ways to implement, passing throught texture scaling and blurring, printing to a texture(erasing it for example), with tricky algorithms like [marching squares](https://en.wikipedia.org/wiki/Marching_squares), [tile neighbour aware method](https://web.archive.org/web/20170608082007/http://www.saltgames.com/article/awareTiles/), or the chosen one, with bitmap masking.

> This two flavor mostly are based on a tile-grid (doesn't matter if 3D or 2D graphics).

### Multiple combinations of mixing visibility layers

Most classic RTS games franchises like Age of Empires, Warcraft, StarCraft, Civilization (to say some) uses two types of "fog", by one side we have the **shroud**, this layer represents unexplored territory (we doesn't see nothing) represented mostly on pure black color, and the **fog** layer itself, with dark transparency color or custom sprites/graphics, this layer represents **explored territory** but **out** of **our sight range**. On the **fog** layer, we see the last **seen** (outdated data) updates from the enemy from when we have previously sight on this zone, and if the enemy build or moves its units under our fog layer, we doesn't see anything till we go to re-explore the zone.

> On most modern games we often only see the fog layer, without the shroud, making to a shroud a tasty old school look.

But since we are playing with visibility tricks, the combination and functions of mixing layers and visibilities can be many as we need or create.

### Quick visual look to examples of games that uses Fog of War
If we made a quick look from the beginning, we can see how very emblematic sagas of videogames are growth till today, and yes fog of war are a indispensable component that you may pass unobserved, till today.

#### Age of Empires

On Age of Empires we found two types of "fog", by one side we have the **shroud**, the black "background", and the fog, the explored but out of range areas with dark transparency.

#### StarCraft 2

On StarCraft2, like on Age of Empires we have the same layer configuration, but in this case with plus of interest, because some buildings can be moved out of previous place.

#### Leage Of Legends

Example of how the fog of war can be applied outside RTS games, on League of Legends (like Dota2), we only have one layer, hiding to the players the enemy information, but not the map (since the map never changes, seems to have no sense). Cool examples that uses a very strategic component, introducing the **wards**, objects that players can buy and if are well player offer a huge advantage to the team.

## Different approaches
### Quick look to different implementation methods
#### From tile-grid map to texture method (smooth fog)
##### League of Legends from Riot Games
Since we are talking about league of legends, i found a very interesting and cool [article](https://technology.riotgames.com/news/story-fog-and-war) from the developers from [Riot Games](https://www.riotgames.com/) of how they faced the migration to new re-design of the map and the adventure of the "jagged" edges of fog of war visibility.

At end, they coded a impressive simply well thinked upscaled method that "blurrs" one pixel. If you want to know more of how they did, for theory and more explanations go to its [article](https://technology.riotgames.com/news/story-fog-and-war) **highly recommended.**

We can see that the result is awesome!, nice work Riot Games, and many thanks to share this type of information.

##### Iron Marines from Ironhide Game Studio

Similar technique like explained above, another highly recommended lecture, composed by two articles explaining the evolution of the system [part1](https://blog.gemserk.com/2018/08/27/implementing-fog-of-war-for-rts-games-in-unity-1-2/) [part2](https://blog.gemserk.com/2018/11/20/implementing-fog-of-war-for-rts-games-in-unity-2-2/)

#### Print directly to texture
This technique is based to paint "unpaint" a alpha bitmap mask from a previously edited texture, checks needed pixel data from the "screen texture layer" and apply the pixel data pixel by pixel accessing it throught texture data.

I recommend you take a look at this very interesting post at [StackOverFlow](https://stackoverflow.com/questions/13654753/sdl-drawing-negative-circles-fog-of-war=)

#### From tile map data, for chunky and smooth fog

Probably the best articles that i found after a lot of diving. Very well explained and detailed. Divided in two parts, explaning both systems.

### Quick look to others 2D visibility alternatives

Apart from the technique what are focused this research, exists plenty of ways to implement other visibility solutions. From more simplistic to more complex, and merging with more knowledgemts of light physics, raycasting, etc. Occluding areas behind certain objects, walls, or any type of obstacle or mechanic. By the way the intention doesn't vary, because our intention is hide player information too, but in some cases this techniques are not used only to hide, also to calculate light sources affected areas for example.

A simple approach is to cast rays from the entity center, and obtain and fill the resultant triangles.

You can found one very good example explaining this raycast technique [here](https://www.redblobgames.com/articles/visibility/):

## Selected approach

Till we use tiled map editor and all the University projects that we are running are based on a isometric tile space, i selected a similar idea that i previously found with Riot article, but mixing with the magic of bitmasking. It was a pleasant surprise to find and understand how this technique works and offer us a big potential and a simplistic code, a brilliant idea found at the last citated  Different Approaches. Probably the same underlaying technique used on games like Starcraft, Age Of Empires, Civilization, to say some, offering us this old school smooth finish.

> The amount of limit of smoothness is the artist hand design! You can shape what you want.

Here is how the final result is expected to look!:

### Core of smooth - overview

The core of this technique, is using bit masking, wich provides us a very smooth configuration "splitting" our fog tiles on a array of bits, used for assign every sprite change with perfect merging between visibility areas. Applying a precomputed "shape" masks bitwise ANDded to our fog data map (i explain this later).
You can find a full explanation on the [article](http://bobkoon.com/how-to-implement-a-fog-of-war-part-2-smooth/) itself **HIGHLY recommended lecture** . *Acknowledgments to its pertinent [autor](http://bobkoon.com/), many thanks to share this to the community.*

Fog data map is composed by an array of FOWTILE structures, looks like this:

```cpp
struct FOWTILE
{
	unsigned short m_bits_fog;
	unsigned short m_bits_shroud;
};
```
Since i want to implement shroud and fog, we store its bits states on separate variables.

For making a good smooth system, we need to "divide" each "pixel" or tile of our map or fog data map.

This image represents a North West Corner, as you can see, represented by the 0x5F hex value, or 95 on decimal base. This direction points directly to our table rects definition.

For this selected approach i select a 3x3 (9) bits "sub-pixel" divisions for each tile cell, but you can split this till you want (2x2, 4x4, etc), the most high, more definitions we need to do on our look up table of entries. (and more and more permutations of bits we can define to make a super smooth fog (and hire more graphic artists! ).

The look up table looks like this:

```cpp
// initialize table for get index of foggyTilesRects
	int i = 0;
	for (; i < NUM_FOW_ENTRIES; ++i)
	{
		fog_rects_table[i] = -1;
	}
	// index 0 are reserved to totally shrouded/fogged tile
	// full fog
	fog_rects_table[0x1FF] = 0;
	// big corners
	fog_rects_table[0x5F] = 1; // corner NW
	fog_rects_table[0x137] = 2; // corner NE
	fog_rects_table[0x1D9] = 3;// corner SW
	fog_rects_table[0x1F4] = 4; // corner SE
	// etc ...
	// more cases
	// ...
```
In this case, the values mapped to this table corresponds to an SDL_Rect array index wich stores the needed rects sections for each sprite case, looks like this:

```cpp
// foggy tiles rects
	for (int i = 0; i < MAX_FOW_GRAPHICS; ++i)
		foggyTilesRects[i] = { i * 64, 0, 64,64 };
```

Next, we need to define our "shape mask", thats it the shape wich we want to "substract" to the bits stored on each tile.
On order to make the code more readable and modificable/debuggable, store our bit definitions for each sub-pixel on a legible format:

```cpp
#define FOW_BIT_NW  (1 << 0)
#define FOW_BIT_N   (1 << 1)
#define FOW_BIT_NE  (1 << 2)
#define FOW_BIT_W   (1 << 3)
#define FOW_BIT_C   (1 << 4)
#define FOW_BIT_E   (1 << 5)
#define FOW_BIT_SW  (1 << 6)
#define FOW_BIT_S   (1 << 7)
#define FOW_BIT_SE  (1 << 8)
```
And combine them on new definitions to easily create pre-computed shape masks, like this: (remember: you can found the full project code on github page)

```cpp
#define fow_all         (FOW_BIT_NW | FOW_BIT_N | FOW_BIT_NE | FOW_BIT_W | FOW_BIT_C | FOW_BIT_E |FOW_BIT_SW | FOW_BIT_S | FOW_BIT_SE)
// ...
#define NUM_FOW_ENTRIES fow_all
// ...
// straights
#define fow_EEE         (FOW_BIT_SE | FOW_BIT_E | FOW_BIT_NE)
// ...
// corners
#define fow_CNE         (FOW_BIT_E | FOW_BIT_NE | FOW_BIT_N |FOW_BIT_NW | FOW_BIT_C | FOW_BIT_SE)
// ...
// joins
#define fow_JNE         (FOW_BIT_E | FOW_BIT_NE | FOW_BIT_N)
// ...
```
If you don't remember or doesn't known how the bitwise operators works , you can found a great talk [here](https://stackoverflow.com/questions/141525/what-are-bitwise-shift-bit-shift-operators-and-how-do-they-work) **must see and understand how the application of bitmasking works** . [here](https://rambutan.readthedocs.io/projects/librambutan/en/master/lang/cpp/compoundbitwise.html) great documentation about compound Bitwise operators (`&=`, `|=`, `^=`). [here](https://en.wikipedia.org/wiki/Bitwise_operations_in_C#Left_shift_%3C%3C) another great article from wikipedia.

Next we have to define our precomputed shape mask, here is an example from a "circle shape mask" for radius 3.
```cpp
// circle radius 3
{
	fow_all, fow_all, fow_CNW, fow_NNN, fow_CNE, fow_all, fow_all,
	fow_all, fow_CNW, fow_JNW, fow_non, fow_JNE, fow_CNE, fow_all,
	fow_CNW, fow_JNW, fow_non, fow_non, fow_non, fow_JNE, fow_CNE,
	fow_WWW, fow_non, fow_non, fow_non, fow_non, fow_non, fow_EEE,
	fow_CSW, fow_JSW, fow_non, fow_non, fow_non, fow_JSE, fow_CSE,
	fow_all, fow_CSW, fow_JSW, fow_non, fow_JSE, fow_CSE, fow_all,
	fow_all, fow_all, fow_CSW, fow_SSS, fow_CSE, fow_all, fow_all,
},
```

Finally we need to apply this mask to our fog data map (the array of FOWTILES structures previously mentioned). And this is where the magic happens thanks to compound operator &=, wich preservers the fog coverage of the map independent of the corresponding value of our mask radius array, and perfectly merges multiple areas of different visibility units without problems.

```cpp
void FowEmitter::ApplyMaskToMap(std::list<iPoint> tiles)
{
	// apply the mask
	// bitwise ANDded to fog data map

	const unsigned short *  mask = &App->fogOfWar->area_mask[radius - FOW_RADIUS_MIN][0];

	for (std::list<iPoint>::iterator iter = tiles.begin(); iter != tiles.end(); ++iter)
	{
		FOWTILE* tile = App->fogOfWar->GetFogTileAt((*iter));

		if (tile != nullptr)
		{
			tile->m_bits_fog &= *mask;
			tile->m_bits_shroud &= *mask;
		}

		mask++;
	}

}
```
### New dedicated module to manage Fog of War and Fog of War emitters

To manage all the entitites that provides visibility on our game, we need one new module that i named it "j1FowManager", and a one specific class that we need to put and update its position on any desired entity that we want named "FowEmitter". To create FowEmitters only we need to pass a one parameter, the radius. Radius are directly relationated with the "circle shape masks" what we have said before. For this implementation we only have two disponible radius of 3 and 4, but you can write the amount that you want, and remember, you are not constrained only to "circle" shapes, any shape that you want is a valid one, **but**, remember to get the same affected amount of tiles with the whatever function you are using to get the involved tiles for the "zone of sight".

The header of j1FowManager looks like this (apart of bit definitions and Fowtiles struct described before):

```cpp
class j1FowManager : public j1Module
{
	friend class FowEmitter;

public:
	j1FowManager();
	~j1FowManager();

	bool Start();
	bool PreUpdate();
	bool Update(float dt);
	bool PostUpdate();
	bool CleanUp();

public:
	void CreateFogDataMap(const uint width, const uint height);
	FowEmitter* AddFogEmitter(uint radius);
	bool IsThisTileVisible(iPoint position) const;

public:
	FOWTILE* GetFogTileAt(iPoint position) const;
	bool CheckFogMapBoundaries(iPoint position) const;

private:
	void DebugMouseDrawTilePos() const;

private:
	SDL_Rect foggyTilesRects[MAX_FOW_GRAPHICS];
	SDL_Texture* smoothFogTex = nullptr;
	SDL_Texture* debugFogTex = nullptr;
	signed char fog_rects_table[NUM_FOW_ENTRIES + 1];
	bool debug = false;
	// stores data map size ---
	uint width;
	uint height;
	// ------------------------
	FOWTILE* fogDataMap = nullptr; // stores entire tilemap states for every tile
	std::list<FowEmitter*> currentEmitters; // stores all emitters on entities
```

And the simple class to manage the visibility spots of the desired entitites:

```cpp
// we have to add this emitter to any entity what we want
// fow emitter updates auto its visibility to fog data map
class FowEmitter
{
public:
	FowEmitter();
	FowEmitter(uint radius);
	~FowEmitter();

	bool Update(float dt);
	bool CleanUp();

public:
	void SetPos(iPoint pos);

private:
	std::list<iPoint> GetTilesAffected() const;
	void ApplyMaskToMap(std::list<iPoint> tileList);

public:
	bool to_delete = false;

private:
	uint radius;
	iPoint position; // on TILE values
};
```
And to make all this work, some other puntualizations are needed:

- We have a simplistic j1EntityFactory module that manages entitites behaviour, and a simple Entity class. If we want that specific entities provides us visibility, we need to declare a pointer to a new possible FowEmitter:

```cpp
enum class EntityType
{
	PLAYER,
	ENEMY,
	WARD
};

class Entity
{
public:
	Entity(EntityType type, iPoint position);
	virtual ~Entity();

	virtual bool Update(float dt);
	virtual	bool CleanUp();

public:
	bool Draw();

public:
	bool to_delete = false;
	EntityType type;
	iPoint position;
	SDL_Rect spriteRect;

	// TODO: add fog of war emitter
	// We need to add a fow emitter if we want that entities
	// provides us visibility.
	FowEmitter* fogVisibilityEmitter = nullptr;

};
```
And on the interested player itself (or the entity that you want), we need to define it:

```cpp
Player::Player(iPoint position) : Entity(type, position)
{
	// Adds fow emitter
	fogVisibilityEmitter = App->fogOfWar->AddFogEmitter(3);

}
```
**Remember** to update the position of the emitter when you want:
```cpp
bool Player::Update(float dt)
{
	bool ret = true;
	// manages simple player input
	SimpleInput();

	// updates position of the emitter
	fogVisibilityEmitter->SetPos(position);

	// more functionality ...
	// ...
	return ret;
}
```
With all this put in place, we are ready to start with the implementation, but one last thing before that. If we want that enemies for example, doesn't draw if they are out of player range of sight. We need to tweak how they are drawn, this may vary dependent of your implementation, but in our case with a simple test we solve this. In our entities draw method we have:

```cpp
// TODO: check entity types of our interest to draw or not outside visibility zone
	if ((*iter)->type == EntityType::ENEMY)
	{
		if(App->fogOfWar->IsThisTileVisible((*iter)->position))
			(*iter)->Draw();
	}
	else
		(*iter)->Draw();
```

And we are ready to start with the TODO's!

## TODO's and Solutions
Quick proposals of very easy exercises to understand the versatility of this core system and the easiest implementation that we need.
### TODO1
In order to create a valid Fog data map filled with needed data to compute our fog, we need to create it first.

**Before TODO1** result:

**Expected** result:

#### Solution:
```cpp
// TODO1: creates fog of war data, see the function on j1FowManager,
// and pass the map data size on tile values
App->fogOfWar->CreateFogDataMap(App->map->data.columns, App->map->data.rows);
```
### TODO2
 We need to define our fogVisibilityEmitter in our player constructor since we need that players provides us a visibility.

 **Expected** result:

#### Solution:
```cpp
// TODO2: Define fogVisibilityEmitter with radius 3 ---
// and set instantiation position
fogVisibilityEmitter = App->fogOfWar->AddFogEmitter(3);
fogVisibilityEmitter->SetPos(position);
```
### TODO3
If we want that visibility follow the player, we need to update its position.

Expected result: now visibility follows the player around.

#### Solution
```cpp
// TODO3: update the position of the emitter to this position
fogVisibilityEmitter->SetPos(position);
```
### TODO4
Since we want a visibility mechanic, we need to filter what entities are drawn or not outside player sight radius.

**Before:**  Enemies are showing us its position under the fog! nerf them.

**Expected** result:

#### Solution
```cpp
// TODO4: check entity types of our interest (ENEMY) to draw or not outside visibility zone
if ((*iter)->type == EntityType::ENEMY)
{
	if(App->fogOfWar->IsThisTileVisible((*iter)->position))
		(*iter)->Draw();
}
else
	(*iter)->Draw();
```

### TODO5 and last!
A lot of talk how much smooth is this fog, and its totally chunky. Yes, you need to do the last step inside j1FowManager, adapt the draw function to get the correctly mapped values to our foggyTilesRects array that stores the correct rects for any smoothed graphic.

**Expected** result:

#### Solution
```cpp
// draw fog
if (frame_id_fog != -1)
{
	SDL_SetTextureAlphaMod(fogTex, 120);

	// TODO5 - adapt this draw function --------------------------------
	// you must to understand how the fog_rects_table mapping works ----
	App->render->Blit(fogTex, drawPos.x, drawPos.y, &foggyTilesRects[frame_id_fog]);
	// -----------------------------------------------------------------

}
// draw shroud on top
if (frame_id_shroud != -1)
{
	SDL_SetTextureAlphaMod(fogTex, 255);

	// TODO5 - adapt this draw function, same as above -----------------
	App->render->Blit(fogTex, drawPos.x, drawPos.y, &foggyTilesRects[frame_id_shroud]);
	// -----------------------------------------------------------------
}
```
Don't forget when you finish to test the debug functionality with F1 Key to help to understand how the system works.

And remember, you can instantiate more players and also wards!. Wards show you other ways to play with visibility mechanics, and don't forget, be creative!

## Improvements

 - The fog layer doesn't needs to be updated on every frame, add it to a Delayed Update or a X ticks only update.
 -  The visibility can be occluded throught certain types of tiles, or different terrain elevations, if your game play with heights this improvement is a must for you.
 - Make more table_rects permutations! if you want a super smooth or a very gradient smooth maybe you need more sprites defining different fog situations (remember sub-pixels).
 -  The dimensions of fogData Array and the tile fog size, doesn't need to be the same as your tilemap data, you can vary it if you want. Put a offseted fog to cover entire possible tilesets design that fill more of "diamond" tile shape.
 - If you have a huge map, maybe a some type of draw sorting are needed, we doesn't need to draw every fog tile. The same principle is used to cycle update.

## Acknowledgements and Webgraphy
[Riot Games Article of how they implemented new Fog Of War](https://technology.riotgames.com/news/story-fog-and-war)

[Fog of War - Wikipedia](https://en.wikipedia.org/wiki/Fog_of_war)

[Fog of War and 2D grid - StackOverflow](https://stackoverflow.com/questions/13936368/fog-of-war-and-2d-grid)

[How efficiently implement Fog of War in realtime- Post StackExchange gamedev](https://gamedev.stackexchange.com/questions/134040/how-do-i-efficiently-implement-fog-of-war-in-a-real-time-strategy-game)

[Iron Marines Fog of War implementation part1](https://blog.gemserk.com/2018/08/27/implementing-fog-of-war-for-rts-games-in-unity-1-2/)

[Iron Marines Fog of War implementation part2](https://blog.gemserk.com/2018/11/20/implementing-fog-of-war-for-rts-games-in-unity-2-2/)

[How to implement a Fog of War chunky System](http://bobkoon.com/how-to-implement-a-fog-of-war-part-1-chunky/)

[How to implement a Fog of War smooth System](http://bobkoon.com/how-to-implement-a-fog-of-war-part-2-smooth/)

[Efficient Fog Of War - GameDev.net](https://www.gamedev.net/forums/topic/530346-efficient-fog-of-war/)

[Implementing Fog Of War throught render to texture](http://damienclassen.blogspot.com/2014/02/implementing-fog-of-war.html)

[Implementing Fog Of War throught marching squares](https://startupfreakgame.com/2017/02/12/creating-fog-of-war-in-games/)

["Drawing negative circles" how to draw onto texture to simulate Fog of War - StackOverFlow](https://stackoverflow.com/questions/13654753/sdl-drawing-negative-circles-fog-of-war=)

[Neighbour Aware tile selection](https://web.archive.org/web/20170608082007/http://www.saltgames.com/article/awareTiles/)

[Extense list of how comercial games uses Fog of War](https://tvtropes.org/pmwiki/pmwiki.php/Main/FogOfWar)

[Fog of War on comercial games - list -](https://www.giantbomb.com/fog-of-war/3015-14/)

### Very interesting and useful articles
[2D visibility](https://www.redblobgames.com/articles/visibility/)

[Field of View](http://www.roguebasin.com/index.php?title=Field_of_Vision)

[Roguelike vision algorithms](http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html)

[Dynamic 2D shadow casting](http://archive.gamedev.net/archive/reference/programming/features/2dsoftshadow/page3.html)

[Gaussian Blurr with linear sampling](http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/)

[The HqX pixel art scaling algorithm](https://en.wikipedia.org/wiki/Hqx)

[HqX scaling filter more in deepth](http://blog.pkh.me/p/19-butchering-hqx-scaling-filters.html)

[Upscaling pixel art with extra smooth quality](http://johanneskopf.de/publications/pixelart/)

[Fast circle algorithm- Bresenhams, also "midpoint" circle - StackOverFlow](https://stackoverflow.com/questions/1201200/fast-algorithm-for-drawing-filled-circles)

[Bresenham's algorithm - wikipedia](https://es.wikipedia.org/wiki/Algoritmo_de_Bresenham)

[Implementing Fog of War on Unity](https://andrewhungblog.wordpress.com/2018/06/23/implementing-fog-of-war-in-unity/)

[Marching squares - wikipedia](https://en.wikipedia.org/wiki/Marching_squares)

[Fog of War on strategy games on general](http://keithburgun.net/fog-of-war-in-push-the-lane-and-strategy-games-generally/)

[Blurring on graphic cards without shaders](http://www.ulrichmierendorff.com/software/opengl_blur.html)

[SDL - Blurring with texture render target trick](https://discourse.libsdl.org/t/question-blur-filters-on-sdl-textures/21145)

repository: peterMcP/FOW-research

repo_name: peterMcP/FOW-research


text:
Nerdy Weeks Types & Tools

- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [VSCode Things](#vscode-things)
  - [Extension](#extension)
  - [Fonts](#fonts)
  - [Color & Icon Theme](#color--icon-theme)
  - [Settings](#settings)
- [Exercises](#exercises)

## Prerequisites

- git v2 or greater
- NodeJS v10 or greater
- npm v6 or greater
- VSCode latest

Test if they exists

```bash
git --version
node --version
npm --version
```
## Setup

To get started and install all dependencies for you run the following commands in your terminal.

```bash
git clone git@github.com:technologiestiftung/nerdy-weeks-types-and-tools.git
cd nerdy-weeks-types-and-tools
npx lerna bootstrap
```

This will use [lerna](https://lerna.js.org/) to install all dependencies in the subfolders, so you don't have to.

When done open the folder `nerdy-weeks-types-and-tools` with VSCode to get started.

## VSCode Things

### Extension

When opening this project with VSCode it should ask to install or review recommended extension. You will need to enable them one by one.

The folder `./vscode-things` contains a script to install all the recommended extension from the shell. Make sure that the VSCode cli is available in your `PATH` and review the script you will have to remove an `exit 0` command.

```bash
./vscode-things/install-all.sh
```

### Fonts

The current font of choice is [Dank Mono](https://gumroad.com/l/dank-mono) which is not free but meh!… Not everything is free. An alternative monospaced font with ligatures and italics for VSCode could be:

- [Operator Mono](https://www.typography.com/fonts/operator/styles/operatormono)
- [Victor Mono (free)](https://rubjo.github.io/victor-mono/)
- [Fira Code (free, no italics)](https://github.com/tonsky/FiraCode)

You might also need these fonts if you use powerline fonts in your terminal:

- [Powerline fonts (has e.g. "Fira Mono for Powerline")](https://github.com/powerline/fonts)

To enable italics you need to add some settings to your VSCode.  You will find them also in the file `.vscode/fabianmoronzirfas.settings.json`

```json
{
  "editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "fontStyle": "italic"
            }
        },
        {
            "scope": "keyword",
            "settings": {
                "fontStyle": "italic"
            }
        },
        {
            "scope": "language",
            "settings": {
                "fontStyle": "italic"
            }
        }
    ]
  }
}
```

### Color & Icon Theme

The color theme of choice os the [Nord theme](https://www.nordtheme.com/). Which can be found for many different editors or shells (here for [VSCode](https://marketplace.visualstudio.com/items?itemName=arcticicestudio.nord-visual-studio-code)). The file icons are the [Material Icon theme](https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme)

### Settings

There is a full copy of my VSCode settings under `vscode-things/fabianmoronzirfas.settings.json`. Just open your settings by hitting `⌘ + ,` and opening them as a file by clicking the little file icon on the upper right. Just paste it all or take what you need.

## Exercises

For the exercises you will find the following folder structures displayed below. In the folder `./final` you will find all the results we hope to achieve on that day. Under `./start` you can find some boilerplate projects so you don't have to configure everything by yourself.

```plain
.
├── final
│   ├── server
│   ├── client
│   └── typescript
└── start
    ├── server
    ├── client
    └── typescript
```

Best way to work will be to open these folders in a new VSCode window.
For example by running

```bash
# For the typescript examples
# you should create a copy of the folder ex_
# So you don't have all in one file
cp -R ./start/typescript/ex_ ./start/typescript/ex1 && code ./start/typescript/ex1 -n
# For the react client project
code ./start/client/ -n
# For the express REST api server project
code ./start/server/ -n
```

gha_language: TypeScript


text:
# KServe (rawDeployment)

*Environment*
 - Kubernetes(KIND)
 - Kserve 0.10

**Pre-requisite**
- [Install KIND](../ETC/Kind.md)
- [Install Cert Manager](../ETC/CertManager.md)
- [Install Tools](../ETC/ToolBinary.md)

**Pre-resuisite steps & check**
~~~
# Deploy kuberentes
kind create cluster
kubectl cluster-info --context kind-kind

# Check yq version
yq --version
yq (https://github.com/mikefarah/yq/) version v4.30.8

# Check jq version
jq --version
jq-1.6

# Check grpcurl version
grpcurl --version
grpcurl v1.8.7

# Check cert manager installed
kubectl get ns  cert-manager || echo "ERROR!! CERT MANAGER NEEDED"

# Export demo home
export DEMO_HOME=/tmp/modelmesh
mkdir -p $DEMO_HOME
cd $DEMO_HOME

# Clone jhouse repository
git clone https://github.com/Jooho/jhouse_openshift.git

# Export common script
source ${DEMO_HOME}/jhouse_openshift/Kserve/demos/utils/common.sh

# Export ModelMesh manifests
export RAW_MANIFESTS_HOME=${DEMO_HOME}/jhouse_openshift/Kserve/docs/RawDeployment/manifests
~~~

## Install Kserve (rawDeployment)
~~~
KSERVE_VERSION=0.10.0
wget https://github.com/kserve/kserve/releases/download/v${KSERVE_VERSION}/kserve.yaml
sed 's/Serverless/RawDeployment/g' -i ./kserve.yaml
kubectl apply -f ./kserve.yaml

wget https://github.com/kserve/kserve/releases/download/v${KSERVE_VERSION}/kserve-runtimes.yaml
kubectl apply -f ./kserve-runtimes.yaml

check_pod_ready control-plane=kserve-controller-manager kserve
~~~

## Deploy a Inference Service with sample models
**1. Tensorflow (v1)**
~~~
cd ${DEMO_HOME}

export MODEL_NAME=flower-sample
kubectl create ns kserve-test
kubectl create -f jhouse_openshift/Kserve/docs/RawDeployment/manifests/tensorflow.yaml -n kserve-test

## HPA is always created now you have to delete hpa as a workaround(https://github.com/kserve/kserve/pull/2658)
kubectl delete hpa flower-sample-predictor-default

# test
oc port-forward svc/flower-sample-predictor-default 7777:80

curl -v \
  -H "Content-Type: application/json" \
  -d @./jhouse_openshift/Kserve/docs/RawDeployment/manifests/tensorflow-input.json \
  http://localhost:7777/v1/models/$MODEL_NAME:predict

{
    "predictions": [
        {
            "prediction": 0,
            "key": "   1",
            "scores": [0.999114931, 9.2098875e-05, 0.000136786344, 0.000337257865, 0.000300533167, 1.84813962e-05]
        }
    ]
}
~~~

**2.

gha_language: Go


text:
# Kapara
This is a game made following [Brackey's Beginner Tutorial](https://www.youtube.com/watch?v=j48LtUkZRjU&index=1&list=PLPV2KyIb3jR5QFsefuO2RlAgWEz6EvVi6).

# [Download](https://github.com/gioragutt/unity-kapara-game/releases)
To download the game, go to the [Releases](https://github.com/gioragutt/unity-kapara-game/releases) page, and download the latest release.
The game is available for:
* Windows (`Karapa.Setup.<version>.x86.exe`)
* Mac (`Kapara.<version>.Mac.rar`)
* Linux (`Kapara.<version>.Linux.rar`)

# Screenshots

![Beginning Of Game](https://raw.githubusercontent.com/gioragutt/unity-kapara-game/master/Media/media1.png "Beginning Of Game")
![Complex Obstacles](https://raw.githubusercontent.com/gioragutt/unity-kapara-game/master/Media/media2.png "Complex Obstacles")
![Explode when you hit an obstacle](https://raw.githubusercontent.com/gioragutt/unity-kapara-game/master/Media/media3.png "Explode when you hit an obstacle")
![Credits](https://raw.githubusercontent.com/gioragutt/unity-kapara-game/master/Media/media4.png "Credits")

## Some of the features are:
* 4 Available Levels - each with increasing difficulty
* Obstacles are generated every time - no two levels are the same!
* Simple high score tracker
* Comfortable keyboard shortcuts
* Checkpoints for passed levels
* Awesome sound tracks (since [v0.0.4](https://github.com/gioragutt/unity-kapara-game/releases/tag/v0.0.4))
* **EXPLOSIONS!**

## Keyboard
* Left Arrow - Move left
* Right Arrow - Move right
* Enter - Start/Restart At Last Checkpoint (where possible)
* Backspace - Restart game entirely (where possible)
* Escape - Pause the game

## Feedback
I appreciate **all** kinds of feedback
* Suggestions/Improvements
  * Go **NUTS** - any idea works!
* Bug reports
  * _Reproduction steps are greatly appreciated!_

Please open an issue or mail me at<EMAIL_ADDRESS>
## Development
After cloning the repository, it's necessary to download the following packages via the `Asset Store` -
* [JSON .NET For Unity](https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347)
* [Unity Particle Pack](https://assetstore.unity.com/packages/essentials/asset-packs/unity-particle-pack-73777)

repository: gioragutt/unity-kapara-game

gha_language: C#

repo_name: gioragutt/unity-kapara-game


text:
## Dynamic Provisioning for Azure disk mount on Windows
### 1. create an azure disk storage class if `hdd` does not exist
 - k8s agent pool is based on managed disk VM
```
kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/storageclass-azuredisk-managed.yaml
```

 - k8s agent pool is based on blob based(unmanaged) disk VM
```
kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/storageclass-azuredisk.yaml
```

###### Note:
 - managed disk mount feature is only supported from v1.7.2
 - AKS cluster use managed disk by default, there are already `managed-standard`, `managed-premium` built-in azure disk storage classes.

### 2. create an azure disk pvc
```kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/pvc-azuredisk.yaml```

#### make sure pvc is created successfully
```watch kubectl describe pvc pvc-azuredisk```

### 3. create a pod with azure disk pvc
```kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/windows/azuredisk/aspnet-pod-azuredisk.yaml```

## Static Provisioning for azure disk
### 1. create an azure disk manually in the same resource group and modify `aspnet-pod-azuredisk.yaml`
 - managed disk
```
wget -O aspnet-pod-azuredisk.yaml https://raw.githubusercontent.com/andyzhangx/Demo/master/windows/azuredisk/aspnet-pod-azuredisk-static-blobdisk.yaml
vi aspnet-pod-azuredisk-static-blobdisk.yaml
```

 - blob based(unmanaged) disk
```
wget -O aspnet-pod-azuredisk.yaml https://raw.githubusercontent.com/andyzhangx/Demo/master/windows/azuredisk/aspnet-pod-azuredisk-static-mgrdisk.yaml
vi aspnet-pod-azuredisk-static-mgrdisk.yaml
```

### 2. create a pod with an azure disk mount
```kubectl create -f aspnet-pod-azuredisk.yaml```

## Check pod status
 - watch the status of pod until its `Status` changed from `Pending` to `Running`
```
watch kubectl describe po aspnet-azuredisk
```

 - enter the pod container to do validation
```
kubectl exec -it aspnet-azuredisk -- cmd
```

```
C:\>d:
D:\>mkdir test
D:\>cd test
D:\test>dir
 Volume in drive D has no label.
 Volume Serial Number is 50C1-AE52

 Directory of D:\test

09/20/2017  12:40 AM    <DIR>          .
09/20/2017  12:40 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)   5,334,327,296 bytes free
```

### known issues of Azure disk on Windows feature
 - [Allow windows mount path on windows](https://github.com/kubernetes/kubernetes/pull/51240) is available from v1.7.x, v1.8.3 or above.

 - Only drive letter(e.g. `D:`) as `mountPath` works for azure disk on Windows feature due to [volume mapping would fail when hostPath is a symbolic link to a drive and containerPath is a dir path on Windows](https://github.com/moby/moby/issues/35436)

 - [other azure disk plugin known issues](https://github.com/andyzhangx/demo/blob/master/issues/azuredisk-issues.md)

#### Links
[Azure Disk Storage Class](https://kubernetes.io/docs/concepts/storage/storage-classes/#azure-disk)

[Azure Disk Scalability and Performance Targets](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/standard-storage?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json#scalability-and-performance-targets)

[Debug Azure disk attachment issue](https://github.com/andyzhangx/Demo/blob/master/windows/azuredisk/azuredisk-attachment-debugging.md)

repository: stcheng/demo

repo_name: stcheng/demo


text:
---
layout: post
title: Introduction to Generalized Linear Model
tags: [statistics, data]
comments: true
---

## Summary:

As one of the most important models in statistical machine learning, GLM is investigated here.
This is the slides I used in the internal machine learning discussion at Ritual.

<iframe src="/img/intro_glm.pdf" width="100%" height="1000"></iframe>


text:
# [Introducing Else If Statements](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/introducing-else-if-statements)

If you have multiple conditions that need to be addressed, you can chain `if` statements together with `else if` statements.

```js
if (num > 15) {
  return "Bigger than 15";
} else if (num < 5) {
  return "Smaller than 5";
} else {
  return "Between 5 and 15";
}
```

---

Convert the logic to use `else if` statements.

## Setup

```js
function testElseIf(val) {
  if (val > 10) {
    return "Greater than 10";
  }
  if (val < 5) {
    return "Smaller than 5";
  }
  return "Between 5 and 10";
}
// Change this value to test
testElseIf(7);
```

## Solution

```js
if (val > 10) {
  return "Greater than 10";
} else if (val < 5) {
  return "Smaller than 5";
} else {
  return "Between 5 and 10";
}

testElseIf(7); // "Between 5 and 10"
```

repository: johnfelipe/progress

repo_name: johnfelipe/progress


text:
# Setup masternode with P2SH collateral output stored on multisig wallet

To store a collateral amount on a multisig P2SH wallet the collateral amount
must be created as an output of a ProRegTx transaction. Any other existing
collateral amount of 1000 Dash stored on a multisig is not suited for the ProRegTx.

There are two methods:

1. Create a ProRegTx transaction on a standard P2PKH wallet and set 1000 Dash
   output of the ProRegTx to a P2SH multisig address of another wallet.

2. Create a ProRegTx transaction on a multisig P2SH wallet and set the Owner/Voting
   addresses to another standard wallet P2PKH adresses (the addresses must
   be of the P2PKH type).

## Method 1. Create from a standard wallet, store collateral on a multisig wallet.

Create a DIP3 masternode on a standard P2PKH wallet with the wizard.

<image src="dip3_p2sh/protx_p1.png" width="800" />

Then select collateral as ProRegTx Output.

<image src="dip3_p2sh/protx_p2.png" width="800" />

Select service params and Owner/Voting/Payout addresses, save BLS priv key,
finish the wizard.

<image src="dip3_p2sh/protx_p3.png" width="800" />
   <image src="dip3_p2sh/protx_p4.png" width="800" />
   <image src="dip3_p2sh/protx_p5.png" width="800" />

Send "Pay to" address of the ProRegTx to a P2SH address of your multisig wallet,
set "Amount" to 1000 Dash value of collateral.

<image src="dip3_p2sh/protx_p6.png" width="800" />

## Method 2. Create from a multisig wallet.

Create a DIP3 masternode on a multisig P2SH wallet with the wizard.

<image src="dip3_p2sh/protx_p1.png" width="800" />

Then select collateral as the ProRegTx Output.

<image src="dip3_p2sh/protx_p2.png" width="800" />

Select service params.

<image src="dip3_p2sh/protx_p3.png" width="800" />

Select Owner/Voting addresses from your standard P2PKH wallet.
Payout addresses can be on a P2SH or a P2PKH wallet.

<image src="dip3_p2sh/protx_p4_p2sh.png" width="800" />

Save BLS priv key, finish the wizard.

<image src="dip3_p2sh/protx_p5.png" width="800" />

Send "Pay to" address of the ProRegTx to a P2SH address of your multisig wallet,
set "Amount" to 1000 Dash value of collateral.

<image src="dip3_p2sh/protx_p6.png" width="800" />

repository: dashpay/docs

gha_language: Python

repo_name: dashpay/docs


text:
---
layout: post
title: "Adversarial Scene Editing: Automatic Object Removal from Weak Supervision"
date: 2018-06-05 19:45:20
categories: arXiv_AI
tags: arXiv_AI Adversarial Knowledge GAN Face
author: Rakshith Shetty, Mario Fritz, Bernt Schiele
mathjax: true
---

* content
{:toc}

##### Abstract
While great progress has been made recently in automatic image manipulation, it has been limited to object centric images like faces or structured scene datasets. In this work, we take a step towards general scene-level image editing by developing an automatic interaction-free object removal model. Our model learns to find and remove objects from general scene images using image-level labels and unpaired data in a generative adversarial network (GAN) framework. We achieve this with two key contributions: a two-stage editor architecture consisting of a mask generator and image in-painter that co-operate to remove objects, and a novel GAN based prior for the mask generator that allows us to flexibly incorporate knowledge about object shapes. We experimentally show on two datasets that our method effectively removes a wide variety of objects using weak supervision only

##### Abstract (translated by Google)
尽管最近在自动图像处理方面取得了巨大进步，但它仅限于面向对象的中心图像或结构化场景数据集。在这项工作中，我们通过开发一个自动无交互对象移除模型，向通用的场景级图像编辑迈进了一步。我们的模型学习使用图像级标签和生成对抗网络（GAN）框架中的未配对数据，从一般场景图像中找到并移除对象。我们通过两个关键贡献实现了这个目标：一个两阶段编辑器体系结构，包括一个掩码生成器和一个合作去除对象的图像绘制器，以及一个基于GAN的基于掩模生成器的新颖事件，允许我们灵活地合并对象形状。我们通过实验在两个数据集上显示，我们的方法仅使用弱监督有效地移除了各种各样的对象

##### URL
[http://arxiv.org/abs/1806.01911](http://arxiv.org/abs/1806.01911)

##### PDF
[http://arxiv.org/pdf/1806.01911](http://arxiv.org/pdf/1806.01911)


text:
# Configuring user access

The default REANA configuration allows users to sign up, after which
an email is sent to the user's email address for confirmation.  Once
the email address is confirmed, the user can then ask administrators
for an access token.

If you would like to disable the email verification step, you can add
`REANA_USER_EMAIL_CONFIRMATION: false` Helm value to [`components.reana_server.environment`](https://github.com/reanahub/reana/tree/master/helm/reana).

If you would like to disable the sign-up form completely, and add your
users manually, you can configure
[`components.reana_ui.hide_signup`](https://github.com/reanahub/reana/tree/master/helm/reana)
Helm value accordingly.

Note that it is also possible to deploy a Single-Sign On system for
managing user access. Currently, this is only available for CERN
deployments.


text:
# Software installation

CUT&RUNTools 2.0 requires Python (3.6), R (3.6), Java and Perl. Installation also requires GCC to compile some C-based source code.

## Prerequisites

Additionally, the following tools should be already installed. Check the corresponding website to see how to install them.  CUT&RUNTools 2.0 may work with a lower version of each tool. In the bracket is the version we have.

* Bowtie2 (2.2.9) [link](http://bowtie-bio.sourceforge.net/bowtie2/index.shtml)
* Samtools (1.3.1) [link](http://samtools.sourceforge.net/)
* MACS2 (2.1.1) [link](https://github.com/taoliu/MACS)
* MEME (4.12.0) [link](http://meme-suite.org/tools/meme)
* Bedops (2.4.30) [link](https://bedops.readthedocs.io/en/latest/)
* Bedtools (2.26.0) [link](https://bedtools.readthedocs.io/en/latest/)
* Deeptools (3.5.0) [link](https://deeptools.readthedocs.io/en/develop/)

Alternatively, we recommend the user to install the software using [conda system](https://docs.conda.io/en/latest/). On a Linux system, paths of software from the anaconda environment might be obtained in the following:

```
conda info -e
# conda environments:
#
base                     *  /home/fyu/anaconda2
bedGraphToBigWig            /home/fyu/anaconda2/envs/bedGraphToBigWig
bedops                      /home/fyu/anaconda2/envs/bedops
bedtools                    /home/fyu/anaconda2/envs/bedtools
bowtie2                     /home/fyu/anaconda2/envs/bowtie2
deeptools                   /home/fyu/anaconda2/envs/deeptools
macs2                       /home/fyu/anaconda2/envs/macs2
samtools                    /home/fyu/anaconda2/envs/samtools
```

We also provided special notes for **Atactk** and **UCSC-tools** (they were already included in our packages), see below.
* Atactk [link](https://github.com/ParkerLab/atactk)- we provide special install instructions since we need to patch a source file.
* UCSC-tools [link](http://hgdownload.soe.ucsc.edu/admin/exe/)- we provide special install instructions.

Other tools already contained in CUT&RUNTools 2.0 (you do not need to install them other than specify them in the configuration file):

* SEACR [link](https://github.com/FredHutch/SEACR)
* picard (0.1.8) [link](http://broadinstitute.github.io/picard/command-line-overview.html)
* trimmomatic (0.36) [link](https://github.com/timflutre/trimmomatic)

Files already contained in CUT&RUNTools:
* genome size files
* blacklist regions
* adaptor files
* example fastq data

### Atactk installation

This is a [python package](https://github.com/ParkerLab/atactk) that determines the enzyme cut frequency matrix. Originally for Tn5 transposase in ATAC-seq, the logic of the tool also applies to other digestions like CUT&RUN.
However since original implementation is designed for ATAC-seq it needs to be patched in one small place in the code to make it suitable for CUT&RUN analysis. Otherwise, we estimate that the cut frequency is sometime off by 1 bp in its calculation.

We provide a patch for this problem. Install the patched version of the package by reading [`atactk.install.sh`](atactk.install.sh). The patches [`make_cut_matrix.patch`](make_cut_matrix.patch) and [`metrics.py.patch`](metrics.py.patch). Then install by:

```
source atactk.install.sh
```
This will use pip to install atactk to the user's home directory (~/.local/bin).

*  `adapterpath` contains Illumina Truseq3-PE adapter sequences (we provide them).

### UCSC-tools installation

We need two specific tools bedGraph2BigWig and fetchChromSizes, and provide a script [`ucsc-tools.install`](ucsc-tools.install) to automatically download and install them from the UCSC genome browser:
```
source ucsc-tools.install
```
This will download the two executables in the current directory.

### kseq installation

We first install a special trimmer we wrote `kseq`. This tool further trims the reads by 6 nt to get rid of the problem of possible adapter run-through. To install:
```
source make_kseq_test.sh
```

## Download genome assemblies

The genome sequence of a specific organism build (such as hg19, hg38) is required for motif finding. We provide a script [`assemblies.install`](assemblies.install) to download this automatically from NCBI. We specifically require repeat-**masked** version of genome sequence file. See [`assemblies.install`](assemblies.install) for more details.
```
source assemblies.install
```

## Install CENTIPEDE R packages for footprinting analysis

In R, run:
```
install.packages("CENTIPEDE", repos="http://R-Forge.R-project.org")
```

### A note about other Linux systems

If you are using Ubuntu Linux 18.04 or above, obtaining and installing the pre-requisites should be in most cases pretty simple.
You can either use the `apt-get install` command to install things like `bedops`, `bedtools`, `bowtie2`. For other packages that are not in the Ubuntu package manager,
they can be installed by going to the official channel, downloading the source tar file, extracting it, and doing `./configure --prefix=/usr/local` followed by `make && make install`.

## Configuration file

The configuration file tells CutRunTools where to locate the prerequisite tools. This is a [JSON](http://www.json.org/) file. A sample JSON file is provided below `bulk-config.json`. Filling in the information should be pretty easy: in most cases we need to provide the path to the `bin` directory of each tool.

```json
{
    "software_config": {
        "Rscriptbin": "/path/to/R/3.3.3/bin",
        "pythonbin": "/path/to/python/2.7.12/bin",
        "perlbin": "/path/to/perl/5.24.0/bin",
        "javabin": "/path/to/java/jdk-1.8u112/bin",
        "bowtie2bin": "/path/to/bowtie2/2.2.9/bin",
        "samtoolsbin": "/path/to/samtools/1.3.1/bin",
        "macs2bin": "/path/to/macs2/<IP_ADDRESS>60309/bin",
        "memebin": "/home/user/meme/bin",
        "bedopsbin": "/path/to/bedops/2.4.30",
        "bedtoolsbin": "/path/to/bedtools/2.26.0/bin",
        "path_deeptools": "/path/to/deeptools",
        "bt2idx": "/n/groups/bowtie2_indexes",
        "genome_sequence": "/home/user/chrom.hg19/hg19.fa",
        "spike_in_bt2idx": "/n/groups/ecoli/bowtie2_indexes",
        "spike_in_sequence": "/home/user/chrom.ecoli/ecoli6.fa",
        "extratoolsbin": "/path/to/cutrun_pipeline2.0",
        "extrasettings": "/path/to/cutrun_pipeline2.0",
        "kseqbin": "/path/to/cutrun_pipeline2.0",
        "adapterpath": "/path/to/cutrun_pipeline2.0/adapters",
        "trimmomaticbin": "/path/to/cutrun_pipeline2.0",
        "picardbin": "/path/to/cutrun_pipeline2.0",
        "picardjarfile": "picard-2.8.0.jar",
        "trimmomaticjarfile": "trimmomatic-0.36.jar",
        "makecutmatrixbin": "/home/user/.local/bin"
    },
    "input_output": {
        "fastq_directory": "/n/scratch2/user/Nan_18_demo/sorted.chr11",
        "workdir": "/n/scratch2/user/workdir",
        "fastq_sequence_length": 42,
        "organism_build": "hg19",
        "spike_in_align": "FALSE",
        "spike_in_norm": "FALSE",
        "spikein_scale": "10000",
        "frag_120": "TRUE",
        "peak_caller": "macs2",
        "dup_peak_calling": "FALSE",
        "cores": "8",
        "experiment_type": "CUT&Tag"
    },
    "motif_finding": {
        "num_bp_from_summit": 150,
        "num_peaks": 1000,
        "total_peaks": 5000,
        "motif_scanning_pval": 0.0005,
        "num_motifs": 10
    }
}

```
The **software_config** section (the first 24 lines) concerns the software installation.  The rest is related to an actual analysis (explained in [USAGE.md](USAGE.md)).

### Validate prerequisites

To check if the paths are correct and if the softwares in these paths indeed work:
```
./validate.py bulk-config.json --ignore-input-output --software
```
This script checks that your configuration file is correct and all paths are correct. You will get an empty line if the validate.py script runs without errors.

Then, CutRunTools 2.0 can be run directly from the directory containing the CutRunTools scripts.
Briefly, a user writes a `bulk-config.json` configuration file for a new analysis. CUT&RUNTools 2.0 uses this to generate a set of slurm-based job-submission scripts, customized to the user's samples and environment.

See the following links for more details:

- [Overview](./bulk-OVERVIEW.md)
- [Quick Start](./bulk-QUICK.md)
- [Usage Page](./bulk-USAGE.md)
- [Directory Structure](./bulk-DIRECTORY.md)


text:
---
layout: post
title:  "Comunitar.io launches"
date:   2020-01-29
excerpt: "Comunitar.io launches with website, social media"
image: images/drone.png
tag:
- launch
- civic tech
- co-production
- website
- social media
---

Comunitar.io, a boutique civic tech studio whose solutions address inefficient and opaque government, has officially opened its doors.

The company offers a wide range of expertise, including:
* geospatial analysis
* data visualization and mapping
* participatory mapping and data collection
* open data practices
* machine learning/deep learning
* data management
* urban development
* web platforms

Comunitar.io is guided by the principles of civically responsible technology - i.e., tech that is transparent and understandable to the people that it affects - and the coproduction of services - the idea that the users of a service should have the greatest hand in deciding how that service should be provided.

Inquiries can be made to CTO [Edgar Lemus](mailto:edgar@comunitar.io).

---
<!--
### Projects Overlay

To set what image links appear in the overlay menu edit `_data/projects.yaml`. Use the following format to set the URL, title, image and project status for as many links as you'd like. If you set `completed` to `false` like `completed: false`, it won't be clickable until you set it true like `completed: true`

{% highlight yaml %}
- title: Moon Jekyll Theme
  url: http://taylantatli.me/Moon
  image: https://cloud.githubusercontent.com/assets/754514/14509720/61c61058-01d6-11e6-93ab-0918515ecd56.png
  completed: true

- title: Ramme Jekyll Theme
  url: http://taylantatli.me/Ramme
  image: https://raw.githubusercontent.com/TaylanTatli/Ramme/master/assets/img/screenshot-post.png
  completed: true

- title: Daisy Pelican Theme
  url: http://taylantatli.me/Daisy-Pelican-Theme/
  image: https://raw.githubusercontent.com/TaylanTatli/Daisy-Pelican-Theme/master/Preview-1.png
  completed: true

- title: Block Icon Theme
  url: https://github.com/TaylanTatli/Block-Icon-Theme
  image: https://raw.githubusercontent.com/TaylanTatli/Block-Icon-Theme/master/Preview.png
  completed: false

- title: Start Page
  url: http://taylantatli.me/StartPage/
  image: https://raw.githubusercontent.com/TaylanTatli/StartPage/master/preview.png
  completed: false
{% endhighlight %}

---
 -->

repository: COMUNITARIO/comunitario

branch_name: refs/heads/gh-pages

repo_name: COMUNITARIO/comunitario


text:
# Open Graph Image Client for Laravel

This Laravel package allows you to easily create Open Graph images for your application or website. Please go [here](https://github.com/flowframe/og-image-server) if you're looking for the back-end repo.

## Support us

[<img src="https://flowfra.me/github-ad.png" width="419px" />](https://flowfra.me/github-ad-click)

Like our work? You can support us by sponsoring or purchasing one of our products and services.

## Installation

You can install the package via composer:

```bash
composer require flowframe/og-image-client
```

You can easily publish the config like so:

```bash
php artisan og-image-client:install
```

## Usage

Once you have setup up the server you can start using the client side package.

First, setup your `.env`:

```
OG_IMAGE_URL=<your_server_url> // https://your-app-on.vercel.com/api

OG_IMAGE_TEMPLATE_PATH=<your_template_path> // default _og-image, we recommend to keep this

OG_IMAGE_SECRET_TOKEN=<your_secret_token_from_server>
```

_Don't forget to add the /api suffix._

And then generate your image:

```php
// helper function, you can also use the Facade: `OgImageClient::generate(...)`
$image = og()->generate([
    'template' => '_og-images/example', // resources/views/_og-images/example.blade.php

    // Attributes which will be used in the template view
    'title' => 'Hello Flowframe',
    'subtitle' => 'How are you doing?',

    // Array are also supported
    'options' => [
        'Wow',
        'Much',
        'Cool',
    ],
]);
```

When developing locally you can also preview your image by doing:

```php
return og()->preview([
    'template' => '_og-images/example',
    'title' => 'Hello Flowframe',
    'subtitle' => 'How are you doing?',
    'options' => [
        'Wow',
        'Much',
        'Cool',
    ],
]);
```

This will render the template with data.

### Templates

The templates get served from the website itself. Alternatively, you can override the url inside the payload to point to another site.

You're free in where you place the template, we suggest to place it in `resources/views/_og-images`.

Here's an example of a template:

```html
<!-- HTML scaffolding... -->

<body>
    <div>
        <h1>{{ $payload['title] }}</h1>

        <p>{{ $payload['subtitle] }}</p>

        <ul>
            @foreach($payload['options'] as $option)
                <li>{{ $option }}</li>
            @endforeach
        </ul>
    </div>
</body>
```

Be aware that nullable values could raise an error. You can easily avoid it by creating classes which require you to implement certain fields or simple do: `{{ $payload['title] ?? '' }}`.

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

## Credits

-   [Lars Klopstra](https://github.com/flowframe)
-   [All Contributors](../../contributors)

## License

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

repository: Flowframe/og-image-client

gha_language: PHP

repo_name: Flowframe/og-image-client


text:
---
title: 'React: Class Components vs. Stateless Functional Components'
description: "In this article, I'll explain the differences between class components and stateless functional components as well as when and why to use the different types."
date: '2018-08-22'
tags: '#reactjs #javascript'
featured_image: ./featured_image.jpg
keywords: 'react.js, react.js tutorial, react.js component, javascript'
published: true
---

When I first began to learn React, I didn't even realize there was a difference between class components and stateless functional components. I thought they were just different ways to write the same thing.

In some ways, they are. In many ways, they aren't the same. In this article, I'll explain the differences between the two as well as when and why to use the different types.

### What is a "Class Component"?

A class component is a component that takes advantage of [ES6 classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) to manage various pieces of the component. State is something we use a lot in React and I'll write more about it in a later post. For now, just know that it's how we manage data within our component. In addition to state, we can create custom functions to use in our component and take advantage of lifecycle methods.

These things can be useful when we are storing or maniplating data within our component. Cases such as these will be our primary use cases for class components. I have provided an example of a class component which will render "Hello World" below using state:

```jsx:title=helloworld.js
class HelloWorld extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      greeting: "Hello World"
    }
  }
  render() {
    return (
      <div>
        <p>{ this.state.greeting }</p>
      </div>
    )
  }
}
```

### What is a "Stateless Functional Component"?

I know, I know. "Stateless Functional Component" sounds like something big and scary, but I promise: it's not. A stateless functional component is just a function that returns JSX. It's very simple but incredibly useful.

There are two ways to create a stateless functional component. Both are similar and do the same thing, it's just a matter of conciseness. I will be using [ES6 arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) to create the components. If you haven't used them, I highly recommend you check ES6 out.

#### The first way: Put it in a variable

If we are putting all of our components in a single file, then this should be how we create stateless functional components. The ability choose how succinctly we want to create our functional components comes into play when we have a different file for each component. The code below illustrates how we can create a functional component within a variable and export it for use in another area of our app.

```jsx:title=helloworld.js
const HelloWorld = (props) => (
  <div>
    <p>{ props.greeting }</p>
  </div>
);
export default HelloWorld;

~~~

<HelloWorld greeting="Hello World!" />
```

#### The second way: export the function

When we have a stateless functional component in a file by itself, we don't need to name the component. I know, this saves us, like, 10 characters but hey I'll take what I can get. We can simply create the function and export it like the code below.

```jsx:title=helloworld.js
export default (props) => (
  <div>
    <p>{ props.greeting }</p>
  </div>
);

~~~

<HelloWorld greeting="Hello World!" />
```

As you can see, these two functional components look almost identical and they do the same thing. It's really just a matter of personal preference.

> A Quick Note:
> With ES6 arrow functions, we can use curly braces and put a return inside of those. To keep things concise, we
> can also write the function on one line. If no curly braces are placed after arrow, the function will
> automatically return whatever is behind the arrow. If the JSX we are returning takes more than one line, we can
> wrap our code in parenthesis like the code above.

#### Which one should I use?

Typically I see that "best practice" is to use stateless functional components whenever possible to reduce code bloat. On [Syntax.fm](https://syntax.fm/) they discussed just using class components all the time because they find that they change a lot of their components from functional to class and don't want to keep converting. Unless you're building an app that is going to be HUGE, I don't see this really causing any problems in terms of performance, so that's completely up to you.

<br />
I would love to hear your thoughts about when to use each of these components. How often do you use stateless function components vs class components?


text:
---
title: last-updated
metaTitle: Last-Updated Plugin | VuePress
---

# [@vuepress/plugin-last-updated](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-last-updated)

> last-updated plugin for vuepress

::: warning Note
Note that this plugin has been included in the core, you don't need to repeat the installation.
:::

## Usage

```js
module.exports = {
  plugins: ['@vuepress/last-updated']
}
```

## Options

### transformer

- Type: `(timestamp: number, lang: string) => string`
- Default: `undefined`

By default, this plugin produces a 13-bit timestamp for each page, you can also pass in a transformer to convert it to any format that you want.

e.g.

``` javascript
const moment = require('moment');

module.exports = {
  plugins: [
    [
      '@vuepress/last-updated',
      {
        transformer: (timestamp, lang) => {
          // Don't forget to install moment yourself
          const moment = require('moment')
          moment.locale(lang)
          return moment(timestamp).fromNow()
        }
      }
    ]
  ]
}
```

::: tip
If you are running in [i18n](../../guide/i18n.md) mode, you can also use the second argument `lang` to generate time strings for different languages.

Note that in VuePress, we follow this spec: [W3C > Language tags in HTML and XML](https://en.wikipedia.org/wiki/Language_localisation), so `en-US` uses hyphens (`-`) instead of underscores (`_`). Please make sure that the library you are using follows this spec, otherwise please convert it yourself.
:::

repository: chenjiji/vuepress

repo_name: chenjiji/vuepress


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link type="text/css" rel="stylesheet" href="bootstrap.min.css" />
<title>Version Differences</title>

Overall

While base functionalities are identical for all versions of ASP.NET Zero,
there are still some differences between different versions. In this document,
we will highlight these differences.

ASP.NET Core v.s. ASP.NET MVC 5.x

Beginning from v4.1, we are more focused to
ASP.NET Core based solutions (rather than ASP.NET MVC 5.x)
since ASP.NET Core is Microsoft's new ASP.NET version. That means our new major
features will be implemented for ASP.NET Core version (.net core & full .net
framework).

Angular v.s. Angularjs 1.x

Beginning from v4.1, we are more focused to
Angular based solutions (rather than Angularjs 1.x) since Angular is Google's
new SPA framework. That means our new major features will be implemented for
Angular framework.

Version Differences Table

The table below shows only the differences, not all features.

	Feature
	ASP.NET Core & Angular
	ASP.NET Core & JQuery
	ASP.NET MVC 5.x & Angularjs
	ASP.NET MVC 5.x & JQuery

	User Interface (theme)
	Metronic v5.x
	Metronic v5.x
	Metronic v4.6.x
	Metronic v4.6.x

	ORM
	EF Core
	EF Core
	EF 6.x
	EF 6.x

	Xamarin Application
	OK
	OK
	-
	-

	Rapid Application Development Tool
	OK
	OK
	-
	-

	Tenant Subscription Management & Paypal Integration
	OK
	OK
	-
	-

	Host Statistics Dashboard
	OK
	OK
	-
	-

	Identity Server Integration
	OK
	OK
	-
	-

	Chat & Real Time Notifications (SignalR integration)
	OK
	OK
	OK
	OK

	ADFS login
	-
	OK
	OK
	OK

	Social Logins (Facebook, Twitter, Microsoft, Google+)
	OK (Facebook, Google)
	OK (all)
	OK (all)
	OK (all)

	LDAP login
	OK
	OK
	OK
	OK

	Two Factor Auth
	SMS, Email, Google Auth
	SMS, Email, Google Auth
	SMS, Email
	SMS, Email

	Application Setup Screen
	OK
	OK
	-
	-

	Code generation extension
	OK
	OK
	-
	-

See development guide documents for details of all features
in different versions:

ASP.NET Core & jQuery

ASP.NET Core & Angular

ASP.NET MVC 5.x & jQuery

ASP.NET MVC 5.x & Angularjs 1.x

repository: aspnetzero/documents

repo_name: aspnetzero/documents


text:
## Usage

```
git clone https://github.com/lagerdata/lager-pdb-demo.git
lager python lager-pdb-demo
```

After the breakpoint is hit:

```
telnet localhost 5555
```

repository: lagerdata/lager-pdb-demo

repo_name: lagerdata/lager-pdb-demo