text:
# Mongodbatlas exporter for Prometheus

## Limitations

- Exporter supports up to 30 processes (mongod and mongos)
> number of process calculation:\
> 1 sharded cluster with 3 shards = 3x3 shards mongod processes + 3x3 mongos processes + 3x1 config mongod processes = 21\
> 1 non-sharded cluster (replica set) = 3x1 mongod processes
- Minimal scrape interval should be 1m

## Configuration
mongodbatlas_exporter doesn't require any configuration file and the available flags can be found as below:
```
usage: mongodbatlas_exporter [<flags>]

Flags:
  --help                    Show context-sensitive help (also try --help-long and --help-man).
  --listen-address=":9905"  The address to listen on for HTTP requests.
  --atlas.public-key=ATLAS.PUBLIC-KEY
                            Atlas API public key
  --atlas.private-key=ATLAS.PRIVATE-KEY
                            Atlas API private key
  --atlas.project-id=ATLAS.PROJECT-ID
                            Atlas project id (group id) to scrape metrics from
  --atlas.cluster=ATLAS.CLUSTER ...
                            Atlas cluster name to scrape metrics from. Can be defined multiple times. If not defined all clusters in the project will be scraped
  --log-level=debug         Printed logs level.
  --version                 Show application version.
  ```


text:
---
cloud: Experience Cloud
product: experience manager
sub-product: forms conversion service
solution: Experience Manager, Experience Manager Forms
type: Documentation
audience: end-user
user-guide-title: Adobe Experience Manager Forms Automated Conversion Service
user-guide-description: Convert PDF Forms to responsive and mobile-ready HTML Forms.
breadcrumb-title: Forms Automated Conversion Guide
feature: Adaptive Forms
role: User
---

# Adobe Experience Manager Forms Automated Conversion Service {#using}

+ [Introduction](introduction.md)
+ [Release Notes](release-notes.md)
+ [Best practices and considerations](styles-and-pattern-considerations-and-best-practices.md)
+ [Configure the service](configure-service.md)
+ [Convert print forms to adaptive forms](convert-existing-forms-to-adaptive-forms.md)
+ [Review and correct converted forms](review-correct-ui-edited.md)
+ [Extend the default meta-model](extending-the-default-meta-model.md)
+ [Recommended data source-based prefill and submit workflows for adaptive forms](prefill-submit-forms.md)
+ [Recommended workflows to enable Document of Record generation for adaptive forms](enable-document-of-record-generation.md)
+ [Integrate adaptive form with database using AEM workflow](submit-converted-adaptive-form-to-database.md)
+ [Frequently asked questions](frequently-asked-questions.md)
+ [Known Issues](known-issues.md)
+ [Troubleshoot](troubleshoot-afcs.md)

license: MIT

branch_name: refs/heads/main

extension: md

license_type: permissive


text:
# python-tools

I just stick (usually networking) python tools that i make in here. You'll need root permissions to run most of these.

**ReverseTCP**

- Works on a LAN Network. Need to add more exception handling for connection refused and binding errors.

branch_name: refs/heads/master

gha_language: Python

gha_license_id: MIT


text:
# [Audio Adversarial Examples: Targeted Attacks on Speech-to-Text](https://arxiv.org/pdf/1801.01944.pdf)
### Authors: Nicholas Carlini and David Wagner

This release of the code is preliminary; it includes the CTC-based attack with a batch size of 1.
This means it requires a slightly larger distortion, and is slower to run than the algorithm that is presented in the paper.
Soon™ I will add these two improvements to this codebase.

To generate adversarial examples for your own files, follow the below process and modify the arguments to **attack.py**

Ensure that the file is sampled at **16KHz**.
You may want to modify the number of iterations that the attack algorithm is allowed to run.

### Instructions for basic use:

1. Install the dependencies

    ```pip3 install --user numpy scipy tensorflow-gpu pandas python_speech_features```

2. Clone the Mozilla DeepSpeech repository into a folder called DeepSpeech:

    ```git clone https://github.com/mozilla/DeepSpeech.git```

3. Checkout the correct version of the code:

    ``` cd DeepSpeech; git checkout tags/v0.1.1```

4. Download the DeepSpeech model

    ```wget https://github.com/mozilla/DeepSpeech/releases/download/v0.1.0/deepspeech-0.1.0-models.tar.gz```
    ```tar -xzf deepspeech-0.1.0-models.tar.gz```

5. Verify that you have a file models/output_graph.pb, it's MD5 sum should be
    ```08a9e6e8dc450007a0df0a37956bc795.```

6. Convert the .pb to a TensorFlow checkpoint file

    ```python3 make_checkpoint.py```

7. Generate adversarial examples

    ```python3 attack.py --in sample.wav --target "example" --out adversarial.wav```

8. (optional) Install the deepseech utility:

    ```pip3 install deepspeech-gpu```

9. Classify the generated phrase

    ```deepspeech models/output_graph.pb adversarial.wav models/alphabet.txt```

gha_license_id: NOASSERTION


text:
# PADLOCK Whitepaper
This is the white paper for the PADLOCK protocol.

It is still a work in progress, any edits are greatly appreciated. Please submit
edits via pull request.

If you are unable/unwilling to contribute, issues are still helpful, feel free
to submit.

PDF format is available under releases.

  To the extent possible under law,

    Ellis Frank
  has waived all copyright and related or neighboring rights to
  PADLOCK Whitepaper.
This work is published from:

  Canada.

repository: padlock-xpl/padlock-whitepaper

repo_name: padlock-xpl/padlock-whitepaper


text:
# [1124. Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval/)

We are given `hours`, a list of the number of hours worked per day for a given employee.

A day is considered to be a *tiring day* if and only if the number of hours worked is (strictly) greater than `8`.

A *well-performing interval* is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days.

Return the length of the longest well-performing interval.

**Example 1:**

```
Input: hours = [9,9,6,0,6,6,9]
Output: 3
Explanation: The longest well-performing interval is [9,9,6].
```

**Constraints:**

- `1 <= hours.length <= 10000`
- `0 <= hours[i] <= 16`

-----

**题目**：求解最长的子数组使得大于8的元素数目比小于等于8的元素多。

**思路**：前缀和。将`hours[i]>8`的当作1，`hours[i]<=8`的当作-1。记当前元素和为`cursum[i] = sum(hours[0...i])`，那么我们需要找到一个最长子数组`hours[i...j]`满足cursum[j] - cursum[i] >= 1，当cursum <= 0时，则转化为查找是否出现过cursum-1这个前缀和。

[**工程代码下载**](https://github.com/shenkh/leetcode)

```cpp
class Solution {
public:
    int longestWPI(vector<int>& hours) {
        int n = hours.size();
        unordered_map<int, int> mp;
        int res = 0, cursum = 0;
        for(int i = 0; i < n; ++i){
            cursum += (hours[i] > 8 ? 1 : -1);
            if(cursum > 0)
                res = i + 1;
            else{
                if(mp.find(cursum - 1) != mp.end())
                    res = max(res, i - mp[cursum-1]);
                // 只保留当前和第一次出现的位置，这样能使得区间最大化
                if(mp.find(cursum) == mp.end())
                    mp[cursum] = i;
            }
        }
        return res;
    }
};
```

url: https://raw.githubusercontent.com/shenkh/leetcode/16d3d76d74b1bff9c062a311545d9843eea677fe/1124. 表现良好的最长时间段 [Medium] [Longest Well-Performing Interval].md

repository: shenkh/leetcode

repo_name: shenkh/leetcode


text:
# binary-extensions [![Build Status](https://travis-ci.org/sindresorhus/binary-extensions.svg?branch=master)](https://travis-ci.org/sindresorhus/binary-extensions)

> List of binary file extensions

The list is just a [JSON file](binary-extensions.json) and can be used anywhere.

## Install

```
$ npm install binary-extensions
```

## Usage

```js
const binaryExtensions = require('binary-extensions');

console.log(binaryExtensions);
//=> ['3ds', '3g2', …]
```

## Related

- [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a filepath is a binary file
- [text-extensions](https://github.com/sindresorhus/text-extensions) - List of text file extensions

---

		Get professional support for this package with a Tidelift subscription

		Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

gha_language: JavaScript


text:
# doa-tm4c123
Simple DOA (correlation and projection into main component) estimation with tm4c123 u-controllers using Direct Register Access.
* Created 2 ADC's drivers
* Using uDMA to memcpy data from  2 ADC's
* Using Protothreads for fast and low overhead multithreading
* Drives a Nokia5110 LCD display to verify that things are not as we expect.
Some parts are messy because it was made a long time ago, when digital modulations were based on clinging a High voltage dieletric to produce electric arcs and we could count with our hands how many generations of pokemon there were.


text:
## General Machine Learning Concepts
### Bias Variance Trade-off
#### Regularization
### Common Distributions
#### Discrete
* Bernouilli
* Binomial
* Multinouilli
* Multinomial
* Poisson
* Empirical

#### Continuous
* Gaussian
* Student t
* Laplace
* Gamma
* Beta
* Pareto
* Dirichlet
### Curse of Dimensionality
----
### Decision Theory
### Ensemble Learning
#### Boosting
#### Bootstrapped Aggregation (Bagging)
#### Stacked Generalization (Blending)
#### Averaging Generalization
### Estimators
#### Maximum Likelihood Estimation
#### Maximum A Posteriori Estimation (MAP)
#### Bayesian Modeling
### Evaluation Metrics
#### Classification Metrics
----
#### Regression Metrics
### Frequentist vs Bayesian
* :mag:  Side Notes  :

    * Don't get mistaken: using Bayes rule doesn't make you a Bayesian. As my previous ML professor [Mark Schmidt](https://www.cs.ubc.ca/~schmidtm/){:.mdLink} used to say: "If you're not integrating, you're not a Bayesian". :sweat_smile:

    * If you understood well the point of view of frequentist, you might be surprised of seeing something like $p(x\| \Theta)$, which means the "conditional distribution of *x* given $\Theta$". Indeed for frequentists $\Theta$ is not a random variable and thus conditioning on it makes no sense (there's a single value for $\Theta$ which may be unknown but is still fixed: it's value is thus not a condition). Frequentists would thus write such distributions: $p(x;\Theta)$ which means "the distribution of *x* parameterized by $\Theta$". In statistics and machine learning, most people use $\|$ for both cases. Mathematicians tend to differentiate between the notations. In this blog, I will use $\|$ for both cases in order to keep the same notation as other ML resources you will find.

#### Gaussian Process

----
Now the Generative classifiers

----

#### Gaussian Discriminant Analysis
#### Gaussian Mixture Model
#### Latent Dirichlet Allocation

### Regression
#### Linear Models
##### Linear Regression
Normally use OLS but could use something else to estimate
##### Ordinary Least Squares
estimation technique: often used in Linear regression
#### Decision Trees
----
#### Gaussian Processes

### Ranking
## Unsupervised Learning

### Clustering
Nota Bene: Careful when ensemble learning to label switching
#### Density Based Clustering
#### Hierarchical Clustering
#### K-Means
#### K-Nearest Neighbors (KNN)
#### Spectral Clustering

### Density Estimation
#### Collaborative Filtering
Recommender systems (also content based or hybrid)

### Dimensionality Reduction
#### Autoencoders
#### Independent Component Analysis (ICA)
#### ISOMAP
#### Linear Discriminant Analysis (LDA)
#### Multidimensional Scaling (MDS)
#### Principal Component Analysis (PCA)
#### Projection Pursuit
#### Sammon Mapping
#### Self-Organizing Maps
#### T-SNE

### Outlier Detection
Nota Bene: distinguish global and local outliers
##### Cluster-Based
##### Distance-Based
##### Graphical Approaches
##### Model-Based

## Reinforcement Learning
### Exploration vs Exploitation
---
### Markov Decision Process
---
### Dynamic Programming
---
### Monte Carlo Methods
---
### Temporal Difference Learning
---
#### Expected Sarsa
#### N steps Expected Sarsa
### Eligibility Traces TD($\lambda$)
### Policy Gradient Methods
### Model Based RL
### Function Approximation
#### Deep Reinforcement Learning
### Links to Neuroscience

## Partially supervised learning
non t called like that
### Active Learning
### Semi-supervised learning

## Approximate Inference
### Deterministic
#### Variational Inference
Comes from Calculus of variation
- standard calculus finds derivative of functions (mapping of input values of a variable to output value). Derivative gives inenitiisimal change in output due to inifnicsimal input change.
- functional takes function as input. For example entropy takes a probability distribution as input. so functional derivative is infinitisimal change in output due to change in pinput function. basically same rule applies

variational inference is simply max/min in function space, and restrict your input space to some family
##### Mean Field

Use only factorized distribuion

##### Normalizing Flows

Take a simple distribution and then transform the samples to make it mroe coplicated :

https://akosiorek.github.io/ml/2018/04/03/norm_flows.html

### Stochastic
Sampling Based
#### MCMC

## Deep Learning
### Backpropagation
### Feed-forward Neural Networks
### Convolution Neural Network
### Recurrent Neural Network
### Autoencoders
### Regularization
* Early Stopping
* Dropout
* Multi-task Learning
* Norm Penalties

### Deep Generative Models
#### Variational Autoencoders
-----
#### Generative Adversarial Networks
#### Neural Autoregressive
#### Flow-based deep generative models

## Graphical Models
### Directed Graphical Models (Bayes Networks)
### Undirected Graphical Models (Markov Networks)
#### Pair Wise Undirected Graphical Models
#### Gibbs Networks
#### Conditional Random FIelds
- https://prateekvjoshi.com/2013/02/23/what-are-conditional-random-fields/
- generalization of multinomial listic regression to seuence prediction (i.e y's are dependent)
- https://www.youtube.com/watch?v=GF3iSJkgPbA
- http://blog.echen.me/2012/01/03/introduction-to-conditional-random-fields/
- discriminative probabilisticc
- advantage over HMM for classification because learn p(y|x) instead of joint
- use for labeling sequences
- using conditional probabilities is udes to relax the conditional independence of naive bayes (like logistic regression) or the conditional indep required in HMM
- HMM are subcase of CRF  where constant probabilities are used to model state transitions.

## Natural Language Processing

## Time Series

## Optimization

### Convex Optimization
#### Linear Programming
##### Canonical and Slack form
----
##### Duality
##### Simplex Algorithm

### Non Convex Optimization

#### Bayesian Optimization
#### Robust Optmization
#### Evolutionary Methods
Compare to RL : If the space of policies is sufficiently small, or can be structured so that good policies are common or easy to find or if a lot of time is available for the search then evolutionary methods can be effective. In addition, evolutionary methods have advantages on problems in which the learning agent cannot sense the complete state of its environment.
##### Genetic algorithms
#### Simulated annealing
#### Tabu Search
#### Hill climbing with random restart
#### Nelder-Mead heuristic

## Information Theory
### Kolmogorov Complexity
the Kolmogorov complexity of an object, such as a piece of text, is the length of the shortest computer program  that produces the object as output

### Minimum Description Length
Suppose we consider a number of different hypotheses for some phenomenon.
We have gathered some data that we want to use somehow to evaluate these
hypotheses and decide which is the“best”one. The minimum description length (MDL) criteria in machine learning says that the best description of the data is given by the model which compresses it the best. Put another way, learning a model for the data or predicting it is about capturing the regularities in the data and any regularity in the data can be used to compress it. Thus, the more we can compress a data, the more we have learnt about it and the better we can predict it. n complexity and goodness of fit

MDL is also connected to Occam’s Razor ( principle of parsimony) used in machine learning which states that “other things being equal, a simpler explanation is better than a more complex one.” In MDL, the simplicity (or rather complexity) of a model is interpreted as the length of the code obtained when that model is used to compress the data. The ideal version of MDL is given by the Kolmogorov Complexity.

L_{MDL}(D) := min_{H \in \mathcal{H}} (L(H) + L(D|H))

Bayesian inerpretation: looking to minimize −[log prior + log likelihood]. => same as looking for MAP

### Information Bottlneck

the idea is to compress while keeping all the "important" infrormation

by maximizing the mutual information of X and its compressed counterpart Z (they call x tilda), you would keep the more infromation you can in a unsupervised way. But you can do in a supervised may by maximizing I(Z,Y) where Y is a sueprvised task (e.g. classification). If you wanted to maximize this you would simply not compress at all and set Z = X. But you want to compress maximize under the constraint that I(Z,X) < gamma. Using lagrange multipliers, this turns into max(I(Z;Y) - beta I(Z;X)). => effectively also maximizing the compression. => maximizing bottleneck by forcing Z and X to be different distributions.  Note that cannot just minimize entropy of Z because for some tasks a very small entropy is enough to encode all. beta gives the tradeoff between accuracy and compresssion

Note that often actually minimize  - 1/beta * (I(Z;Y) - beta I(Z;X) ) =  I(Z;X) - 1/beta I(Z;Y)  =  I(Z;X) - beta' I(Z;Y)  which is equivalent

an other simpel way of seeing it, is to maximize compression while keeping all the important information:

min I(Z;X)
s.t. H(Y|X) = H(Y|Z)

R/ compression can either be in size (ex: autoencoder) but also in information Ex: dropout / noisy atoencoder => not less but add noise

Note that to do this, it is assuemd that you have p(x,y) which is a hard task on its own (i.e ML)

link with rate distortion theory:
if want to compress input to max R I(z;x), what is the lowest distortion  D that you can get =>
E_{x,z}[D(x,z)] s.t. I(Z;X) <= R.
if D(x,z) = KL(p(y|x) || p(y|z)), then rate distortion is equivalent to information bottleneck

### FIsher Information

If we have a known density p(X|theta), then information asnwers the question "how useful is X to determine theta". i.e. amount of information that an observable random variable X carries about an unknown parameter θ.

If f is sharply peaked with respect to changes in θ, then there's only a small range of possible theta that could explain data => doesn't need much data. => variance of parameters in sharp distribution is smaller than flat. This suggests studying some kind of variance with respect to θ.

If very shap then curve is high => high hessian / second derivative => low variance (donc proportional to inverse of hessian). Fisher information is hessian of log likelihood. hus, the Fisher information may be seen as the curvature of the support curve (the graph of the log-likelihood). Near the maximum likelihood estimate (because look at derivative at MLE), high Fisher information indicates that the maximum is sharp.
=> can be used to compute confidence intervals in frequentist statistis

Formally, the partial derivative with respect to θ of the logarithm of the likelihood function p(X|theta) is called the “score”.  if θ is the true parameter, it can be shown that expectation is 0. Fisher information is the variance => expectation of squared derivative of log likelohood. FOr high dimension hessian.

#### Cramer Rao Bound
The Cramér–Rao bound states that the inverse of the Fisher information is a lower bound on the variance of any unbiased estimator of theta
var(\hat theta) = I^{-1}(theta)

Note that this is similar to : "What’s the distribution of the unknown parameter?". but with frequentist view => makes no sense to talk about distribution of parameters.

Source:
- https://www.quora.com/What-is-an-intuitive-explanation-of-Fisher-information
- https://www.youtube.com/watch?v=i0JiSddCXMM

## Computational Neuroscience
### Spiking Neural Networks

## Other
### Causal Learning
#### Counter Factuals
### State Space Models
### Optimal control
https://vincentherrmann.github.io/blog/wasserstein/
we look at the minimal amount of energy to move one distribution to an other (it's similar to KL divergence but instead of looking at the difference in the y axis (i.e difference of probability given to each point in both distribution) you look at the distance in x axis (i.e how much energy does it take to make one one distribution turn itno an other). For example if there are 2 very non linear pdf that are the same but shifted by a small amout, the KL might be very big (because difference of probability given to each point might be big) but not the earth moving disatnce)
### Useful Tricks
#### Density Ratio Estimation
Many tasks in probabilistic ML, require estimation of ratio of probabilities:
* importance sampling: p(x)/q(x)
* KL divergence E_p[log(p(x)/q(x))]
* COnditional probability: p(y|x)=p(y,x)/p(x)
* hypothesisi testing : r(x)=p(x|H_0)/p(x|H_1)

often the probabilities are unkown (or in   tractable), so can't compute numerator and denom eparately then divide, we may only have samples drawn from the two distributions, not their analytical forms. Dnsity ratio estimation says that can sompute the ratio using a dbinary discriminator D that says if x is from p:
r(x)=p(x)/q(x)= D(x)/(1-D(x))
=> if have samples can simply train discriminator and woudl get the ratio.

info:
- intuitive explanantion: http://blog.shakirm.com/2018/01/machine-learning-trick-of-the-day-7-density-ratio-trick/
- more details : http://yosinski.com/mlss12/media/slides/MLSS-2012-Sugiyama-Density-Ratio-Estimation-in-Machine-Learning.pdf
- code and plots : http://louistiao.me/notes/a-simple-illustration-of-density-ratio-estimation-and-kl-divergence-estimation-by-probabilistic-classification/

## Probabilities
### Definition
### Gaussian
### Bernoulli
### Exponential
### Poisson
### Exponential Family
### Distribution
### Processes
2 explanations

* Random process is a sequence of random variables. To answer any question we might be interesting in, we need to know the mean and variance of every variable, but this is not all. Indeed, r.v. can be dependent so we need to know the joint distribution of every subset of r.v. e.g. P(X_1, X_3, X_9)?
* Treat the whole èrpcess as a single r.v. where the output is any possible sequence/path/function (e.g. 0 1 for bernoulli / randov variable over function for gaussian process). With this view can start asking questions about infinit sequence. E.g. in bernoulii : proba of all 1? Would be 0 if p in [0,1[. Furthermore every sequence has proba -> 0 (because multiply proba that are less than 1), but there's an infinite number of possible => sum of all is still 1. It's like when continuous r.v.

### Bernoulli Process
Collection of i.i.d bernoulli r.v. => joint of any subset is simply product

* discrete time
* number of arrivals in n time slots : binomial pmf
* interarival time : geometric pmf
* time to k interval : pascal pmf
* memoryless (once arrival comes, proba to next arrivl is indep. I.e. as if process start again at every time step)

info : https://www.youtube.com/watch?v=gMTiAeE0NCw&index=13&list=PLUl4u3cNGP61MdtwGTqZA0MreSaDybji8

### Poisson Process

* geenralize bernoulli process to continuous => if counting number of clientd that came, instead of putting a 1 or 0 at every second you want to be more precise (what if 2 client come in same second) => go to milisieconb => go to continuous => no more slots, simly write down time when client came
* time homogeneitynumber of clients per interval only depend on time. But every "time slot" (although continuous) has same proba of success
* independence of joint time interval (=> same as saying in discrete time that different time are indep r.v.)
* during very small delta time (infinitely small).
    - proba of seeing 1 client is lambda * delta
    - not seeing is 1-lambda*delta
    - ore than 1 client is 0
    - Lambda is "arrival rate" and is (expected # arrival)/time unit
* number of arrival in interval of lentgh tau (was binomial in discrete case). can approx as having n bernoulli where n = tau/delta and proba of each is p=lambda * delta => take limit of bernoulli when delta -> 0 => poisson
* interval time distribution is limit of geometric as delta-> 0 => exponential

info :
* https://www.youtube.com/watch?v=jsqSScywvMc&index=14&list=PLUl4u3cNGP61MdtwGTqZA0MreSaDybji8
* https://www.youtube.com/watch?v=XsYXACeIklU&list=PLUl4u3cNGP61MdtwGTqZA0MreSaDybji8&index=15

### Markov Chain

* generalization of previous processes but now not indep
* new state = f(old state, noise)
* Pretty much any process can be described as markov process if defined with the correct notion of state

info:
* https://www.youtube.com/watch?v=IkbkEtOOC1Y&list=PLUl4u3cNGP61MdtwGTqZA0MreSaDybji8&index=16

### Simple symmetric random walk

Dsicrete stochastic process where the location can only jump to neighbouring sites of a lattice (Simple) with equal probability (symmetric). *e.g.* often talk about random walk where can only take a step +1 or -1 whith Bernoulli probability.

Notes:
- maximum height achieved is on the order of sqrt(n)

### Brownian Motion
Continuous time generalization of a random walk.

definition:
- B(0) = 0
- B(t) indep of B(t')
- B(t) - B(s) ~ gaussian(0, t-s)

Note:
- it is the integral of a white noise gaussian process (i.e goes up or down with mean 0), but brownian adds this noise to last value => integral
- crosses the time axis infinitely often
- most often it's contained in [-sqrt(t), sqrt(t)]
- nowhere differentiable => cannot use calculus (have to use Ito's calculus that extends calculus to this)
- one genralization of Brownian motion is an **ito process**, which basically is a brownian motion with possibly non zero mean (=> introduces correlation)
- an other generalization is the **marrtingale**Stochastic process where $$\mathbb{E}[X_{n+1}\vert X_{1:n-1}]=X_n$$. It is a generalization of a random walk and brownian motion.
- use langevin equation (f=ma generalized when random forces), to study systems of brownian motion
- also a gaussian process with mean 0 and variance t and cov(s,t) = s (becaus indep => only variance)

### Gaussian Process
Collection of r.v. s.t. every finite subset if distribution accoring to multivariate gaussian

## Statistics
### Definitions
**Nuisance Parameters**
Any parameter which is not of immediate interest but which must be accounted for in the analysis of those parameters which are of interest. The classic example of a nuisance parameter is the variance, σ2, of a normal distribution, when the mean, μ, is of primary interest. Usually you have to marginalize over the nuisance parameters.
**Statistic**
More generally, we call a function of the data, say, T = t(Xn
) a statistic. A statistic is referred to as sufficient for the parameter θ, if the expression P(Xn ∣T = t, θ) does not depend on θ itself. T
**Moments**
n-th moment of a function:
$$\mu_n = \int_{-\infty}^\infty (x - c)^n\,f(x)\,\mathrm{d}x$$

=> for probability E[(X-c)^n]. c=0 => raw moment moment. c = mean => central moemnt, they describe the sahpe of the function independently of translation.

FOr PDF:
- Normalized nth central moments:  E[(X-mu)^n]/sigma^n
- mean : first moment
- variance : second central moment
- skewness : third normlized moment
- kurtosis _ fourth normalized moment

## Linear Algebra
## Math
### General
#### Norm

##### Finite Dimensions

Property:
- $\vert \mathbf{x} \vert \geq 0$ and equality only if $\mathbf{x} = 0$
- (positive homogoneity) $\vert \alpha x \vert = \alpha \vert  x \vert, \ \forall \alpha \in \mathbb{R}$
- triangle inequality

These are true for all $L_p$ norms with $p \geq 1$ :

$$||\mathbf{x}||_p = (sum_{-\infty}^{\infty} |\mathbf{x}|^p )^{1/p}$$

Important norms:
- l1
- l2
- l inf

Note:
- $\left\| x \right\| _p \leq \left\| x \right\| _r \leq n^{ (1/r - 1/p) } \left\| x \right\| _p, \ forall 0 < r < p$
- can be extended to infintie number of components (sequence space). This yields the space $ℓ p$
- can be extended to function for which  the $p^{th}$ power of the absolute value is integrable : $Lp$ space (normally lebesgue integrable but four our use cases we can use riemanian integrals):

$$||f||_p (∫_{-\infty}^{\infty} |f(x)|^p dx)^{1/p} < \infty$$

#### Hilbert Space
- geenralization of euclidean space
-  complex or real inner product space (i.e.  vector space with an inner product) which is complete (i.e. any sequence of points that get closer and closer to each other converges to some point) with respect to the distance (norm between points that satisfies triangular ineq.) defined by the inner prod

Notes :
- generalization of R^n

Ex:
- L2 space: space of square integrable function $||f||_2 < \infty$

Info:
-https://www.quora.com/What-are-Hilbert-Spaces-in-laymens-terms
-https://sadeepj.blogspot.com/2014/05/a-tutorial-introduction-to-reproducing.html

### Measure
$\mu$ is intuitively the size of a set. Example measurre of a box is area.
mu(empty) = 0, sum of measure union is measure of sum of union in disjoint set, measure of subset is smaller than measure of set,

ex:
- lebesgue measure smallest possible sum of open intervals such that the union of the intervals cover the set we are measuring E. Which is what you would think of, for example lebesgue of segment $\[a,b\]$, you take all sets open intervals that cover the segment, and take the minimum of the sums => b-a

*Nota Bene: these terms are not always the most important ones but important ones I have encountered since my "migration" to machine learning / computer science in September 2016.*

Thanks to [Mark Schmidt](https://www.cs.ubc.ca/~schmidtm/){:.mdLink}, my Machine Learning professor, who introduced me to this amazing field.

-----
Additional ----
#### Discriminative Classifiers

I devoted a [section](#generative-vs-discriminative){:.mdLink} to discriminative classifiers but in summary these are the algorithms that directly learn a (decision) boundary between classes.

As a reminder these can be either:
* **Probabilistic**: the algorithm has a probabilistic interpretation: it tries to model $p(y\|x)$.
* **Non-Probabilistic**: the model cannot me interpreted with probabilities: it simply "draws" a boundary which you will simply use to predict.

-----

Other concepts ??
- Maximum Mean Discrepancy


text:
# caseman

Easily manage test case record setups and teardowns for MSSQL databases using this command line utility.

## features

  - Define test cases in a simple node module input file format.
  - Records defined are placed into a JSON output file that the teardown utility can use to delete your records after your test case has run.
  - Backreference previously defined rows (or even the current row) in your input file to define field values for input. This is useful when relating entries by auto-incremented primary keys, or sequence numbers that have been populated by a sequence function.

### Configuration

Caseman will look for a config file in your present working directory (`pwd`), or you can specify the path to the config file as the last parameter given to any command.

The following is a complex example of a config file that defines everything that can be defined. A discussion of config parameters follows.

```javascript
module.exports = {
    getSequenceSqlFunction: function(id,variableName) {
        /**
         * Returns the next number for the secondary primary key for a given table.
         * Yes. I know tables shouldn't have a secondary primary key. Good luck telling
         * the DB designer that.
         *
         * @param strTableName string name of the table you want to get the next number for.
         * @return promise that resolves with an integer ID
         */
            /**
             * Returns the rather cryptic "NextNumber" ID code name
             *
             * @param strTableName string name of table you want to know the next number ID
             *        code name for
             */
            var getNextNumberIdNameByTableName = function(strTableName,varName) {
                var ref = {
                     'ImportMaster'                : 'ECOMMIMPID'
                    ,'ImportDetails'               : 'ECOMMIDTID'
                    ,'AddressMaster'               : 'ADDRESSID'
                    ,'AccountPledges'              : 'PLEDGEID'
                    ,'AccountMaster'               : 'ACCTNBR'
                    ,'TransactionResponseMaster'   : 'RESPONSEID'
                    ,'RecurringTransactionHeaders' : 'RECTRANSID'
                };
                if(typeof ref[strTableName] == 'undefined') {
                    console.log(strTableName + ' is not a nextNumber enabled table.');
                    return false;
                }
                return ref[strTableName];
            };

            return function() {
                var strType = getNextNumberIdNameByTableName(id);
                var strSql = "EXEC [dbo].[X31_NextNumberBusinessDataSingleValueByType] @strType=N'"+strType+"',@iNextNumber=@"+variableName+" OUTPUT\n";
                return strSql;
            };
    },
    mssql: {
         user       : process.env.ROUNDSQL_USER
        ,password   : process.env.ROUNDSQL_PASS
        ,server     : process.env.ROUNDSQL_HOST
        ,database   : process.env.ROUNDSQL_DBNAME
        ,port       : process.env.ROUNDSQL_PORT
    }
};
```

##### Config parameter: getSequenceSqlFunction

This method should return a function that will be called by caseman to return a SQL Statement that populates the given variable with data. The string returned by the function will be inserted into the SQL transaction and is expected to populate the given variable with the sequence value.

This function takes a sequence identifier, and a variable name.

The sequence identifier usually a string or a table name identifying which sequence you will be getting sequence data from.

The variable name is the name of the transaction variable that the rest of the transaction will use to reference the sequence value.

##### Config parameter: mssql

The mssql config parameter is given to the node-mssql module as provided. Please see [mssql](https://github.com/patriksimek/node-mssql) for more information on configuration for the mssql module.

### Usage

Caseman has two commands:

#### build

Syntax:

```sh
caseman build inputfile outputdir [configfile]
```

The build command parses through your file to create a single large transaction that will be executed to set up your test cases. Current performance metrics show that a test setup with about 90 or so records takes about 4 seconds to set up.

During the build process, caseman will auto-discover table column data and use prepared statement binding by data type to insert data.

The javascript input format defined below allows you to back-reference values gathered for the previously entered rows.

#### teardown

Syntax:

```sh
caseman teardown outputfile [configfile]
```

The teardown command takes the output file that was created during the build process as its input.

The teardown process will use the information in the output file to discover information necessary for cascade deleting as was defined in the build file, then it will run a single transaction to run all the deletions by primary key or cascade delete as was defined in your build file.

Please do try to be careful with your cascade deletes. We of course can't make any guarantee you won't reference the wrong field and delete random bits of data. However, if you enter the right column, we're fairly certain it will work as expected.

### The build file

Each test case is defined with a build file that defines the records you want to set up in your database for your test cases.

Below is an example of a test case definition file (test case build file) that is run for a certain test case.

File: login_test.js
```javascript
module.exports = {
    "name": "testing simple account login to web site"
    ,"description": "Single account with email address, password and physical address."
    ,"records": [{
        "table":"AccountMaster"
       ,"sequences": {
           "AccountNumber": "AccountMaster"
       }
       ,"deleteCascade": {
           "AccountFirstContacts":{"AccountNumber":"AccountNumber"}
           ,"AccountCommunications":{"AccountNumber":"AccountNumber"}
           ,"TransactionMaster":{"AccountNumber":"AccountNumber"}
           ,"AccountSalutations":{"AccountNumber":"AccountNumber"}
           ,"AccountPledges":{"AccountNumber":"AccountNumber"}
           ,"RecurringTransactionHeaders":{"AccountNumber":"AccountNumber"}
       }
       ,"row": {
             "FirstName"         : "TESTJON"
            ,"LastName"          : "TESTWATSON"
            ,"AccountType"       : "I"
            ,"FamilyConsolidate" : 0
            ,"AllowTransactions" : 1
            ,"Status"            : "A"
       }
    }
    ,{
        "table":"AddressMaster"
       ,"sequences": {
           "AddressId": "AddressMaster"
       }
       ,"deleteCascade": {
           "TransactionResponseMaster":{"AddressId":"AddressId"}
       }
       ,"row": {
             "Type"           : "HOME"
            ,"AddressLine1"   : "123456 E TEST AVE"
            ,"City"           : "TESTVILLE"
            ,"State"          : "AZ"
            ,"ZipPostal"      : "85379"
            ,"Country"        : "USA"
            ,"AddressIsPOBox" : 0
       }
    }
    ,{
        "table":"AccountAddresses"
       ,"populateFrom": {
           "AccountNumber": {"AccountMaster":"AccountNumber"}
           ,"AddressId": {"AddressMaster":"AddressId"}
       }
       ,"row": {
             "Active"       : 1
            ,"UseAsPrimary" : 1
       }
    }
    ,{
        "table":"AccountEmails"
       ,"populateFrom": {
           "AccountNumber": {"AccountMaster":"AccountNumber"}
       }
       ,"row": {
             "EmailType"    : "HOME"
            ,"EmailAddress"<EMAIL_ADDRESS>            ,"Active"       : 1
            ,"UseAsPrimary" : 1
            ,"DataSource"   : "FH"
       }
    }
    ,{
        "table":"AccountNotes"
       ,"populateFrom": {
           "AccountNumber": {"AccountMaster":"AccountNumber"}
       }
       ,"row": {
             "NoteType"     : "YWEBPASS"
            ,"ShortComment" : "testing"
            ,"LongComment"  : "testing"
            ,"DataSource"   : "FH"
       }
    }
]};
```

#### Input file properties

For the purposes of this discussion, let e = the object stored in module.exports after evaluating this file.

##### e.name

string: This is the name of the test case for your reference. It is also used to construct the file name of the output file.

##### e.description

string: This is a description that is only used for your reference. It is not used elsewhere.

##### e.records

array: Array of record objects that define the records you want to insert for your test case.

#### Record object properties

Each record object defines a row you want to insert into a particular table. Properties and their meanings are defined here:

##### table

string: The name of the table you want to insert data into

##### sequences

object: Defines the field that will receive the sequence along with the sequence identifier that will be passed to your sequence function.

If you have defined a sequence object in your case definition file without defining a sequence function getter in your caseman config file, the process will fail with an error.

The format of the object allows you to specify fieldnames as properties, and the sequence identifer as the property's value.

##### deleteCascade

object: Defines other records that should be deleted first so that you will not violate a foreign key constraint by deleting this record during the teardown process.

Caseman currently only supports one level of delete cascading. In the given example, the AccountMaster table must first delete a record from AccountFirstContacts. However, if the insertion into AccountFirstContacts also triggered an insertion into some other table, caseman has no recursion. This may come in a later version of caseman. Feel free to submit a pull request if you feel you have implemented it well.

The deleteCascade object's property names are tables that have rows that should be deleted first before deleting the record in question.

The value of each property is another object that defines the local and foreign key that will be used to find the record to delete.

The property is the local key, meaning the fieldname on AccountMaster in the given example. The value is the foreign key meaning the field name on AccountFirstContacts in the given example.

##### populateFrom

object: Defines fields in this record that should be populated from previously defined records.

Note: populateFrom does not query the database to get values that can't be acquired from a sequence or static values defined in your file. That may come in a later release, or you can submit a pull request if you feel you have implemented that well.

Properites are local field names and their values are objects that define the tablename: fieldname that the local field should be populated from.

##### reusableAutoIncrement

string: Defines the name of an autoincremented primary key field on this table that you want to use in a later model's populateFrom field. This must be declared in the model that the value is coming from so that it can be used later.

##### row

object: Defines static data that should be inserted into e.table.

Note that date values must be entered as date objects. If the field in your database has a data type of datetime, then you must set the value to new Date('...').

Example:

```javascript
       ,"row": {
            "StartDate"       : new Date(2015,2,15)
       }
```

Note that you should not define static data for a field that is also found in sequences or populateFrom.

## Command line examples

```sh
$ caseman
# displays the help text for the program
```

```sh
$ caseman build login_test.js path/to/outputdir
```

```sh
$ caseman teardown path/to/outputdir/outputfilename.json
```

### Installation

```sh
$ npm i -g caseman
```

### Development

Want to contribute? Great!

Roadmap:

- I'd love to expand the code to support other DBMS's. So far I have only needed it for connecting to MSSQL Server.
- Recursion in the cascadeDelete would be helpful.
- Making populateFrom go get data from any table in the database regardless of whether it was in the case definition file to begin with or not would be useful.

### Todo's

 - Write Tests
 - Contribute

License
----

MIT


text:
---
layout: post
title: "Find Umpire Strike Zones with R and pitchRx"
categories: saber
---

Ever wonder how “high” or “low” an umpire’s strikezone is compared to the rest of the leauge? Thanks to some public data and the PitchRx package, it’s easy to use a cluster analysis to figure it out!

## Tim Timmons vs. the League

For this analysis I’m going to pick on umpire Tim Timmons, for no other reason than I like his name. The first thing I’ll want to do is create a subset where Timmons is the home plate umpire. Note, in the SQL query at the end of the article I’ve already sorted my data to only include home plate umpires and named the data frame ‘umpZone.’

 Refer to the SQL at the end of the article for the data collection method.

Now that we’ve got all the pitches where Timmons was the home plate ump., the next thing is to parse the data even further to include only pitches that were a called ball or strike.

{% highlight r %}
TimNoswing
{% endhighlight %}

{% highlight text %}
## Error in eval(expr, envir, enclos): object 'TimNoswing' not found
{% endhighlight %}

{% highlight r %}
AllNoswing
{% endhighlight %}

{% highlight text %}
## Error in eval(expr, envir, enclos): object 'AllNoswing' not found
{% endhighlight %}

## Visualizing the Strike Zone

Now we get to the fun part! There’s a couple ways to go about this. The simplest way is to go directly to the strikeFX function that’s included in the pitchRx package. To visualize strike zones for Timmons vs. the rest of the league you would do something like this.

{% highlight r %}
strikeFX(TimNoswing, geom="tile", density1=list(des="Called Strike"), density2=list(des="Ball"),
         layer=facet_grid(.~stand))
{% endhighlight %}

{% highlight text %}
## Error in match(x, table, nomatch = 0L): object 'TimNoswing' not found
{% endhighlight %}

...and then

{% highlight r %}
strikeFX(AllNoswing, geom="tile", density1=list(des="Called Strike"), density2=list(des="Ball"),
         layer=facet_grid(.~stand))
{% endhighlight %}

{% highlight text %}
## Error in match(x, table, nomatch = 0L): object 'AllNoswing' not found
{% endhighlight %}

### Timmons

### Leauge

## What do the Heat Maps Say?

The “all umpires” map looks much more filled out compared to Timmons’ simply because there are more data points. However, Timmons appears to have a comparable strike zone to the rest of the umpires in the league.

There are a couple interesting points to both maps.

* The Strike zone appears to be a bit low in general.

* The zone appears to shift depending on the batter’s stance.

The reason for the zone appearing low could very well depend on the batter’s height. The true zone is between a batter’s waist and knees, so the zone is variable depending on height. In this case we’re using a “standardized” strike zone based on an average height. Also, it would be helpful to keep in mind that Pitch f/x technology is very good but may not be perfect.

The shift of the strike zone between left-handed and right-handed batters also has a simple explanation. When looking at the heat maps it’s helpful to imagine a batter standing there, most likely crowding the plate.

## Alternate Visualization Methods

It’s been proposed that the ‘mgcv’ package in R provides superior strike zone visualizations due to its ability to “smooth” the data accurately using cross-validation. The result is a better looking heat map that enables us to see the zone a little better. But there is one caveat, this method is a RAM killer! I’m working with 8 GB of RAM so I only applied this method to Timmons’ data frame. I would recommend more if you want to apply this to a larger data frame.

First, create a binomial model from the ‘TimNoswing’ data frame.

{% highlight r %}
StrikeModel
{% endhighlight %}

{% highlight text %}
## Error in eval(expr, envir, enclos): object 'StrikeModel' not found
{% endhighlight %}

Then, use strikeFX to plot the model.

{% highlight r %}
strikeFX(TimNoswing, model=StrikeModel, layer=facet_grid(.~stand))
{% endhighlight %}

{% highlight text %}
## Error in match(x, table, nomatch = 0L): object 'TimNoswing' not found
{% endhighlight %}

### Timmons with Model

If you’ve used pitchRx to create a database already, a SQL query via your R database package is a good solution because it allows you to pull ONLY the data you need for the analysis. The data I’m using here comes fro the follow query written directly into R via my database connection. I put this at the end of the article simply because SQL code isn’t the most exiting thing in the world but I thought it was important to include.


text:
# The Niirrty.Plate configuration file

If you will use the template engine in many different scripts, the best way for doing configure some equal settings,
is to use a configuration file.

## Config properties

The following configuration properties are known:

### `openChars` (string)

   Each template tag starts with a specific character sequence. The default value is `{`.
   You only have to set it if you need an other one.

### `closeChars` (string)

   Each template tag ends with a specific character sequence. The default value is `}`.
   You only have to set it if you need an other one.

### `templatesFolder` (string)

   The templates folder. For usage with config files you have to use a virtual file system by
   `Config::FromFile( … )`

### `cache.mode` [editor|user] (string)

   The template engine cache can be used in 2 different modes.

   The default mode `user` means, use the current defined cache settings

   The other `editor` mode means, ignore all cache setting and rebuild all caches if a template is used.

### `cache.folder` (string)

   The template compiler always must output to a file. It defines the folder/directory that should be used to store the
   compiled templates. This setting is required and must point to an existing folder. PHP must have the right to white
   the compiled template cache file into this folder.

### `cache.lifetime` (int)

   Defines how long (how many seconds) a compiled template file should life before it becomes a invalid state.

   0 means, on each template usage it should be checked if something has been changed. And only if so, the cache is
   newly created.

   The default value is `60`. It means the compiled template (e.g. The HTML + PHP mix) is marked as valid for the next
   60 seconds after compilation without some change checks.

## Config file formats

Config file can be defined currently by the following formats:

### The JSON config file format

```json
{
   "openChars"       : "{",
   "closeChars"      : "}",
   "templatesFolder" : "tplbase:/templates",
   "cache"           : {
      "mode"            : "user",
      "folder"          : "tplbase:/compile-cache",
      "lifetime"        : 120
   }
}
```

## The INI config file format

```ini
openChars       = "{"
closeChars      = "}"
templatesFolder = "tplbase:/templates"
cache.mode      = "user"
cache.folder    = "tplbase:/compile-cache"
cache.lifetime  = 120
```

## The PHP config file format

```php
<?php

return [
   'openChars'       => '{',
   'closeChars'      => '}',
   'templatesFolder' => 'tplbase:/templates',
   'cache'           => [
      'mode'            => 'user',
      'folder'          => 'tplbase:/compile-cache',
      'lifetime'        => 120
   ]
];

```

## The XML config file format

```xml
<?xml version="1.0" charset="utf-8"?>
<config type="UK.Plate">
   <openChars>{</openChars>
   <closeChars>}</closeChars>
   <templatesFolder>tplbase:/templates</ignoreWhitespace>
   <cache>
      <mode>editor</mode>,
      <folder>tplbase:/compile-cache</folder>
      <lifetime>120</lifetime>
   </cache>
</config>
```

## How to use the template config file?

You can simple set it globally by using:

```php
<?php
\Niirrty\Plate\Config::FromFile(
   'config:/plate-config.json',
   \Niirrty\IO\Vfs\Manager::Create()
      ->addHandler(
         \Niirrty\IO\Vfs\Handler::Create( 'config folder' )
            ->setProtocol( 'config', ':/' )
            ->setRootFolder( __DIR__ )
         )
      ->addHandler(
         \Niirrty\IO\Vfs\Handler::Create( 'tpl base folder' )
            ->setProtocol( 'tplbase', ':/' )
            ->setRootFolder( __DIR__ )
         )
   )->registerAsGlobalInstance();
```

or without the `->registerAsGlobalInstance()` if you want to use more then one.

and access it elsewhere by need:

```php
<?php
$configArray = \Niirrty\Plate\Config::GetInstance()->toArray();
echo 'Open=', $configArray[ 'openChars' ], ' Close=', $configArray[ 'closeChars' ];
```


text:
---
title: Invariant Object Recognition
event: Seminar for the course - Bio-inspired Artificial Intelligence.

summary:
abstract: "In this paper, we present a bird's eye view of biologically inspired models of visual recognition. The focus of this paper is to identify some components that constitute a class of biologically inspired visual recognition systems which include convolutional neural networks and HMAX like architectures and to identify the optimality of parameters for each of the components and answer some questions that would lead to construction of what we refer to as the optimal biologically inspired hierarchical architecture for object recognition."

# Talk start and end times.
#   End time can optionally be hidden by prefixing the line with `#`.
date: "2014-11-01T13:00:00Z"
date_end: "2015-02-01T15:00:00Z"
all_day: true

# Schedule page publish date (NOT talk date).
publishDate: "2017-01-01T00:00:00Z"

authors: []
tags: []

# Is this a featured talk? (true/false)
featured: false

image:
  caption: 'Untangling object manifolds [1]'
  focal_point: Right

url_pdf: "talk/corticalComputing/corticalComputing.pdf"
url_video: ""

# Markdown Slides (optional).
#   Associate this talk with Markdown slides.
#   Simply enter your slide deck's filename without extension.
#   E.g. `slides = "example-slides"` references `content/slides/example-slides.md`.
#   Otherwise, set `slides = ""`.
slides: ""

# Projects (optional).
#   Associate this post with one or more of your projects.
#   Simply enter your project's folder or file name without extension.
#   E.g. `projects = ["internal-project"]` references `content/project/deep-learning/index.md`.
#   Otherwise, set `projects = []`.
projects:
- internal-project

# Enable math on this page?
math: true
---

1. David D. Cox James J. DiCarlo. Untangling invariant object recognition. TRENDS in Cognitive Sciences, 11(8), July 2007.


text:
# Durandiella seriata (Fr.) J.W. Groves, 1954 SPECIES

#### Status
ACCEPTED

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

#### Published in
Can. J. Bot. 32: 139 (1954)

#### Original name
Cenangium seriatum Fr., 1822

### Remarks
null

repository: mdoering/backbone

repo_name: mdoering/backbone


text:
Please do not spend more than 3 hours on this.
# SOC Test
## Instructions
1. Fork this repo
2. Write a small app that accepts a csv file as an upload. The csv file is a contact list. The contents of the list need to be inserted into a database. There needs to be a way to view and delete after the upload.
4. Either demonstrate in code or provide an explanation in this README on how you would handle very large files.
5. Either demonstrate in code or provide an explanation in this README on how you would handle different encodings.
6. Submit this as a pull request.

For very large files I would have broken the parsing of the csv (and saving to the database) into chunks using python's chunks() function.  For example "for chunk in csv_file.chunks(): save the data".  Usually, you also have to make changes to nginx to accept files above a certain size.

For different encodings, if it's just unicode and utf-8 I'd have to worry about, I'd use the encode() function of python.  However, this is not always really reliable and frankly you have to mess around with it a bit.  If multiple encodings are expected, then I'd probably have to write a table that detects the encoding and decodes it to the correct type for storage in the database.

NOTE: The layout of the pages I've submitted, are by no means ideal.  Flow and user experience would be accounted for better (and I don't have buttons that navigate between the pages), but I tried to keep it simple for the sake of getting functionality correct.


text:
# First Time Setup
Set up venv

`python3 -m venv venv`

Activate venv

`. venv/bin/activate`

Install requirements

`pip install -U -r requirements.txt`

# Run tests
Go to the project level directory.

If you haven't already activated your venv, do so by running

`. venv/bin/activate`

Run

`pytest`

repository: richardfung/finances

repo_name: richardfung/finances


text:
S ingle Responsibility Principle
:	Identifying classes based on responsibilities in the context of current application
O pen-Closed Principle
:	Identifying abstractions
L iskov substitution principle
:	Review implementations that don't really fit the abstraction, rather are look alikes. Create specific abstractions or classes based on the need.
I nterface Segregation Principle
:	Review abstractions & improve by breaking them down to more specific abstractions based on the need.
D ependency Inversion Principle
:	Implement class dependencies or relations such that classes depend on abstractions and not concrete implementations.


text:
# Modified Palindrome

## Definitions
A palindrome is a word that is read the same in both directions
* Example (Palindrome): eye, madam, racecar, noon
* Example (Non Palindrome): test, abc, anything

## Task
1. Implement a modified palindrome where it is case insensitive and ignores any non-alphanumeric characters
 * Examples: _!E#@y#e
 * MaDaM!!
 * RaCEC@A@R
2. Test that the solution is efficient for 1-billion characters


text:
# Expectations

**Website:** [http://remi.github.com/expectations.dart][web]

**Source:** [https://github.com/remi/expectations.dart](https://github.com/remi/expectations.dart)

[Dart][] comes out of the box with a good set of expectations via [Expect][].

Unfortunately, there are some problems with Expect:

 1. There's no way to extend it to add additional expectations, so you would have to
use Expect for some expectations and MyExpect for others.  Not ideal.
 2. Not everyone likes the `Expect.equals(A, B)` syntax.  I always forget, which
argument is the actual and which one is the expected?  Ugh.

Enter `expectations.dart`!

## Get it!

Download [the latest version of **expectations.dart**][latest]

## Usage

```actionscript
#import("expectations.dart");

testWithoutExpectations() {
  Expect.equals("Rover", dog.name);
  Expect.notEquals("Spot", dog.name);
  Expect.stringEquals("Rover", dog.name);
  Expect.identical(expectedDog, dog);
}

testWithExpectations() {
  expect(dog.name) == "Rover";
  expect(dog.name).not == "Rover";
  expect(dog.name).equalsString("Rover");
  expect(dog).identical(expectedDog);
}
```

That's pretty much all there is to it!

### What methods can I call?

Expectations comes out of the box with support for every method that [Expect][] has:

 * `Expect.approxEquals` becomes `expect().approxEquals`
 * `Expect.equals` becomes `expect().equals`
 * `Expect.fail` becomes `expect().fail`
 * ... etc ...
 * See [CoreExpectations][] for API documentation for all methods

Our [CoreExpectations][] were designed to be as similar to [Expect][]'s methods as possible.
We also based this on [another implementation][unittest_expect] of `expect()` that's used in the Dart [unittest][]
test framework, trying to match their implementation as much as possible.

### ToBeExpectations

Out of the box, Expectations' methods look like:

 * `expect().equals`
 * `expect().isNull`
 * `expect().identical`

While this is a perfectly acceptable API, another popular testing framework ([Jasmine][]) has a slightly
different API:

 * `expect().toEqual`
 * `expect().toBeNull`
 * `expect().toBe`

In support of both common APIs, you can configure Expectations to use [ToBeExpectations][] instead of
[CoreExpectations][].

### How do I create/register new expectation methods?

Let's say you want to implement `expect().toBeAwesome`.  First, you need to make a class with the `toBeAwesome`
method on it.  The `expect()` method will return an instance of your class, so `toBeAwesome` can be called on it:

```actionscript
class AwesomeExpectations {
  var target;

  // When expect() is called with an object, eg. expect("foo"),
  // we instantiate a new instance of the Expectation class, passing
  // it the target object, eg. "foo" in the case of expect("foo")
  AwesomeExpectations(this.target);

  toBeAwesome() {
    Expect.isTrue(target.isAwesome);
  }
}
```

Now that you have your class, we need to tell Expectations to return a `new AwesomeExpectations(target)` whenever
`expect()` is called, instead of returning the default ([CoreExpectations][]).

```actionscript
Expectations.onExpect((target) => new AwesomeExpectations(target));
```

That's it!  Now, whenever `expect()` is called, we will call the closure that you passed to onExpect,
passing it the target object so you can instantiate a `new AwesomeExpectations(target)` and we'll return
that from `expect()`.

Now you can call `expect("foo").toBeAwesome()`.

Okay, but now what happens when you try to call `expect("foo").equals("bar")`?

Your `AwesomeExpectations` class doesn't have an `equals` function, so it'll blow up with a `NoSuchMethodException`!

### Extending CoreExpectations

Let's say that you want to add a new `toBeAwesome` expectation method, but you still want to be able to use
all of the default expectations, eg. `equals`, `isNull`, etc.

The easiest say to do this is to simply make your custom expectation class `extend CoreExpectations`, which
is where all of our default expectations are defined.

```actionscript
// If your class extends CoreExpectations, you'll get all of our
// default expectations.  Note: you can also extend ToBeExpectations.
class AwesomeExpectations extends CoreExpectations {

  // CoreExpectations already has a target field so you
  // can simply call the parent constructor.
  AwesomeExpectations(var target) : super(target);

  // Add you own expectations
  toBeAwesome(){ Expect(target.isAwesome).isTrue }

  // Or even override the defaults!
  equals(value, [String reason = null]) {
    // my awesome implementation
  }
}
```

That's great, but let's say that we want to make a couple of different classes, each providing
expectations for a specific class, eg. `DogExpectations` and `CatExpectations`, because the
`Dog` and `Cat` classes are business objects that we work with a lot.

The closure that you pass to `Expectations.onExpect` can return null to "opt-out" of returning
an instance of your Expectation class.

```actionscript
// Register our Expectation classes
Expectations.onExpect((target) => (target is Dog) ? DogExpectations : null);
Expectations.onExpect((target) => (target is Cat) ? CatExpectations : null);

// This works because "foo" isn't a Dog/Cat so we'll get CoreExpectations as usual
expect("foo").equals(5);

// This works because we're passing a Dog so we'll get a DogExpectations
// (assuming DogExpectations implements the 'isBreed' method)
expect(rover).isBreed("Golden Retriever");

// This will work *if* your DogExpectations class extends CoreExpectations
// or if your DogExpectations has its own 'identical' method
expect(rover).identical(rex);
```

That's really all there is to it.

## License

Expectations is released under the [MIT license][mit].

[latest]:           https://raw.github.com/remi/expectations.dart/master/pkg/expectations.dart
[web]:              http://remi.github.com/expectations.dart
[Dart]:             http://www.dartlang.org/
[Expect]:           http://www.dartlang.org/docs/api/Expect.html#Expect::Expect
[unittest]:         http://code.google.com/p/dart/source/browse/trunk/dart/client/testing/unittest/unittest.dart
[unittest_expect]:  http://code.google.com/p/dart/source/browse/trunk/dart/client/testing/unittest/shared.dart?r=1334#41
[CoreExpectations]: http://remi.github.com/expectations.dart/CoreExpectations.html#CoreExpectations::CoreExpectations
[ToBeExpectations]: http://remi.github.com/expectations.dart/ToBeExpectations.html#ToBeExpectations::ToBeExpectations
[Jasmine]:          http://pivotal.github.com/jasmine/
[mit]:              http://www.opensource.org/licenses/mit-license.php

extension: markdown

gha_language: Dart


text:
# AWS Example

This examples shows how to deploy Kubernetes cluster on AWS using Terraform.

To run, set up your AWS provider credentials and subnet ID. Configure MetaKube host address. Create a project in Metakube UI and create an api account and a token. Set [token value](https://registry.terraform.io/providers/syseleven/metakube/latest/docs#token).

Running the example

run `terraform init .` and then `terraform apply` to see it work.

repository: syseleven/terraform-provider-metakube

gha_language: Go

repo_name: syseleven/terraform-provider-metakube


text:
**The Visual Studio Code extension provided by DeepCode.ai finds bugs and critical vulnerabilities in your code. We support Java, C/C++, Python, JavaScript, TypeScript and XML.**

# Table of Contents

1. [DeepCode extension - what is it?](#deepcode-extension)
2. [Installation](#installation)
   1. [Video on how to install the extension](#video-on-how-to-install-the-extension)
   2. [Tips on the installation process](#tips-on-the-installation-process)
3. [How to use it?](#how-to-use-it)
   1. [PROTIP: DeepCode analysis on Save](#protip---deepcode-analysis-on-save)
   2. [Video on how to use the extension](#video-on-how-to-use-the-extension)
   3. [DeepCode in action](#deepcode-in-action)
   4. [How to ignore suggestions (text)](#how-to-ignore-suggestions-text)
   5. [How to ignore suggestions (video)](#how-to-ignore-suggestions-video)
   6. [.dcignore file](#dcignore-file)
4. [Feedback and contact](#feedback-and-contact)

# DeepCode extension

Through the extension you can quickly start using DeepCode's code review and analysis within your development workflow. The extension will automatically alert you about critical vulnerabilities you need to solve in your code the moment when you hit Save in your IDE. With DeepCode's superior code review you save time finding and fixing bugs before they go to production.

## DeepCode's AI Engine finds bugs

DeepCode uses symbolic AI to process hundreds of millions of commits in open source software projects and learns how to find serious coding issues. Because the platform determines the intent of the code — and not only the syntax mistakes — DeepCode identifies 10x more critical bugs and security vulnerabilities than other tools.

## Our AI provides explanation behind found bugs

In order to show detailed explanation why something was flagged as bug we introduced a new AI technique called Ontology. With Ontology, we’ve integrated the capability to present logical conclusions within the DeepCode engine.

## Supported languages

Java, C/C++, JavaScript, Python, TypeScript and XML are currently supported.

# Installation

## Video on how to install the extension

- We've prepared a short video on how to install the extension. Head over to youtube to quickly get the extension up and running:

## Tips on the installation process

- select **"Cloud"** when you want to use your (cloud) Github, BitBucket or Gitlab account.
- select **"Self-managed"** when the organization you are part of has a DeepCode Server installation. The DeepCode service is likely running in combination with self-managed BitBucket or Gitlab.

# How to use it?

## PROTIP - DeepCode analysis on Save

- DeepCode's extension runs automatically when you hit Save (or the keyboard shortcut).
- If you don't like to save while working we strongly recommend to [enable the AutoSave](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save).

## Video on how to use the extension

- Here is a video on how to use the extension. In short - don't forget to save and you would be in good hands:

## DeepCode in action

- Here is how it looks like when inspecting all issues using the "Problems" tab and syntax highlight:

![deepcode problem](images/problem.png)

## How to ignore suggestions (text)

There are two key steps here:

   1. Ignore particular alert directly within its suggestions tooltip or 'bulb' menu:

   ![deepcode ignore menu](images/ignore_menu.png)

   2. Deepcode will create a comment, that will inform our analysis engine to ignore it. Don't forget to specify a description why you think it needs to be ignored. Your feedback will improve our engine over time:

   ![deepcode ignore comment](images/ignore_comment.png)

## How to ignore suggestions (video)

- If the above information is not enough and want to see it in action, here is a video:

## .dcignore file

- If you want to ignore certain files/folders (like node_modules for example), create a .dcignore file. You can create it in any folder on any level starting from the directory where your project resides. The file syntax is identical to .gitignore:

![deepcode dcignore](images/ignore_file.png)

# Feedback and contact

- In case you need to contact us or provide feedback, we would love to hear from you - [here is how to get in touch with us](https://www.deepcode.ai/feedback).
- If you need to update this file, you can do so by [editing this README.md](https://github.com/DeepCodeAI/vscode-extension/edit/master/README.md).


text:
sbt-settings
=========

SBT plugin providing standard functions and configurations

### Sbt 1.x

Since major version 4, this plugin is cross compiled for sbt 1.x (specifically 1.3.4).

| Sbt version | Plugin version |
| ----------- | -------------- |
| `0.13.x`    | `any`          |
| `>= 1.x`    | `>= 4.x`       |

## License ##

This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").

repository: hmrc/sbt-settings

gha_language: Scala

repo_name: hmrc/sbt-settings


text:
## Usage

Download amazon-employee-access-challenge.zip from https://www.kaggle.com/c/amazon-employee-access-challenge

```
$ unzip amazon-employee-access-challenge.zip
```


text:
This project allows for translation between `grep` style regex strings
and the regular expression data type utilized by
[15-150](https://cs.cmu.edu/~15150).

# Syntax #

Any single character, e.g., `a` will match that character. To match a
literal version of a meta-character escape it with backslash, e.g., `\*`
will match the character `*`. Adjacent characters are treated as the
concatenation of those characters.

Characters can be grouped for other commands with parentheses (`(`, `)`).

Any atom (either a single character or characters grouped by
parentheses) followed by a `*` will be matched 0 or more times.

Two atoms can be alternatively matched with `|`. For instance `a|b`
would match either `a` or `b`.

## Examples ##

- `a` will match the single character `a`
- `a|b` will match either the single character `a` or the single
character `b`
- `a*` will match a 0 or more times
- `abc` will match the string `abc`
- `(ab)*c` will match `ab` 0 or more times followed by `c`
- `a|b*` will match either:
    - `a`; or,
    - `b` 0 or more times

# License #

[MIT](LICENSE)

# Authors #

Code for parsing regular expression in string format into the internal
datatype was written by Cooper Pierce and James Gallicchio.

Code which utilizes `Regex.t` values to match and accept regex was
written by 15-150 course staff, including Michael Erdmann and Frank
Pfenning

repository: kopecs/sml-regex-builder

repo_name: kopecs/sml-regex-builder


text:
---
title: Overview
page_title: Client-side Events Overview - RadXmlHttpPanel
description: Check our Web Forms article about Overview.
slug: xmlhttppanel/client-side-programming/events/overview
tags: overview
published: True
position: 0
---

# Client-side Events Overview

**RadXmlHttpPanel** offers a set of client-side events that let the developer apply the needed logic through the control's [Client-side API]({%slug xmlhttppanel/client-side-programming/xmlhttppanel-object%}):

* **[OnClientResponseEnding]({%slug xmlhttppanel/client-side-programming/events/onclientresponseending%})**—occurs before the data (content) is pasted into the RadXmlHttpPanel.

* **[OnClientResponseEnded]({%slug xmlhttppanel/client-side-programming/events/onclientresponseended%})**—occurs immediately after the data (content) is pasted into the RadXmlHttpPanel.

* **[OnClientResponseError]({%slug xmlhttppanel/client-side-programming/events/onclientresponseerror%})**—occurs in the cases when an error (WebService or Callback error) occurs when the RadXmlHttpPanel tries to load certain content.

# See Also

 * [Overview]({%slug xmlhttppanel/client-side-programming/overview%})

repository: telerik/ajax-docs

gha_language: C#

repo_name: telerik/ajax-docs


text:
# Esports API

A public API getting you the latest results in Esports.

## Structure
- Ubuntu 14.04
- PHP 5
- MongoDB
- Phalcon 3
- apidoc

## Supported Game's
- Counter Strike :: Global Offensive
- Overwatch
- Call of Duty
- League of Legends
- Heroes of the Storm
- Dota 2

## Usage
Then open up your favorite browser and go to https://esports.glenndehaan.com/

Here you will find the API docs to use the API.
That's it. Easy right?

## PWA
I also create this awesome PWA with this API:

![Image of Esports PWA](https://user-images.githubusercontent.com/7496187/27261192-2a8df0ea-543e-11e7-85b9-9cd67d859e68.png)

Check it out here:
https://github.com/glenndehaan/esports-pwa

## License

MIT


text:
# Changelog
All notable changes to runtime_typecheck will be documented in this file.

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

## [0.7] 2017-09-22
### Added
- Detection of unknown parameters passed to the decorated function

## [0.6] 2017-09-22
### Added
- Detection of missing mandatory parameters


text:
So, it was quite simple to bringing in interactive mapview from google map API into openframeworks but it seems to be a bit slow to load in image but good for Leap Motion interactivity.

```

void testApp::update(){
    string str_latitude = ofToString( latitude - mouseY * 0.00001 );
    string str_longitude = ofToString( longitude - mouseX * 0.00001 );
    string imgPath = "http://maps.googleapis.com/maps/api/staticmap?center="
    + str_latitude
    + ","
    + str_longitude
    + "&zoom=14&size=400x400&sensor=false";
    gMapView.loadImage(imgPath);
}

```

repository: fkkcloud/ColorOfWorld

repo_name: fkkcloud/ColorOfWorld


text:
Overview
========

What is Donations? Donations is an HTTP "resty" API for managing donations of items in games.

Donations allows your app to focus on the interaction required to donating items and keeping players engaged, instead of the backend required for actually doing it.

## Features

* **Multi-tenant** - Donations already works for as many games as you need, just keep adding new games;
* **Item Donation Management** - Donate items to other players and request items from them in return;
* **New Relic Support** - Natively support new relic with segments in each API route for easy detection of bottlenecks;
* **Easy to deploy** - Donations comes with containers already exported to docker hub for every single of our successful builds. Just pick your choice!

## Architecture

Donations is based on the premise that you have a backend server for your game. That means we do not employ any means of authentication.

There's no validation if the actions you are performing are valid as well. We have TONS of validation around the operations themselves being valid.

What we don't have are validations that test whether the source of the request can perform the request (remember the authentication bit?).

## The Stack

For the devs out there, our code is in Go, but more specifically:

* Web Framework - [Echo](https://github.com/labstack/echo) based on the insanely fast [FastHTTP](https://github.com/valyala/fasthttp);
* Database - MongoDB;
* Locks - Redis.

## Who's Using it

Well, right now, only us at TFG Co, are using it, but it would be great to get a community around the project. Hope to hear from you guys soon!

## How To Contribute?

Just the usual: Fork, Hack, Pull Request. Rinse and Repeat. Also don't forget to include tests and docs (we are very fond of both).

repository: topfreegames/donations

repo_name: topfreegames/donations


text:
# `createReducer(initialState: any, actionHandlers: Object)`
The `createReducer` function can be used to reduce boilerplate code in your application.

The function signature is pretty easy, the first argument is an object containing keys which match the `actionType` you want to handle, the value is the `actionHandler` function that will be called with the actions `payload` and a second argument which is the current state.

The `actionHandler` function supports currying, we recommend the usage of a library such as [plow-js](https://grebaldi.gitbooks.io/plow-js/) to fully take advantage of this feature.

> TL;DR Writing a redux reducer has never been easier!

#### Example usage
```js
import {$set} from 'plow-js';
import {createReducer} from 'redux-lumbergh';

const initialState = {};
const actionHandlers = {
  //
  // Since plow-js supports curried functions, we can just return a setter.
  // Under the hood the returned setter function will be called with the current state as the first and only argument.
  //
	'myActionType': payload => $set(['foo'], payload.value)
};
const reducer = createReducer(initialState, actionHandlers);
```

The finalized `reducer` can now be passed to either the `createStore` or `combineReducer` function of redux.

repository: ImmoweltGroup/redux-lumbergh

repo_name: ImmoweltGroup/redux-lumbergh


text:
# Description

This is a serverless slack bot that can be used by teams to place work from home events on a google calendar via emoji reactions to a daily prompt.

# Usage

Once the bot is deployed, it will post a message to the specified slack channel every morning at the specified time. To add an event to the designated "work from home" calendar, you can reply to the message with a "house" emoji. Deleting the emoji will also remove the event from the calendar. The event details posted to the calendar will be the slack user's "first_name" parameter with " WFH" appended to it. If the first name is an empty string, the "name" parameter will be used as a backup. Reaction adds/removals to previous day's "work from home" messages will have no effect on the current day's calendar events.

# Dependencies

- [Docker](https://docs.docker.com/v17.12/install/)
- [node 10.16.3](https://nodejs.org/en/download/)
- [npm^6](https://docs.npmjs.com/about-npm-versions#the-latest-release-of-npm)
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)

# Setup

1) Download node dependencies
  - ```npm run install-all-node-modules```  <- A common paradigm of serverless applications is to have separate node_modules in each lambda, as well as in each layer, and your test directory or top level directory for local development. This command installs node_modules in each directory as necessary.

  - ```npm i -g serverless```

## Setting up google calendar & authentication

3) Create a google calendar to be accessed by your slack bot. Navigate to the calendar's settings and copy the calendar Id into the serverless.env.yml and serverless.test-env.yml files under WFH_GCAL_ID.

4) Configure google authentication information
  - visit this [link](https://developers.google.com/calendar/quickstart/nodejs) and click "enable google calendar"

  - click "Download Client Configuration"

  - Once you download the credentials.json, copy the Client ID, secret, and projectId/quickstartId into both the serverless.env.yml and serverless.env-test.yml files (an automated script for that part would be hepful)

  - then, run ```npm run generate-google-token``` and go to the link provided. Enter the code from the link into the command prompt.

## Setting up the slack bot via Slack App
5) Go to the [slack apps home page](https://api.slack.com/apps) and click "create app"
6) Once your app ha been created, navigate to "bot users" and click "add a bot user"
7)  Navigate to "OAuth & permissions", scroll down to "scopes" and add the following permissions:
  - reactions:read
  - users:read
  - chat:write:bot
8) Naviagate up to "install app in workspace" to install the app in your workspace, which will give your bot user an API token.
9) copy the "Bot User OAuth Access Token" to your serverless.env.yml & serverless.test-env.yml files.
10) **This takes place after deployment**
- After deployment you must subscribe your work-from-home listener lambda to reaction events via your slack app.
- [Head back to your slack app](https://api.slack.com/apps) and navigate to event subscriptions.
- Subscribe to reaction events, and past the url of your work-from-home listener post endpoint in the provided form. This will send a "challenge" post to the lambda, which will respond back with the challenge parameter.

## Setting up Environment Files
- The "create-env-file" will create each environment file for you, and will query slack for your slack bot and slack channel IDs by name, and in the case of your test file it will query for your test user's first name and id as well.
- You should use a different serverless.env file for each environment: local, test, dev, staging, prod.
- The "create-env-file" script will ask you for each variable as necessary, and generate the file at the path specified by the "-p" flag.
- To generate your local development serverless.env file, run ```npm run create-env-file -- -p serverless.env-local.yml```
- Alternatively you can copy the serverless.env.example.yml and manually fill out the variables. If you choose to do this you will need to determine the slack IDs of your slack channel, bot user, and test user, which requires some querying. Slack provides some useful interfaces for this: https://api.slack.com/methods/users.list/test https://api.slack.com/methods/channels.list/test

## Local development:

1) local dynamodb:
  - ```docker run -p 8000:8000 amazon/dynamodb-local```
  - ```npm run generate-tables```
2) Locally running the api:
  - ```sls offline -p serverless.env-local.yml```
3) invoking a function:
  -  ```sls invoke -n {function name} -p serverless.env-local.yml``` <- need to make sure this works and add more local development commands.

## Run tests
- Generate yout test serverless.env file: ``` npm run create-env-file -- -p serverless.env-test.yml``` (stage should be "LOCAL" which is the default)
- Alternatively, you can copy serverless.env-test.example.yml and manually fill out the variables.
- then run ```npm test```
- If all pass, you're good to proceed to deployment

# Deployment
- Generate your respective dev/staging/prod environment files with ```npm run create-env-file -- -p {filename}```
- deploy dev: ```sls deploy -p serverless.env-dev.yml```
- deploy staging: ```sls deploy -p serverless.env-staging.yml```
- deploy production: ```sls deploy -p serverless.env-prod.yml```

## AWS Roles and permissions for deployment
- If you don't have an AWS account, [set one up](https://aws.amazon.com/)
- Deploying this serverless application requires several permissions, including, but not necessarily limited to:
  - iam:CreateRole
  - iam:GetRole
  - iam:AttachRolePolicy
  - iam:AddRoleToInstanceProfile
  - cloudformation:CreateStack
  - cloudformation:DescribeStacks
  - cloudformation:DescribeStackEvents
  - cloudformation:DescribeStackResource
  - cloudformation:ValidateTemplate
  - cloudformation:UpdateStack
  - cloudformation:ListStacks
  - dynamodb:CreateTable
  - dynamodb:DeleteTable
  - lambda:UpdateFunctionCode
  - lambda:UpdateFunctionConfig
  - lambda:GetFunctionConfiguration
  - lambda:AddPermission
  - s3:DeleteObject
  - s3:GetObject
  - s3:ListBucket
  - s3:PutObject

# Testing

- Before you can test slack integrations, you must
1) have your slack bot set up and
2) Create a severless.env-test.yml env file in the test directory with a slack user's email, first name, and slack ID.

- Before you can test google calendar integration, you must
1) have your google calendar ID and
2) have your google authentication set up and inserted into the serverless.env-test.yml

## Test Commands
- All tests: ```npm test```
- Unit tests: ```npm run test-unit```
- AWS controller unit test: ```npm run test-aws```
- Integration tests: ```npm run test-integration```
- Calendar integration tests: ```npm run test-calendar```
- Slack integration tests: ```npm run test-slack```
- Handler integration tests: ```npm run test-handlers```
- Controller integration tests: ```npm run test-controllers```

# Caveats
1) The bot will invite users to work-from-home events based on their slack emails.
2) The google user authenticated for the wfh bot should have write access to the calendar in question
3) All users that could potentially be invited to a work from home event on the work from home calendar should have read access on that calendar as well.
4) When posting work-from-home events, the bot will use the first name of the user, but if that does not exist it will default to "real_name".

# TODO

1) Deployment currently adds some files from the top level directory into each lambda. only the handler functions should be deployed to each lambda.
2) Race condition between adding/removing a reaction. Adding a reaction and then deleting it fires off two different instances of the listener lambda. This leaves the potential for the deletion lambda to trigger first, and the addition lambda to be fired second, leaving the event on the calendar.
3) While there is currently some code for adding work-from-home events on a specific date, it is not ready or tested.
4) Requiring the entire AWS-sdk is cumbersome and delays lambda cold starts. The opt layer should only require specific services. Haven't gotten that to work yet.
6) Many aspects of this should be parameterized. E.g., the message posted, the emoji used for declaring a work from home event, and the time of day that the message should be posted.
7) The google credentials.json file is contructed from environment variables based on the original file downloaded from the google authentication setup. The variables in this file may drift over time if Google makes any changes to that file.
8) The "install-all-node-modules" should be replaced with lerna
9) Acceptance tests are badly needed.


text:
`core` is a loose webdev lib (all code is focussed on minimalism) to quickly write PHP-code without big frameworks or horribly complex libraries for basic stuff like SQL, input validation etc..

Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Composer
===================
Add to your project
```json
{
    "require": {
    	"mpdroog/core": "master",
    },
    "minimum-stability": "dev",

	"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mpdroog/core"
        }
    ]
}
```

php.ini
===================
Compatible php.ini (if you want to bump security up big time)
```
[PHP]
; Security
; =========
; Limit allowed directory
open_basedir = /path/to/project

; Limit the allowed functions
; 1) No shell executes
; 2) No ini parsing/source show or rot13 (used by hackkits)
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source,str_rot13,dl,ini_set,php_ini_loaded_file,php_ini_scanned_files,zend_version,gc_disable,phpinfo,phpversion,putenv,php_uname,php_logo_guid,get_current_user,get_loaded_extensions,phpversion,ord,mail

; Hide PHP-details
expose_php = Off

; No file uploads
file_uploads=Off

; Report ALL errors
error_reporting = E_ALL

; UTF-8 encoding
default_charset = "UTF-8"
; Block URL calls with fopen
allow_url_fopen = Off

[Date]
; Set timezone
date.timezone = UTC

[Session]
; Don't allow session_id overrides
session.use_strict_mode = 1
; Session-cookie name
session.name = sess
; JS cannot read session
session.cookie_httponly = On
; https only
session.cookie_secure = On
```

repository: JvGinkel/core

repo_name: JvGinkel/core


text:
---
crosspost: true
layout: post
title: Securing your Google service account key in builds
date: 2017-10-05T22:00:00.000Z
image: /images/securing-your-google-service-account-key-in-builds/padlock-597495_1920.jpg
author: azabost
tags:
  - android
  - build
hidden: false
comments: true
published: true
language: en
---
Establishing a reliable continuous delivery and deployment process is often very important as it might greatly reduce the length of time needed for the validation and verification of the software product. This is also true for Android projects, especially the ones aimed at short time to market.

For me, one of the most crucial time savers is the [gradle-play-publisher](https://github.com/Triple-T/gradle-play-publisher) plugin, which allows me to publish the APKs as soon as the build is finished. However, you need the Google service account for that.

## With great power comes great responsibility

The Google service account is an account that might be used by your applications to access all the Google APIs, including the ones for Google Play publishing ([Publishing API](https://developers.google.com/android-publisher/#publishing)). This API allows for example to:

* publish the APK (obviously)
* update the app listing (title, descriptions, images, videos, recent changes)
* change contact information (e-mail, phone number, website)

While granting this account the [required permissions](https://github.com/Triple-T/gradle-play-publisher#google-play-service-account), you cannot choose which particular apps it can access - it's either all or nothing. So if you have more than one application on your Google developer account, the service account will be able to reach them all.

Bearing this in mind, you should always protect the service account from abuse. The [documentation](https://developers.google.com/android-publisher/api_usage) also does warn you:

> We recommend not giving third parties access to any service accounts you may create. We especially recommend not giving access to any private keys for your service account. Doing so provides anonymous access to your account that can be shared with anyone.

![Padlock](/images/securing-your-google-service-account-key-in-builds/padlock-597495_1920.jpg)

## Automatic build deployment

If you are going to use the Publishing API in your builds, you definitely should take the appropriate measures to keep the service account key secure. Depending on your company policies (e.g. repositories access), the size of your team, your customer needs and policies, you might consider:

* not storing the key in the repository
* storing the key in a password-protected archive in the repository
* storing the key in a separate repository
* not storing the key at all (wait, what? see the example below)
* ... etc.

## Example

So how you can *not store the key at all*? Well, I have lied a bit. You must store it somewhere, but this example will show you how to store it as a secret value on a build server instead of a repository. This way you don't have to protect the repository itself, but the build server instead. Is it easier? It depends. But it's just one of the methods you can choose.

### Setting a secret value

Most of the automation servers like Jenkins or TeamCity have the ability to store a secret value, which you can use during the build. Whether it is really secure depends on the particular software you use, the build script (which may be printing the secret value to the build logs for example) and the access you give other people to the infrastructure and build configuration.

In this example, the secret value is stored on a TeamCity server and it will be available to the build in an environment variable.

![TeamCity secret value](/images/securing-your-google-service-account-key-in-builds/tc_secret_value.png)

### Reading the key in a build

There are plenty of ways you can read the environment variable during the build. This example uses a Gradle task to generate a file containing the key needed by the `gradle-play-publisher` plugin before the publication.

```groovy
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'

class GenerateGooglePlayDeploymentJsonFile extends DefaultTask {
    File jsonFile

    @TaskAction
    def generate() {
        def envVar = "GOOGLE_API_JSON"
        def json = System.getenv(envVar)
        if (json) {
            jsonFile.write(json)
        } else {
            logger.log(LogLevel.ERROR, "You must use $envVar for Google Play publishing")
        }
    }
}

android {

    final googlePlayDeploymentJsonFile = new File("google_play_api.json")

    task generateGooglePlayDeploymentJsonFile(type: GenerateGooglePlayDeploymentJsonFile) {
        jsonFile = googlePlayDeploymentJsonFile
    }

    playAccountConfigs {
        defaultAccountConfig {
            jsonFile = googlePlayDeploymentJsonFile
        }
    }
    play {
        track = 'beta'
    }
    defaultConfig {
        playAccountConfig = playAccountConfigs.defaultAccountConfig
        // other config ...
    }
    buildTypes {
        release {
            // config ...
        }
        debug {
            // config ...
        }
    }
    productFlavors {
        prod {
            // config ...
        }
        dev {
            // config ...
        }
    }
    project.afterEvaluate {
        project.tasks.findAll {
            it.name.startsWith("generate") && it.name.endsWith("PlayResources")
        }.forEach({
            logger.log(LogLevel.WARN, "Configuring Google Play deployment JSON file for task: $it")
            it.dependsOn generateGooglePlayDeploymentJsonFile
        })
    }
    // other config ...
}
```

The way it works is pretty straightforward:

1. Find some tasks generated by the publishing plugin.

   * The generated tasks names consist of the names of your release build variants. In this example there are: `devRelease` and `prodRelease`, which produce (among the others): `generateDevReleasePlayResources` and `generateProdReleasePlayResources`.
2. Make the generated tasks depend on the `generateGooglePlayDeploymentJsonFile` task, which expects the Google service account key (in JSON format) in the environment variable and saves it to a specified file.
3. Configure the publishing plugin to use the generated file.

Of course this simple script might be further improved and I encourage you to do it on your own.

### Publishing the app

The Gradle tasks used for the publication in this example are: `publishApkDevRelease` and `publishApkProdRelease`. Publishing the APKs with them is as simple as running these tasks like this:

```bash
gradle publishApkProdRelease
```

And you can see in the logs that it works:

```text
[10:59:52][Step 1/1] Configuring Google Play deployment JSON file for task: task ':app:generateDevReleasePlayResources'
[10:59:52][Step 1/1] Configuring Google Play deployment JSON file for task: task ':app:generateProdReleasePlayResources'
...
[11:00:50][Step 1/1] :app:assembleProdRelease
[11:00:50][Step 1/1] :app:generateGooglePlayDeploymentJsonFile
[11:00:50][Step 1/1] :app:generateProdReleasePlayResources
[11:00:58][Step 1/1] :app:publishApkProdRelease
```

### Throw the key away

Now, having this process configured, you can safely delete the Google service account key file, so no one will ever abuse it (unless they somehow read it from the build server, which is your only worry now). In case your server dies and you lose the key, you can just invalidate it and generate another one in the [Google APIs Console](https://console.developers.google.com).

## Summary

Protecting the service account key may be challenging, but it's very important and worth considering. You should assess the options you have, their pros and cons, the risks and profits. Keep in mind that any level of protection is better than no protection at all.

repository: bright/new-www

branch_name: refs/heads/gatsby

gha_language: TypeScript

repo_name: bright/new-www


text:
# Simple Multi-User TCP/IP Client/Server Example (Depreciated!)
## Requires
- Visual Studio 2010
## License
- Apache License, Version 2.0
## Technologies
- Obsolete
## Topics
- TCP/IP Client/Server
## Updated
- 03/22/2015
## Description

Update 3/22/2015

This sample is now obsolete.

For the current client/server sample, please see this link:

https://code.msdn.microsoft.com/Simple-Multi-User-TCPIP-1ff0da41

For a detailed explaination of the solution's code, please see the Technet Wiki article:

Simple Multi-User TCP/IP Client & Server using TAP

Update 10/25/2013

The sample has been updated to use a concurrent queue within the server.  The previous example lacked thread synchronization when emptying the data queue and this could cause problems in some scenarios.

Introduction

This sample provides an example of a simple pair of client and server programs which communicate with each other over TCP/IP.  The example uses
Async methods to connect and read data, and a Task
object to monitor client connections on the server.

While the sample does not attempt to implement any kind of data transmission protocol, it does include comments to indicate places where the code might be changed substantially in support of a custom protocol.

Building the Sample

The sample solution is configured to run one instance each of the client and server projects when clicking the Run button in Visual Studio.  Once debugging has begun, you can return to the
Solution Explorer, right click the ClientExample project, and select
Debug -> Start New Instance in order to start additional client instances and test multiple users.

Description

This example shows a simple communication stream between a client and a server over TCP/IP.  The server program also demonstrates a simple multi-threaded connection monitoring routine.

The example programs do not attempt to implement a data transmission protocol.  All messages are read in 64 byte chunks and the server does not attempt to relate multi-part messages from clients.  However, comments in the code indicate the places
 where changes would be made to accomodate multi-part messages and/or alternate message frame size schemes.

A client/server application is a two-part problem: first you must define the raw data transmission methodology for the programs, and second you must then implement a data transmission protocol to control the flow of the raw data and make it meaningful to
 the applications.  This sample only attempts to deal with the first part of the problem; transmitting the raw data.

Source Code Files

ServerForm.vb - contains the ServerForm class, MonitorInfo class, and ConnectionInfo class

ClientForm.vb - contains the ClientForm class and ConnectionInfo class

More Information

This sample was the result of a discussion on the MSDN Forums at:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/602d926e-a09c-4c95-9af4-61833a1afcab

url: https://raw.githubusercontent.com/ZhuangyingXu/msdn-code-gallery-community-s-z/1b488d4ccff2d0bed0a1d5182d8fe5cc61e397b9/Simple Multi-User TCPIP ClientServer Example (Depreciated!)/README.md


text:
**Can’t I just learn the concepts behind boolean algebra and not memorize this?**

Sure, you can do that, but then you’ll have to constantly go through the rules to boolean algebra

while you code. If you memorize these first, it not only builds your memorization skills but also

makes these operations natural. After that, the concept of boolean algebra is easy. But do whatever works for you.

path: /27. Memorizing Logic/README.md


text:
---
layout: post
title: My first animation
---
We made animation at "Processing". How I sade before at this programm beside drawing we can make animation. At begining for me it was unclear and hard, I make a lot of mistakes. But teacher and other students help me, and explain what wronge I was doing. After that I it's seemed not so hard. For begining we made ball wich moves by mouse and moves himself. If I wasn't lazy, I have explainad you how it is workes. But realyti is cruel.
You can see animaton>>>[there](https://ulpan.github.io/Animation/) or [there](https://ulpan.github.io/Zeref/)