text:
function gooseFilter (birds) {
  var geese = ["African", "Roman Tufted", "Toulouse", "Pilgrim", "Steinbacher"];
return birds.filter(x=> !geese.includes(x))

  // return an array containing all of the strings
  //in the input array except those that match strings in geese
};

this function takes in an array of birds, has an array of geese that is compared to the array of birds.
i just learned that by using both filter() and includes() you can iterate over the birds array, and return the array
minus the geese. I find this to be a really powerful combination of methods and want to log it in this repo.

function stringy(size) {
let count = 0
let string =[]
for(i=0;i<size;i++){
count++
console.log( count/2 % 1 === 0)
 if( count/2 % 1 === 0){
string.push("0")
 }
  else{
string.push("1")
  }
}
  console.log(string.join(''))
  return string.join('')
}

The function above takes a number and returns a string of alternating "01". The most useful bit of code from this snippet is if( count/2 % 1 === 0) which is checking to see if the count divided by 2 is a float or a whole integer. Checking the type wont work, it s labeled the same, a number. So by checking the remainder the programmer can determine if the number is a float or a whole number. This is another useful bit of knowledge to know for future reference.I'm going to see best practices for the solution above. The following code isnt considered top best practice but the code is alot shorter and i want to know how

const stringy = x => ''.padStart(x,'10');

ok so from left to right, a function using arrow function syntax takes in an integer then returns alternating 0s and 1s starting with 1 the length of the integer.Testing the shorter code actually works. but how?
whats padstart, mozilla says The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. there example

const str1 = '5';

console.log(str1.padStart(2, '0'));
// expected output: "05"
so 5.padstart(2,'0')
the 5 is padded by the 0 until total length is 2 so '05'

so
lets say input is 5
'' or empty space is  padded with 01 so what if the length is just 1
it just returns half the string or 1 in this case

I guess the lesson to take away here is that there may be a method out there that makes everything easier
also look into creating my own library of code where i can build my own methods(project idea)

function fakeBin(x){
let arr = x.split('')
return arr.map(x=>{
return parseInt(x) < 5 ? '0': '1'
}).join('')
}

The function above is my solution for taking in a string of numbers like '45385593107843568' and returning the binary value of it. any digit with a val under 5 is 0 and above it a 1. This is a function that is difficult to see how it can be refactored. There isn't an unecessary if else statement and instead a ternary statement is used. returning a new array(later joined) based on the integer value w parse int, and if lower than 5 return 0 and above a 1 so i think im proud of how this solution turned out. Let's check out the best practice for this .It's alot less code, I'll see why.
function fakeBin(x) {
    return x.split('').map(n => n < 5 ? 0 : 1).join('');
}
ok so it seems I tend to declare and assign variables unecessarily. I dont understand however why theres no parse
int to turn the elment into an integer,implicit syntax is also used
differences
------------
1.vars declared when shouldnt be
2.implicit syntax shoould be used
3.unecessary parseint is used,, in js a string number can be compared to an integer

im going to test strings and integers with comparison operators in dev tools to see the result.it works

The following solution is for a problem that wants the dev to  subtract one set of numbers from another set of numbers depending on which set of numbers has a greater value, this is problem is one that I had a clear cut solution in my head from the beginning. In pseudo code I knew
.I would need a reducer function to multiply all the values of an array together
.use this reducer on both arrays
.Have a condtional(I thought a ternary statement would be appropriate here) that compares values and subtracts the lesser num from the greater num

here's the solution I came up with, this time I'm going to review the best practices section and figure out that they did differently heres my solution

function findDifference(a, b) {
  let reducer = (acc,cv) => {
    return acc * cv
  }
  let reduceA = a.reduce(reducer)
    let reduceB = b.reduce(reducer)
    return reduceA > reduceB ? reduceA-reduceB: reduceB-reduceA
}

this was considered an easy problem in codewarss, I also want to stop solving level 8 katas and focus on level 6 katas so I can grow and think more about these problems. The code below is considered best practice

function find_difference(a, b) {
  return Math.abs(a.reduce((previous, current) => previous * current) - b.reduce((previous, current) => previous * current));
}
ok so right away i dont get Math.abs.
the mozilla definition is The Math.abs() function returns the absolute value of a number,
whats that mean
Math.abs('-1');     // 1
Math.abs(-2);       // 2
Math.abs(null);     // 0
Math.abs('');       // 0
Math.abs([]);       // 0
Math.abs([2]);      // 2
Math.abs([1,2]);    // NaN
Math.abs({});       // NaN
Math.abs('string'); // NaN
Math.abs();         // NaN
based off these examples I see that it takes whatever value there is an makes it positive. and also isnt an arr anymore
so lets check 8-5 = 3 ok lets try reversed  5-8 = -3 the pattern is no matter which way it's subtracted its the polar opposite and Math.abs makes it postive so this removes the need to check the higher value also a reducer var isnt defined but instead used directly in the same line. Maybe I should stop declaring so many variables unless necessary. Maybe by doing so it makes everything quicker.


text:
# Multilevel Modelling - Part 2

This chapter^[This note is part of [Spatial Analysis Notes](index.html)
Multilevel Modelling -- Random Slope Model by Francisco Rowe is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.] provides an introduction to multi-level data structures and multi-level modelling.

The content of this chapter is based on:

* @Gelman_Hill_2006_book provides an excellent and intuitive explanation of multilevel modelling and data analysis in general. Read Part 2A for a really good explanation of multilevel models.

* @bristol2020 is an useful online resource on multilevel modelling and is free!

This Chapter is part of [Spatial Analysis Notes](index.html), a compilation hosted as a GitHub repository that you can access it in a few ways:

* As a [download](https://github.com/GDSL-UL/san/archive/master.zip) of a `.zip` file that contains all the materials.
* As an [html
  website](https://gdsl-ul.github.io/san/multilevel-modelling-part-2.html).
* As a [pdf
  document](https://gdsl-ul.github.io/san/spatial_analysis_notes.pdf)
* As a [GitHub repository](https://github.com/GDSL-UL/san).

## Dependencies

This chapter uses the following libraries: Ensure they are installed on your machine^[You can install package `mypackage` by running the command `install.packages("mypackage")` on the R prompt or through the `Tools --> Install Packages...` menu in RStudio.] before loading them executing the following code chunk:

```r
# Data manipulation, transformation and visualisation
library(tidyverse)
```

```
## Warning: package 'tibble' was built under R version 3.6.2
```

```r
# Nice tables
library(kableExtra)
# Simple features (a standardised way to encode vector data ie. points, lines, polygons)
library(sf)
# Spatial objects conversion
library(sp)
# Thematic maps
library(tmap)
# Colour palettes
library(RColorBrewer)
# More colour palettes
library(viridis) # nice colour schemes
# Fitting multilevel models
library(lme4)
# Tools for extracting information generated by lme4
library(merTools)
```

```
## Warning: package 'MASS' was built under R version 3.6.2
```

```r
# Exportable regression tables
library(jtools)
library(stargazer)
library(sjPlot)
```

## Data

For this chapter, we will data for Liverpool from England's 2011 Census. The original source is the [Office of National Statistics](https://www.nomisweb.co.uk/home/census2001.asp) and the dataset comprises a number of selected variables capturing demographic, health and socio-economic of the local resident population at four geographic levels: Output Area (OA), Lower Super Output Area (LSOA), Middle Super Output Area (MSOA) and Local Authority District (LAD). The variables include population counts and percentages. For a description of the variables, see the readme file in the mlm data folder.^[Read the file in R by executing `read_tsv("data/mlm/readme.txt")`]

Let us read the data:

```r
# clean workspace
rm(list=ls())
# read data
oa_shp <- st_read("data/mlm/oa.shp")
```

## Conceptual Overview

So far, we have estimated varying-intercept models; that is, when the intercept ($\beta_{0}$) is allowed to vary by group (eg. geographical area) - as shown in Fig. 1(a). The strength of the relationship between $y$ (i.e. unemployment rate) and $x$ (long-term illness) has been assumed to be the same across groups (i.e. MSOAs), as captured by the regression slope ($\beta_{1}$). Yet it can also vary by group as shown in Fig. 1(b), or we can observe group variability for both intercepts and slopes as represented in Fig. 1(c).

![Fig. 1. Linear regression model with (a) varying intercepts, (b) varying slopes, and (c) both. Source: @Gelman_Hill_2006_book p.238.](figs/ch6/fig11.1_Gelman_Hill.png)

### Exploratory Analysis: Varying Slopes

Let's then explore if there is variation in the relationship between unemployment rate and the share of population in long-term illness. We do this by selecting the 8 MSOAs containing OAs with the highest unemployment rates in Liverpool.

```r
# Sort data
oa_shp <- oa_shp %>% arrange(-unemp)
oa_shp[1:9, c("msoa_cd", "unemp")]
```

```
## Simple feature collection with 9 features and 2 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 335032 ymin: 387777 xmax: 338576.1 ymax: 395022.4
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs
##     msoa_cd     unemp                       geometry
## 1 E02001354 0.5000000 MULTIPOLYGON (((337491.2 39...
## 2 E02001369 0.4960630 MULTIPOLYGON (((335272.3 39...
## 3 E02001366 0.4461538 MULTIPOLYGON (((338198.1 39...
## 4 E02001365 0.4352941 MULTIPOLYGON (((336572.2 39...
## 5 E02001370 0.4024390 MULTIPOLYGON (((336328.3 39...
## 6 E02001390 0.3801653 MULTIPOLYGON (((335833.6 38...
## 7 E02001354 0.3750000 MULTIPOLYGON (((337403 3949...
## 8 E02001385 0.3707865 MULTIPOLYGON (((336251.6 38...
## 9 E02001368 0.3648649 MULTIPOLYGON (((335209.3 39...
```

```r
# Select MSOAs
s_t8 <- oa_shp %>% dplyr::filter(
    as.character(msoa_cd) %in% c(
      "E02001354",
      "E02001369",
      "E02001366",
      "E02001365",
      "E02001370",
      "E02001390",
      "E02001368",
      "E02001385")
    )
```
And then we generate a set of scatter plots and draw regression lines for each MSOA.

```r
ggplot(s_t8, aes(x = lt_ill, y = unemp)) +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap(~ msoa_cd, nrow = 2) +
  ylab("Unemployment rate") +
  xlab("Long-term Illness (%)") +
  theme_classic()
```

```
## `geom_smooth()` using formula 'y ~ x'
```

We can observe great variability in the relationship between unemployment rates and the percentage of population in long-term illness. A strong and positive relationship exists in MSOA `E02001366` (Tuebrook and Stoneycroft), while it is negative in MSOA `E02001370` (Everton) and neutral in MSOA `E02001390` (Princes Park & Riverside). This visual inspection suggests that accounting for differences in the way unmployment rates relate to long-term illness is important. Contextual factors may differ across MSOAs in systematic ways.

## Estimating Varying Intercept and Slopes Models

A way to capture for these group differences in the relationship between unemployment rates and long-term illness is to allow the relevant slope to vary by group (i.e. MSOA). We can do this estimating the following model:

OA-level:

$$y_{ij} = \beta_{0j} + \beta_{1j}x_{ij} + e_{ij}$$

MSOA-level:

$$\beta_{0j} = \beta_{0} + u_{0j}$$
$$\beta_{1j} = \beta_{1} + u_{1j} $$
Replacing the first equation into the second generates:

$$y_{ij} = (\beta_{0} + u_{0j}) + (\beta_{1} + u_{1j})x_{ij} + e_{ij}$$
where, as in the previous Chapter, $y$ the proportion of unemployed population in OA $i$ within MSOA $j$; $\beta_{0}$ is the fixed intercept (averaging over all MSOAs); $u_{0j}$ represents the MSOA-level residuals, or *random effects*, of the intercept; $e_{ij}$ is the individual-level residuals; and, $x_{ij}$ represents the percentage of long-term illness population. *But* now we have a varying slope represented by $\beta_{1}$ and $u_{1j}$: $\beta_{1}$ is estimated average slope - fixed part of the model; and, $u_{1j}$ is the estimated group-level errors of the slope.

To estimate such model, we add `lt_ill` in the bracket with a `+` sign between `1` and `|` i.e. `(1 + lt_ill | msoa_cd)`.

```r
# attach df
attach(oa_shp)

# change to proportion
oa_shp$lt_ill <- lt_ill/100

# specify a model equation
eq6 <- unemp ~ lt_ill + (1 + lt_ill | msoa_cd)
model6 <- lmer(eq6, data = oa_shp)

# estimates
summary(model6)
```

```
## Linear mixed model fit by REML ['lmerMod']
## Formula: unemp ~ lt_ill + (1 + lt_ill | msoa_cd)
##    Data: oa_shp
##
## REML criterion at convergence: -4762.8
##
## Scaled residuals:
##     Min      1Q  Median      3Q     Max
## -3.6639 -0.5744 -0.0873  0.4565  5.4876
##
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr
##  msoa_cd  (Intercept) 0.003428 0.05855
##           lt_ill      0.029427 0.17154  -0.73
##  Residual             0.002474 0.04974
## Number of obs: 1584, groups:  msoa_cd, 61
##
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept) 0.047650   0.008634   5.519
## lt_ill      0.301259   0.028163  10.697
##
## Correlation of Fixed Effects:
##        (Intr)
## lt_ill -0.786
```

In this model, the estimated standard deviation of the unexplained within-MSOA variation is 0.04974, and the estimated standard deviation of the MSOA intercepts is 0.05855. But, additionally, we also have estimates of standard deviation of the MSOA slopes (0.17154) and correlation between MSOA-level residuals for the intercept and slope (-0.73). While the former measures the extent of average deviation in the slopes across MSOAs, the latter indicates that the intercept and slope MSOA-level residuals are negatively associated; that is, MSOAs with large slopes have relatively smaller intercepts and *vice versa*. We will come back to this in Section [Interpreting Correlations Between Group-level Intercepts and Slopes].

Similarly, the correlation of fixed effects indicates a negative relationship between the intercept and slope of the average regression model; that is, as the average model intercept tends to increase, the average strength of the relationship between unemployment rate and long-term illness decreases and *vice versa*.

We then explore the estimated average coefficients (*fixed effects*):

```r
fixef(model6)
```

```
## (Intercept)      lt_ill
##  0.04764998  0.30125916
```

yields an estimated regression line in an average LSOA: $y =  0.04764998 + 0.30125916x$. The fixed intercept indicates that the average unemployment rate is 0.05 if the percentage of population with long-term illness is zero.The fixed slope indicates that the average relationship between unemployment rate and long-term illness is positive across MSOAs i.e. as the percentage of population with long-term illness increases by 1 percentage point, the unemployment rate increases by 0.3.

We look the estimated MSOA-level errors (*random effects*):

```r
ranef_m6 <- ranef(model6)
head(ranef_m6$msoa_cd, 5)
```

```
##            (Intercept)      lt_ill
## E02001347 -0.026561023  0.02717992
## E02001348  0.001690577 -0.11534207
## E02001349 -0.036084591  0.05547012
## E02001350  0.032241334 -0.14298965
## E02001351  0.086214974 -0.28130545
```
Recall these estimates indicate the extent of deviation of the MSOA-specific intercept and slope from the estimated model average captured by the fixed model component.

We can also regain the estimated intercept and slope for each county by adding the estimated MSOA-level errors to the estimated average coefficients; or by executing:

```r
#coef(model6)
```

We are normally more interested in identifying the extent of deviation and its significance. To this end, we create a caterpillar plot:

```r
# plot
plotREsim(REsim(model6))
```

These plots reveal some interesting patterns. First, only one MSOA, containing wards such as Tuebrook and Stoneycroft, Anfield & Everton, seems to have a statistically significantly different intercept, or average unemployment rate. Confidence intervals overlap zero for all other 60 MSOAs. Despite this, note that when a slope is allowed to vary by group, it generally makes sense for the intercept to also vary. Second, significant variability exists in the association between unemployment rate and long-term illness across MSOAs. Ten MSOAs display a significant positive association, while 12 exhibit a significantly negative relationship. Third, these results reveal that geographical differences in the relationship between unemployment rate and long-term illness can explain the significant differences in average unemployment rates in the varying intercept only model.

Let's try to get a better understanding of the varying relationship between unemployment rate and long-term illness by mapping the relevant MSOA-level errors.

```r
# read data
msoa_shp <- st_read("data/mlm/MSOA.shp")
```

```
## Reading layer `MSOA' from data source `/Users/Franciscorowe/Dropbox/Francisco/uol/teaching/envs453/201920/lectures/san/data/mlm/MSOA.shp' using driver `ESRI Shapefile'
## Simple feature collection with 61 features and 17 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 333086.1 ymin: 381426.3 xmax: 345636 ymax: 397980.1
## epsg (SRID):    27700
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs
```

```r
# create a dataframe for MSOA-level random effects
re_msoa_m6 <- REsim(model6) %>% filter(groupFctr == "msoa_cd") %>%
  filter(term == "lt_ill")
str(re_msoa_m6)
```

```
## 'data.frame':	61 obs. of  6 variables:
##  $ groupFctr: chr  "msoa_cd" "msoa_cd" "msoa_cd" "msoa_cd" ...
##  $ groupID  : chr  "E02001347" "E02001348" "E02001349" "E02001350" ...
##  $ term     : chr  "lt_ill" "lt_ill" "lt_ill" "lt_ill" ...
##  $ mean     : num  0.0343 -0.1078 0.0554 -0.1407 -0.2807 ...
##  $ median   : num  0.0376 -0.1093 0.054 -0.1392 -0.2797 ...
##  $ sd       : num  0.0455 0.0728 0.0835 0.0363 0.0404 ...
```

```r
# merge data
msoa_shp <- merge(x = msoa_shp, y = re_msoa_m6, by.x = "MSOA_CD", by.y = "groupID")
```

```r
# ensure geometry is valid
msoa_shp = lwgeom::st_make_valid(msoa_shp)

# create a map
legend_title = expression("MSOA-level residuals")
map_msoa = tm_shape(msoa_shp) +
  tm_fill(col = "median", title = legend_title, palette = magma(256, begin = 0, end = 1), style = "cont") +
  tm_borders(col = "white", lwd = .01)  +
  tm_compass(type = "arrow", position = c("right", "top") , size = 4) +
  tm_scale_bar(breaks = c(0,1,2), text.size = 0.5, position =  c("center", "bottom"))
map_msoa
```

The map indicates that the relationship between unemployment rate and long-term illness is tends to stronger and positive in northern MSOAs; that is, the percentage of population with long-term illness explains a greater share of the variation in unemployment rates in these locations. As expected, a greater share of population in long-term illness is associated with higher local unemployment. In contrast, the relationship between unemployment rate and long-term illness tends to operate in the reverse direction in north-east and middle-southern MSOAs. In these MSOAs, OAs tend to have a higher unemployment rate relative the share of population in long-term illness. You can confirm this examining the data for specific MSOA executing:

```r
oa_shp %>% dplyr::select(msoa_cd, ward_nm, unemp, lt_ill) %>%
    filter(as.character(msoa_cd) == "E02001370")
```

```
## Simple feature collection with 23 features and 4 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 335885 ymin: 391134.2 xmax: 337596.3 ymax: 392467
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs
## First 10 features:
##      msoa_cd                  ward_nm     unemp    lt_ill
## 1  E02001370                  Everton 0.4024390 0.2792793
## 2  E02001370 Tuebrook and Stoneycroft 0.3561644 0.3391813
## 3  E02001370                  Everton 0.3285714 0.3106383
## 4  E02001370                  Everton 0.3209877 0.3283019
## 5  E02001370                  Anfield 0.3082707 0.1785714
## 6  E02001370                  Everton 0.3000000 0.4369501
## 7  E02001370                  Everton 0.2886598 0.3657143
## 8  E02001370                  Everton 0.2727273 0.3375000
## 9  E02001370                  Everton 0.2705882 0.2534247
## 10 E02001370 Tuebrook and Stoneycroft 0.2661290 0.2941176
##                          geometry
## 1  MULTIPOLYGON (((336328.3 39...
## 2  MULTIPOLYGON (((337481.5 39...
## 3  MULTIPOLYGON (((336018.5 39...
## 4  MULTIPOLYGON (((336475.7 39...
## 5  MULTIPOLYGON (((337110.6 39...
## 6  MULTIPOLYGON (((336516.3 39...
## 7  MULTIPOLYGON (((336668.6 39...
## 8  MULTIPOLYGON (((336173.8 39...
## 9  MULTIPOLYGON (((336870 3917...
## 10 MULTIPOLYGON (((337363.8 39...
```

Now try adding a group-level predictor and an  individual-level predictor to the model. Unsure, look at the Sections [Adding Group-level Predictors] and [Adding Individual-level Predictors] in the previous Chapter.

## Interpreting Correlations Between Group-level Intercepts and Slopes

Correlations of random effects are confusing to interpret. Key for their appropriate interpretation is to recall they refer to group-level residuals i.e. deviation of intercepts and slopes from the average model intercept and slope. A strong *negative* correlation indicates that groups with high intercepts have relatively low slopes, and *vice versa*. A strong *positive* correlation indicates that groups with high intercepts have relatively high slopes, and *vice versa*. A correlation close to *zero* indicate little or no systematic between intercepts and slopes. Note that a high correlation between intercepts and slopes is not a problem, but it makes the interpretation of the estimated intercepts more challenging. For this reason, a suggestion is to center  predictors ($x's$); that is, substract their average value ($z = x - \bar{x}$). For a more detailed discussion, see @bristol2020.

To illustrate this, let's reestimate our model adding an individual-level predictor: the share of population with no educational qualification.

```r
# centering to the mean
oa_shp$z_no_qual <- no_qual/100 - mean(no_qual/100)
oa_shp$z_lt_ill <- lt_ill - mean(lt_ill)

# specify a model equation
eq7 <- unemp ~ z_lt_ill + z_no_qual + (1 + z_lt_ill | msoa_cd)
model7 <- lmer(eq7, data = oa_shp)

# estimates
summary(model7)
```

```
## Linear mixed model fit by REML ['lmerMod']
## Formula: unemp ~ z_lt_ill + z_no_qual + (1 + z_lt_ill | msoa_cd)
##    Data: oa_shp
##
## REML criterion at convergence: -4940.7
##
## Scaled residuals:
##     Min      1Q  Median      3Q     Max
## -3.6830 -0.5949 -0.0868  0.4631  6.3556
##
## Random effects:
##  Groups   Name        Variance  Std.Dev. Corr
##  msoa_cd  (Intercept) 8.200e-04 0.02864
##           z_lt_ill    2.161e-06 0.00147  -0.04
##  Residual             2.246e-03 0.04739
## Number of obs: 1584, groups:  msoa_cd, 61
##
## Fixed effects:
##               Estimate Std. Error t value
## (Intercept)  0.1163682  0.0039201   29.68
## z_lt_ill    -0.0003130  0.0003404   -0.92
## z_no_qual    0.3245811  0.0221347   14.66
##
## Correlation of Fixed Effects:
##           (Intr) z_lt_l
## z_lt_ill  -0.007
## z_no_qual -0.015 -0.679
```

How do you interpret the random effect correlation?

## Model building

Now we know how to estimate multilevel regression models in *R*. The question that remains is: *When does multilevel modeling make a difference?* The short answer is: when there is little group-level variation. When there is very little group-level variation, the multilevel modelling reduces to classical linear regression estimates *with no group indicators*. Inversely, when group-level coefficients vary greatly (compared to their standard errors of estimation), multilevel modelling reduces to classical regression *with group indicators* @Gelman_Hill_2006_book.

*How do you go about building a model?*

We generally start simple by fitting simple linear regressions and then work our way up to a full multilevel model - see @Gelman_Hill_2006_book p. 270.

*How many groups are needed?*

As an absolute minimum, more than two groups are required. With only one or two groups, a multilevel model reduces to a linear regression model.

*How many observations per group?*

Two observations per group is sufficient to fit a multilevel model.

### Model Comparison

*How we assess different candidate models?* We can use the function `anova()` and assess various statistics: The Akaike Information Criterion (AIC), the Bayesian Information Criterion (BIC), Loglik and Deviance. Generally, we look for lower scores for all these indicators. We can also refer to the *Chisq* statistic below. It tests the hypothesis of whether additional predictors improve model fit. Particularly it tests the *Null Hypothesis* whether the coefficients of the additional predictors equal 0. It does so comparing the deviance statistic and determining if changes in the deviance are statistically significant. Note that a major limitation of the deviance test is that it is for nested models i.e. a model being compared must be nested in the other. Below we compare our two models. The results indicate that adding an individual-level predictor (i.e. the share of population with no qualification) provides a model with better.

```r
anova(model6, model7)
```

```
## refitting model(s) with ML (instead of REML)
```

```
## Data: oa_shp
## Models:
## model6: unemp ~ lt_ill + (1 + lt_ill | msoa_cd)
## model7: unemp ~ z_lt_ill + z_no_qual + (1 + z_lt_ill | msoa_cd)
##        Df     AIC     BIC logLik deviance  Chisq Chi Df Pr(>Chisq)
## model6  6 -4764.7 -4732.5 2388.3  -4776.7
## model7  7 -4956.5 -4918.9 2485.2  -4970.5 193.76      1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
```

repository: anhnguyendepocen/san

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: anhnguyendepocen/san


text:
---
# Thumbwheel click

> Thumbwheel click is a mikroBUS add-on board with a 10-position rotary sprocket connected to a 1-Wire 8-Channel Addressable Switch.

[click Product page](https://www.mikroe.com/thumbwheel-click)

---

#### Click library

- **Author**        : Aleksandra Cvjeticanin
- **Date**          : Mar 2022.
- **Type**          : One Wire type

# Software Support

We provide a library for the Thumbwheel Click
as well as a demo application (example), developed using MikroElektronika
[compilers](https://www.mikroe.com/necto-studio).
The demo can run on all the main MikroElektronika [development boards](https://www.mikroe.com/development-boards).

Package can be downloaded/installed directly from *NECTO Studio Package Manager*(recommended way), downloaded from our [LibStock™](https://libstock.mikroe.com) or found on [Mikroe github account](https://github.com/MikroElektronika/mikrosdk_click_v2/tree/master/clicks).

## Library Description

> This library contains API for Thumbwheel Click driver.

#### Standard key functions :

- `thumbwheel_cfg_setup` Config Object Initialization function.
```c
void thumbwheel_cfg_setup ( thumbwheel_cfg_t *cfg );
```

- `thumbwheel_init` Initialization function.
```c
err_t thumbwheel_init ( thumbwheel_t *ctx, thumbwheel_cfg_t *cfg );
```

#### Example key functions :

- `thumbwheel_get_position` This function gets the position of the rotary sprocket.
```c
err_t thumbwheel_get_position ( thumbwheel_t *ctx, uint8_t *position );
```

## Example Description

> This example demonstrates the use of Thumbwheel click board by displaying the exact position of the rotary sprocket.

**The demo application is composed of two sections :**

### Application Init

> Initializes the driver and checks the communication.

```c

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    thumbwheel_cfg_t thumbwheel_cfg;  /**< Click config object. */

    /**
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX
     * are defined as HAL_PIN_NC, you will
     * need to define them manually for log to work.
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    thumbwheel_cfg_setup( &thumbwheel_cfg );
    THUMBWHEEL_MAP_MIKROBUS( thumbwheel_cfg, MIKROBUS_1 );
    if ( ONE_WIRE_ERROR == thumbwheel_init( &thumbwheel, &thumbwheel_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( THUMBWHEEL_ERROR == thumbwheel_check_communication ( &thumbwheel ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

```

### Application Task

> Demonstrates the usage of thumbwheel_get_position function which gives the exact position of the rotary sprocket. The position will be displayed on the UART Terminal.

```c
void application_task ( void )
{
    static uint8_t old_position = 0xFF;
    uint8_t position;

    if ( ( THUMBWHEEL_OK == thumbwheel_get_position ( &thumbwheel, &position ) ) &&
         ( old_position != position ) )
    {
        log_printf( &logger, " Position: %u \r\n\n", ( uint16_t ) position );
        old_position = position;
    }
    Delay_ms( 100 );
}
```

The full application code, and ready to use projects can be installed directly from *NECTO Studio Package Manager*(recommended way), downloaded from our [LibStock™](https://libstock.mikroe.com) or found on [Mikroe github account](https://github.com/MikroElektronika/mikrosdk_click_v2/tree/master/clicks).

**Other Mikroe Libraries used in the example:**

- MikroSDK.Board
- MikroSDK.Log
- Click.Thumbwheel

**Additional notes and informations**

Depending on the development board you are using, you may need
[USB UART click](https://www.mikroe.com/usb-uart-click),
[USB UART 2 Click](https://www.mikroe.com/usb-uart-2-click) or
[RS232 Click](https://www.mikroe.com/rs232-click) to connect to your PC, for
development systems with no UART to USB interface available on the board. UART
terminal is available in all MikroElektronika
[compilers](https://shop.mikroe.com/compilers).

---

license: MIT

gha_language: C

gha_license_id: NOASSERTION


text:
Motto is a tool that processes Flick programs:

* It compiles programs to run on a separate back-end runtime system.

* Provides a reference runtime for running Flick programs without requiring
  additional dependencies.

* Enables querying of Flick programs -- for instance, type-checking Flick
  expressions from the command-line.

**NOTE** Motto accepts several switches. At the moment most of them are
only described in the [code](https://github.com/NaaS/motto/blob/master/motto.ml).

# Building

To compile Motto:
```
$ ./build.sh
```

If compilation fails, check that you have all dependencies listed in the
"Dependencies" section below.

Try running `./motto.byte -h` to see if you have a binary. See the section on
"Testing" for how to run the tool over regression tests.

## Using Docker

If you have [Docker](http://docker.com) installed, you can also use a container
to run the compiler without installing all the dependencies.  The source code
can be mounted in `/src` within the container.

```
$ docker build -t motto .
$ docker run -v `pwd`/tests:/src motto -q --parser_test_file flick_code/types_process.cp
```

# Getting going
We start with the mathematical cousin of "Hello, world" -- i.e., the factorial
program. Look at the [factorial function in Flick](https://github.com/NaaS/motto/blob/master/tests/flick_code/factorial.cp).
To run this, we need an environment that can interpret it -- Motto provides
this. This interpreter requires a runtime, which connects it with resources on
the machine on which Flick programs are interpreted. For instance, sockets
aren't a concept that Flick provides; they are resources that the machine makes
available to the runtime, that in turn provides them to running Flick programs
as channels.

Motto provides a flexible scriptable-runtime. That is, in addition to running
Flick programs, you can programmatically control different aspects of the
runtime. This is useful, for instance, if you want to alter the contents of
channels, to make tests more repeatable and specific. Or you could simulate
phenomena that are beyond the control of Flick programs, such as channels
breaking. If you have the time, it's not difficult to turn this into an
_interactive_ runtime -- i.e., a "toplevel" or Read-Eval-Print Loop, a.k.a.,
"REPL".)

Now look at an example of the [runtime's use to run the factorial function](https://github.com/NaaS/motto/blob/master/tests/runtime/factorial.ml).
Using the scriptable runtime, you can compile and run Flick programs using the
OCaml compiler and runtime.  To compile the example:
```
$ ./build.sh factorial.byte
```
and then run!
```
$ ./factorial.byte
```

You should get the following output:
```
let y = 13 ~> 13
let z = 5 + (y * ?somechan) + y ~> 70
factorial (z - (60 + ?somechan)) ~> 40320
```
This output reproduces each expression that was evaluated by the runtime,
followed by `~>`, and followed by the value that the expression evaluated to.

Tracing the evaluation within expressions is not difficult to implement --
essentially by adding and using a hook in the [evaluation monad](https://github.com/NaaS/motto/blob/master/runtime/eval_monad.ml) -- but currently
this is not implemented.

Take a look at this [example](https://github.com/NaaS/motto/blob/master/tests/runtime/runtime_general_test.ml)
for a comprehensive example of using the scriptable runtime.

# Compiler

To compile a file named `source_file` run the following command:
```
$ ./motto.byte -o output_directory source_file
```
where `output_directory` is the name of the directory (that doesn't yet
exist) that's intended to hold the compiler's output.
The compiler will create `output_directory` and deposit the output files there,
where they can be compiled and linked using a separate toolchain.

Other than the reference runtime system, described above, only a single back-end
runtime system is supported. Thus code is generated exclusively for this
runtime.

# Testing

For testing, I'm currently using the following as `source_file`:
* `examples/hadoop_wc_type.cp`
* `tests/flick_code/simple_function.cp`

To run the parser regression tests on both the `examples` and `tests` directories:
```
$ ./motto.byte -q --parser_test_dir examples --parser_test_dir tests/flick_code
```
Or you might wish to only test a single file:
```
./motto.byte -q --parser_test_file tests/flick_code/types_process.cp
```

To run type inference on expressions:
```
$ ./motto.byte -q --infer_type "(| E |)"
```
where `E` is an expression.

To run the type checker on regression tests, see the
[test_type_checker.sh](https://github.com/NaaS/motto/blob/master/scripts/test_type_checker.sh) script.

# Background

The Flick language is a simplification of the [Crisp](https://github.com/NaaS/motto/blob/master/doc/crisp.md) language idea.

# Dependencies

Other than the OCaml compiler (tested with v4.03.0) this project has the following dependencies:
* ocamlfind. This in turn depends on:
  * m4
* menhir

# License and support

Motto is distributed under the terms of the [Apache 2.0 license](https://github.com/NaaS/motto/blob/master/LICENSE).

The Motto tool was developed as part of the [Network-as-a-Service
project](http://www.naas-project.org/) (NaaS), which was funded by
the UK's Engineering and Physical Sciences Research Council
through grants EP/K034723/1, EP/K031724/1, and EP/K032968/1.
These grants were held at the following universities respectively:
* Computer Laboratory, University of Cambridge
* School of Computer Science, University of Nottingham
* Department of Computing, Imperial College London

repository: NaaS/motto

gha_language: OCaml

repo_name: NaaS/motto


text:
# Notireader

## General info
This project aims to create a simplified auto-replying chatbot using direct reply action on notification. This feature was introduced in Android 7.0 (API level 24) and requires additional setup for versions below.

## Compatibility

Currently been tested on android 6.0.1 with Wear OS by Google installed:
```
https://play.google.com/store/apps/details?id=com.google.android.wearable.app
```
This is because android anything below 7.0 cannot use notification action without the Wear OS app.

## How to use

Currently supports KakaoTalk messenger. Notification must be turned on. By receiving any message containing "/start" will trigger the direct reply and send "Auto Reply" back to the sender.

repository: namjmnam/Notireader

branch_name: refs/heads/main

repo_name: namjmnam/Notireader


text:
## Calculator
This is a calculator that is meant to add 2 numbers.
** Authors: Naisenya, Naomi and Elvis.
## Description
The calculator aids users to quickly add two numbers and get a result from their inputs.
## Setup/Installation Requirements
The user is prompted to input their first number and second number. After this the Calculator uses an addition function to get the result and then the answer is displayed for the user.

## Known Bugs
No any known bugs.

## Technologies Used
Developed on HTML and js.
## Support and contact details
For support please contact me on<EMAIL_ADDRESS>### License
MIT License

repository: emakuthi/calculator

repo_name: emakuthi/calculator


text:
# webhook-sender [![PyPi version](https://img.shields.io/pypi/v/webhook_sender.svg)](https://pypi.python.org/pypi/webhook_sender/) [![Build Status](https://travis-ci.org/GitGuild/webhook-sender.svg?branch=MVP)](https://travis-ci.org/GitGuild/webhook-sender) [![Coverage Status](https://coveralls.io/repos/github/GitGuild/webhook-sender/badge.svg?branch=MVP)](https://coveralls.io/github/GitGuild/webhook-sender?branch=MVP)

A simple program to manage the sending of webhooks registered in an SQL database.

# Installation

This package is registered with pypi, and can be installed with pip.

`pip install webhook_sender`

Additionally, it is recommended to set the `sender.py` script up on a cron job running every minute. This manual execution is currently the only way to run the program.

# Configuration

This package expects a config file in the `.ini` format. See the `example_cfg.py` file for example values. To replace this with a production configuration file, set the `WEBHOOK_SENDER_CONFIG_FILE` environmental variable.

repository: TAPPGuild/webhook-sender

repo_name: TAPPGuild/webhook-sender


text:
# Wonton

Wonton library provides low level infrastructure for wrappers
to various unstructured mesh and data (state) managers.
A wrapper is an implementation of an interface to the native
interface of the mesh and state manager and can be used by
libraries such as Portage and Tangram without copying data
from the mesh and state manager.

The primary reason for Wonton's existence is to enable applications
to interface to the Portage and Tangram libraries. Wonton also provides
a common repository for these interface implementations as well
as common definitions and methods.

## Getting Started
To obtain a copy of wonton and its submodules from GitHub, clone
recursively:
```sh
git clone --recursive https://github.com/laristra/wonton
```

If you are familiar with Docker, take a look at
our
[Dockerfile](https://github.com/laristra/wonton/blob/master/docker/Dockerfile) for
a working build environment.  In particular, the Dockerfile builds off
of
the [wonton-buildenv](https://github.com/laristra/wonton-buildenv)
Dockerfile, and uses
our
[travis.yml](https://github.com/laristra/wonton/blob/master/.travis.yml) file
with Travis CI.

### Prerequisites
Wonton uses standard C++11 features, so a fairly modern compiler
is needed. We regularly test with Intel 18.0.1, GCC 6.4.0, and GCC 7.3.0.
The build system _requires_ CMake version 3.13+.

The following libraries are _required_:

- **__Either__** Boost (1.58.0+) **__or__** Thrust (1.8.3):
  We wrap some features of either one of these packages.  If you would
  like to run with OpenMP or TBB threads, then you _must_ use Thrust.

The following libraries are _highly recommended_:

- LAPACKE (3.8.0+)

Wonton provides wrappers for a few third-party mesh types.  Building
support for these is _optional_:

- [Jali](http://github.com/lanl/jali):

  We regularly test with version 1.1,4.  You will need to set the
  `WONTON_ENABLE_Jali` and `Jali_ROOT` CMake variable if you wish to build
  support for Jali and its tests (see examples below).

- [FleCSI Burton Specialization](http://github.com/laristra/flecsi-sp):

  The Burton specialization in the `flecsi-sp` repository is built on
  top of [FleCSI](http://github.com/laristra/flecsi).  You will need
  _both_ projects to build support for the Burton mesh specialization
  and its tests.  You will need to set `WONTON_ENABLE_FleCSI=True` and add
  the FleCSI and FleCSI-sp install paths to the `CMAKE_PREFIX_PATH`;
  see examples below.  Both FleCSI packages are under constant
  development.  This version of wonton is known to work with hash
  `bd29de5d` of the FleCSI _stable_ branch, and hash `e78c594` of the
  FleCSI-SP _stable_ branch.

The [documentation](http://wonton.lanl.gov) is built using doxygen (1.8+).

### Installing

In the simplest case where you have the appropriate versions mentioned
above and Boost and LAPACKE are in the usual locations that CMake
searches, then the build step is:

```sh
wonton $ mkdir build
wonton $ cd build
wonton/build $ cmake -DENABLE_UNIT_TESTS=True ..
wonton/build $ make
```

This compiles the serial code and about a dozen unit tests.  To
run the tests, execute

```sh
wonton/build $ ctest
```

If you wish to install the code into the `CMAKE_INSTALL_PREFIX` then
execute
```sh
wonton/build $ make install
```

To build the documentation, one would configure with the
`-DENABLE_DOXYGEN=True` flag, and then `make doxygen`.

# License

This project is licensed under a modified 3-clause BSD license - see
the [LICENSE](https://github.com/laristra/wonton/blob/master/LICENSE)
file for details.

# Release

This software has been approved for open source release and has been
assigned **LA-CC-18-019**.

----
----

# Example builds

Below we list copy & paste instructions for several local machines; we
have a script that parses this README file to execute the examples
below to ensure they build.

repository: laristra/wonton

repo_name: laristra/wonton


text:
# stenajs-webui-core

A library with common UI components for React,

### Yarn ###

All instructions are written with Yarn as package manager.
If you are using NPM, replace `yarn add` with `npm install --save` in the following instructions.

## Prerequisites

It is highly recommended that you use `create-react-app` to setup your application. This ensure that you have a proper webpack configuration.

For more information, see [https://facebook.github.io/create-react-app/]().

## Installation

```
$ yarn add stenajs-webui-core
```

This installs all dependencies, including two icon packs from Font Awesome that are used by components.
You can install more icon packs if you need them for your project. The included ones are `free-regular-svg-icons` and `free-solid-svg-icons`.
## Storybook

All components are documented in Storybook.

[https://stenait.github.io/stenajs-webui-core](https://stenait.github.io/stenajs-webui-core)

#### Run Storybook on your local machine

You can run Storybook locally by cloning the `stenajs-webui-core` repository and running:

```
yarn
yarn start
```

## Typescript

`stenajs-webui-core` is developed in Typescript, and all exported components and functions are fully typed.
It is recommended to use Typescript, as this will type-check your usage with the library.

`create-react-app` supports Typescript out of the box. Just create `.ts` and `.tsx` files in your project.
## Icons

This library uses FontAwesome 5, which adds some setup steps.

### 1) How to install

Install any other icon packs that you want to use.

For example, add `free-brands-svg-icons` like this:

```
$ yarn add @fortawesome/free-brands-svg-icons
```

The icon packs `free-regular-svg-icons` and `free-solid-svg-icons` is used by `stenajs-webui-core`.

### 2) How to use

#### a) Explicit import

```
import { fab } from '@fortawesome/free-brands-svg-icons';
import {
    faCheckSquare,
    faCoffee,
} from '@fortawesome/free-solid-svg-icons';
import {
    faCheckCircle,
    faCircle,
} from '@fortawesome/free-regular-svg-icons';

const element = <Icon name={faCheckSquare} />
const element = <Icon name={faCoffee} />
const element = <Icon name={faCheckCircle} />
const element = <Icon name={faCircle} />

```

#### b) Build a Library

Create a source file, for example `initFontAwesome.ts`

Import `library` from `@fortawesome/fontawesome-svg-core`, and use `library.add` to add any icons that you want to use in your project.

```
import { library } from '@fortawesome/fontawesome-svg-core';
import { fab } from '@fortawesome/free-brands-svg-icons';
import {
    faCheckSquare,
    faCoffee,
} from '@fortawesome/free-solid-svg-icons';
import {
    faCheckCircle,
    faCircle,
} from '@fortawesome/free-regular-svg-icons';

library.add(
    fab,
    faCheckSquare,
    faCoffee,
    faCheckCircle,
    faCircle,
);
```

Then import `initFontAwesome` in your project.

`index.tsx`
```
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { App } from './App';
import './initFontAwesome';

ReactDOM.render(<App />, document.getElementById('root');
```

For more information, see [https://fontawesome.com/how-to-use/on-the-web/using-with/react]().

repository: StenaIT/stenajs-webui-core

gha_language: TypeScript

gha_license_id: MIT

repo_name: StenaIT/stenajs-webui-core


text:
---
path: "/blog/how-to-check-abandoned-carts-in-woocommerce"
date: "2019-05-12"
datemodified: "2019-10-18"
title: "How to check abandoned carts in WooCommerce"
description: "Know how to check abandoned carts on your WooCommerce store with Retainful - a free WooCommerce abandoned cart recovery plugin. Capture abandoned carts and recover them by sending automatic cart reminder emails."
keywords: "woocommerce abandoned cart, woocommerce shopping cart abandonment, woocommerce see abandoned carts, best abandoned cart woocommerce"
author: "Siddharth"
image: "../images/how-to-check-abandoned-carts-in-woocommerce/how-to-check-abandoned-carts-in-woocommerce.png"
thumbnail: "../images/how-to-check-abandoned-carts-in-woocommerce/how-to-check-abandoned-carts-in-woocommerce.png"
category: 'woocommerce'
ogtype: blog
---

Cart abandonment is one of the bigger challenges faced by eCommerce stores. What makes it more challenging is not knowing how many carts have been abandoned. Let's learn how to find the abandoned carts and recover them in your WooCommerce store.

## What is cart abandonment?

About 70% of the shoppers abandoned their carts, according to research firm Baymard Institute. People visit your online store, browse through various product categories, add products to the cart but most of them leave the site without buying. That is called cart abandonment.
****
___

<toc>
</toc>

## Why people abandon cart?
People abandoned their carts for a variety of reasons. Understanding why customers abandon cart can put you forward in knowing how to reduce it.

Following are some of the most common reasons for people abandoning your online cart:

- Unexpected shipping cost and additional taxes or fees
- Asking to create a New user account
- People just checking your online store
- No coupons and discounts available
- No transparent privacy and return policy
- Complex payment gateway or less payment choices.

___

## How to Check Abandoned Carts in WooCommerce?

To check the carts that are being abandoned, you’ll be needing a tool that’s robust, reliable and completely yours. An App like Retainful could be doing the job.

![](https://raw.githubusercontent.com/retainful/site-images/master/how-to-check-abandoned-carts-in-woocommerce/retainful.png)

Retainful comes with power-packed features and allows you to check abandoned carts in real-time. And also the number of recovered carts and live carts in your store. There’s a whole lot of other <link-text url="https://www.retainful.com/product/features/woocommerce" rel="noopener" target="_blank">things you can do with Retainful.</link-text> For now, we’ll get to the point.,

## Steps to Check WooCommerce shopping cart abandonment

### Install & Activate Retainful

1.  <link-text url="https://wordpress.org/plugins/retainful-next-order-coupon-for-woocommerce/" rel="noopener nofollow" target="_blank">Download Retainful</link-text>

2.  Install and Active the Retainful Plugin.

![](https://raw.githubusercontent.com/retainful/site-images/master/how-to-check-abandoned-carts-in-woocommerce/retainfulDashboard.jpeg)

The installation process takes no more than two minutes.

<cta url="https://app.retainful.com/?utm_source=blog&utm_medium=try_retainful_free&utm_campaign=check_abandoned_carts_in_woocommerce" rel="noopener" target="_blank">Try Retainful For Free!</cta>

### Setting up Retainful

Once installed, you should be deciding as to when a cart should be considered as abandoned. Because you don’t want to create chaos among customers who haven’t actually abandoned their carts right? So,

-   Go to the Settings tab and scroll down to the ‘Abandoned Carts’ section. And set the time limit as to when a cart should be considered as abandoned.

-   You can also choose whether you should get a notification when a cart is recovered or not.

-   Mark duplicate carts if need be and also set the time limit as to when a cart should be marked duplicate.

-   And then, click the Save button.

![](https://raw.githubusercontent.com/retainful/site-images/master/how-to-check-abandoned-carts-in-woocommerce/abandonedCarts.png)

You’ve now set specific criteria as to when a cart should be considered abandoned.

Now, the next step,

### Checking abandoned carts with Retainful

Checking abandoned carts with Retainful is easier than said. Because Retainful offers one of the most simple and clean dashboards with stellar data.

All you have to do is,

-   Click on the “Carts” section from the Retainful menu.

-   Toggle to “Abandoned Carts” in the “Filter By” section.

![](https://raw.githubusercontent.com/retainful/site-images/master/how-to-check-abandoned-carts-in-woocommerce/dashboard.png)

-   You can find the list of abandoned cart details along with the date of abandonment, the customer’s name, and the abandoned cart’s value. Retainful automatically assigns a custom cart ID for the abandoned cart.

You can even check the number of recovered carts and the number of live carts by selecting from the different filter options that are available.

## Recover Abandoned Carts

With Retainful, it’s not just about knowing the number of carts that are abandoned. You can even recover them by sending automated abandoned cart recovery emails _(we’ve given the total abandoned cart value in the dashboard for enough motivation)._ Sending well-timed <link-text url="https://www.retainful.com/blog/how-to-write-abandoned-cart-emails-in-woocommerce" rel="noopener" target="_blank">crafted cart recovery emails</link-text> can help you recover more abandoned carts. Here’s an example

-   Send the 1st cart email 1 hour after the customer abandons the cart.

-   The second email goes 3 hours after the cart is left abandoned.

-   The third, 1 day after abandonment.

-   And the final email, 2 days after the cart is being abandoned.

You can stop sending emails anywhere in between once your cart is recovered _(with Retainful, everything is automated. You just have to set it and forget it)._ <link-text url="https://www.retainful.com/docs/woocommerce/creating-an-abandoned-cart-email-sequence" rel="noopener" target="_blank">Here’s a step by step guide to create abandoned cart recovery email reminders with Retainful.</link-text>

So, that’s pretty much about how to check abandoned carts in WooCommerce. It’s easy and quick. The clean dashboard gives you enough information about your WooCommerce that helps you make informed decisions which directly reflect on your store’s growth!

So, know what’s happening in your store and start recovering abandoned carts while it’s not too late!

repository: retainful/site

gha_language: JavaScript

repo_name: retainful/site


text:
---
title: The Output/REPL Window
description: When Calva evaluates Clojure/ClojureScript code, the results are displayed inline as well as printed to the results output window.
---

# The Output/REPL Window/File

When Calva evaluates Clojure/ClojureScript code, the results are displayed inline as well as printed to the results output window/file. This file is created and opened when Calva is connected to a REPL.

In ClojureScript projects the window will be associated with the `cljs` REPL once this one is connected. It will then look something like so:

![Output Window Connected](images/howto/output/output-window-connected.png)

The first prompt is from when the `clj` REPL is connected, the second when Calva has a `cljs` REPL connection. The first part of the prompt tells you which REPL type the window is currently connected to. This gets important when the file/window is used as an interactive REPL.

## Find the Output/REPL Window

If you quickly want to open and switch to the output window there is the command **Calva: Show Output Window**, `ctrl+alt+o o`.

To sync the Output/REPL window namespace with the current file before switching, use the **Switch Namespace of the Output/REPL Window to Current Namespace** command, `ctrl+alt+c alt+n`.

## Find the File for the Current REPL Window Namespace

When you are working from the Output/REPL window, and want to open the file that defines its current namespace, use the **Show File for the Current Output/REPL Window Namespace** command, `ctrl+alt+o o`.

!!! Note
    This also works for Clojure core and library namespaces.

## Evaluating Code

The window will be automatically associated with the REPL and the namespace of any project Clojure/ClojureScript file you evaluate code in. So for instance if you evaluate this code in a `clj` file with the namespace `fresh-reagent.handler`:

```clojure
(def mount-target
  [:div#app
   [:h2 "Welcome to fresh-reagent"]
   [:p "please wait while Figwheel is waking up ..."]
   [:p "(Check the js console for hints if nothing exciting happens.)"]])
```

The output window will print the defined var and then a new prompt reflecting the current REPL connection and namespace:

![eval-results-1](images/howto/output/eval-results-1.png)

If you then switch to the output window (`ctrl+alt+o o`), and enter this at the prompt:

```clojure
mount-target
```

then evaluate it using `alt+enter`, you'll get:

![eval-results-2](images/howto/output/eval-results-2.png)

This, since the namespace ”followed” the first evaluation over to the output window.

## REPL History

Recently evaluated forms in the REPL file are persisted and can easily be shown again for modifying and re-evaluating.

### Navigate REPL History

You can navigate up and down the last forms evaluated in the REPL file by using `alt+up` and `alt+down`, provided your cursor is at the end of the last form after the prompt. If the cursor is not at the end of the last form, then `alt+up` and `alt+down` will do what they are mapped to, which is by default "Move Line Up" and "Move Line Down," respectively.

If you have typed some text after the prompt before you start traversing up the history, this text will be preserved and will display when you traverse back down the history. If you modify some text in the history while traversing, the modification will be saved at that location in history.

### Clear REPL History

You can clear the repl history by running the command "Clear REPL History" from the command palette.

## Stack Traces

When an evaluation produces an error, the output window will automatically print the the error message. If there is a stack trace associated with the error, this can now be printed on demand using the **Calva: Print Last Stacktrace to the Output Window** command. The output window will also have a Codelense button below the error message that will print the stack trace..

![Print Stacktrace Codelense button](images/howto/output/print-stacktrace-codelense.png "Print Stacktrace Codelense button")

For printed stacktraces, when source locations are available (Clojure files) you will be able to navigate to them by pressing `ctrl+click` (`cmd+click` on Mac) on the file name. You can also hover over symbols in the stack trace to see the symbol's documentation, and `ctrl+click` (`cmd+click` on Mac) the symbol to Peek Definition.

![Stack trace clicking and peeking definition](images/howto/output/stack-traces.gif "Stack trace clicking and peeking definition")

## Load Current Namespace

When navigating namespaces it is easy to [forget to first require them](https://clojure.org/guides/repl/navigating_namespaces#_how_things_can_go_wrong) and that can be a bit tricky to fix. To help with this Calva's command **Load/Evaluate Current File and its Requires/Dependencies** also works in the output window, but then acts like **Load Current Namespace**.

Consider you have two files, `pez/xxx.clj` and `pez/yyy.clj`, where `pez.yyy` requires `pez.xxx`.

```clojure
(ns pez.xxx)

(def a :xxx-a)

(def b :xxx-b)
```

```clojure
(ns pez.yyy
  (:require [pez.xxx]))

(def a :yyy-a)

(println "Hello" pez.xxx/a)
```

Then with a freshly jacked-in REPL you do `(ns pez.yyy)` and want to work with the vars defined there. Clojure will complain. But if you **Load/Evaluate Current File and its Requires/Dependencies**, it will start working. Something like so:

![Load Current Namespace in the Calva Output Window](images/howto/output/load-current-namespace.png)

!!! Note
    This currently suffers from a limitation in Calva where it won't reload dependencies, so you will sometimes have to do this ”manually” anyway (by opening the files and loading them). See [Calva issue #907](https://github.com/BetterThanTomorrow/calva/issues/907)

### Peek Current Namespace

A somewhat hidden feature: You can see documentation for, peek and navigate to a namespace by hovering on the namespace symbol in one of the repl window prompts (just like you would if it was not in the prompt 😄).

## Paredit Enabled

The output window is mostly a regular Calva Clojure/ClojureScript file, which make everything that works in a regular file work in this file, including [Paredit](paredit.md). This makes it easy to navigate the input and output. For instance, to select the last evaluation results you can press `ctrl+w` (`shift+alt+right` on Windows and Linux):

![Paredit select current form](images/howto/output/select-last-result.png)

## Debugger Enabled

The output window is mostly a regular... (you get it), which means you also have the [Calva debugger](debugger.md) at your command at the REPL prompt (only for `clj` sessions, so far). So instead of evaluating a function definition using `alt+enter` you can evaluate it and instrument it for debugging using `ctrl+alt+c i`. Then call the function.

![repl-file debugger](images/howto/output/repl-file-debugger.png)

## It is Ephemeral

The contents of the output/REPL window is written to a file named `output.repl` in the `.calva/output-window` directory of your project. The file is recreated at every new session. And you should copy anything you want to keep from this file to wherever you want to keep it.

You probably want to add `.calva/output-window/` to your `.<something>ignore` files. (There are some more files in that directory that you shouldn't keep under source control.)

## Choose CLJ or CLJS REPL Connection

In full stack projects, you will probably use the window as a REPL for both `clj` and `cljs`. You can toggle which REPL the window is connected to using the command **Calva: Toggle REPL Connection for CLJC files**. There is a button for this in the status bar:

![Toggle CLJC](images/howto/cljc-toggle-button.png)

## Known Quirks

Due to limitations in the VS Code API it is hard for Calva to know if the output file is opened, and also if it is opened more than once. Make it a habit to leave this window opened. And if it is opened in several tabs, expect evaluation printouts to be a bit unpredictable.

If you save the output/REPL file (which most often does not make much sense, but anyway) you will sometimes be presented with a message about VS Code being confused about the file contents being out of sync. Just choose to *Overwrite* the currently saved version and you should be fine.

repository: BetterThanTomorrow/calva

branch_name: refs/heads/published

repo_name: BetterThanTomorrow/calva


text:
+++
title = "os_env resource"
draft = false
platform = "os"

[menu]
  [menu.inspec]
    title = "os_env"
    identifier = "inspec/resources/os/os_env.md os_env resource"
    parent = "inspec/resources/os"
+++

[\[edit on GitHub\]](https://github.com/inspec/inspec/blob/master/docs-chef-io/content/inspec/resources/os_env.md)

Use the `os_env` Chef InSpec audit resource to test the environment variables for the platform on which the system is running.

## Availability

### Installation

This resource is distributed along with Chef InSpec itself. You can use it automatically.

### Version

This resource first became available in v1.0.0 of InSpec.

## Syntax

A `os_env` resource block declares an environment variable, and then declares its value:

    describe os_env('VARIABLE') do
      its('property') { should eq 1 }
    end

where

- `('VARIABLE')` must specify an environment variable, such as `PATH`
- `matcher` is a valid matcher for this resource

## Examples

The following examples show how to use this Chef InSpec audit resource.

### Test the PATH environment variable

    describe os_env('PATH') do
      its('split') { should_not include('') }
      its('split') { should_not include('.') }
    end

### Test the Path environment variable by specifying the target Environment (Windows)

On windows a User's environment variable may obscure the local machine (system) environment variable. The correct environment variable may be tested as follows:

    describe os_env('PATH', 'target') do
      its('split') { should_not include('') }
      its('split') { should_not include('.') }
    end

where

- `'target'` may be either `system` or `user`

### Test Chef Habitat environment variables

Chef Habitat uses the `os_env` resource to test environment variables. The environment variables are first defined in a whitespace array, after which each environment variable is tested:

    hab_env_vars = %w(HAB_AUTH_TOKEN
                      HAB_CACHE_KEY_PATH
                      HAB_DEPOT_URL
                      HAB_ORG
                      HAB_ORIGIN
                      HAB_ORIGIN_KEYS
                      HAB_RING
                      HAB_RING_KEY
                      HAB_STUDIOS_HOME
                      HAB_STUDIO_ROOT
                      HAB_USER)

    hab_env_vars.each do |e|
      describe os_env(e) do
        its('content') { should eq nil }
      end
    end

## Matchers

For a full list of available matchers, please visit our [matchers page](/inspec/matchers/).

### content

The `content` matcher return the value of the environment variable:

    its('content') { should eq '/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin' }

### split

The `split` matcher splits the value of the environment variable with the `:` deliminator (use the `;` deliminator if Windows):

    its('split') { should include ('/usr/bin') }

Note: the `split` matcher returns an array including `""` for cases where there is a trailing colon (`:`), such as `dir1::dir2:`


text:
---
id: Basic
title: Adding Chimp to an existing app
---

In this section we will turn a basic Apollo-based backend into one that uses our generator.

You can [watch me here](https://youtu.be/w8JpCQP8oag) turn a basic Apollo-based backend into one that uses our generator.
Alternatively you can [follow through the steps yourself](https://www.xolv.io/dev-notes/adding-chimp-3-to-an-existing-application/), or if you prefer [take a look at the diff here](https://github.com/xolvio/chimp-gql-tiny-example/pull/2)

For an example with a lot more use-cases like Filtering, Pagination, using actual external DataSources and Federation take a look at [Examples/Federation](Examples/Federation.md)

repository: xolvio/chimp

repo_name: xolvio/chimp


text:
# Data Migration and Verification for GPII-4014 Deployment

The scripts in this directory are used during GPII-4014 deployment to perform the data migration and the data verification afterwards. See [GPII-4014](https://issues.gpii.net/browse/schema-0.2-GPII-4014) for deploy details.

## How to use these scripts

### Scripts for testing

1. createSimulatedGpiiKeys.js

 This script creates simulated GPII keys and their corresponding prefs safes in schema version 0.1 format. It
 creates documents in batches of a given number. For example, for creating 1000 GPII keys in batches of 100, this
 script will generate 100 new GPII keys and their corresponding prefs safes each time to send to CouchDB /_bulk_docs
 to create. This is to avoid the potential memory overflow at creating a large number of GPII keys in one shot. An example to create 50K GPII keys in batches of 50:
 ```
 node scripts/migration/schema-0.2-GPII-4014/createSimulatedGpiiKeys.js http://localhost:25984 50000 50
 ```

### Scripts for deployment

Assuming the document IDs for NOVA client credentials are "clientCredential-nova1" and "clientCredential-nova2":

1. migration-step1.js

 Run this script **before** deploying the new universal docker image from the universal root directory. It migrates all client credential documents. An example:
```
node scripts/migration/schema-0.2-GPII-4014/migration-step1.js http://localhost:25984 "clientCredential-nova1" "clientCredential-nova2"
```

2. migration-step2.js

 Run this script **after** deploying the new universal docker image from the universal root directory. It updates all "schemaVersion" and "timestampUpdated" values in batches. An example of migrating in batches of 5000 documents in one batch:
```
node scripts/migration/schema-0.2-GPII-4014/migration-step2.js http://localhost:25984 5000
```

3. verify.js

 Run this script **after** the data migration completes. It checks if all documents have been migrated. An example of verifying
 in batches of 5000 documents in one batch:
```
node scripts/migration/schema-0.2-GPII-4014/verify.js http://localhost:25984 5000 "clientCredential-nova1" "clientCredential-nova2"
```

repository: GPII/universal

repo_name: GPII/universal


text:
User style sheet & font — GNOME Shell extension
===

This extension loads CSS file from `~/.config/gnome-shell/gnome-shell.css`
allowing you to customize GNOME Shell appearance with custom style sheet.
It works similar to `~/.config/gtk-3.0/gtk.css` but in the shell.
Also, this extension applies GTK font name and font size to GNOME Shell.

Installation
---

This extension can be installed from official repository with GNOME Shell
extensions in your web browser:
https://extensions.gnome.org/extension/3414/user-stylesheet-font.

Also, it is possible to install the extension from command line:

```bash
dbus-send --type=method_call --dest=org.gnome.Shell /org/gnome/Shell \
    org.gnome.Shell.Extensions.InstallRemoteExtension<EMAIL_ADDRESS>```

Alternatively, you can copy all files from this repository to
<EMAIL_ADDRESS>directory and restart GNOME Shell.

How to use custom style sheet
---

* Put your CSS code in `gnome-shell.css` file inside `~/.config/gnome-shell` directory.
* You must restart GNOME Shell after creating `gnome-shell.css` file.
  Press Alt+F2 and type `r` (only legacy X11) or just logout and login again.
* You don't have to restart GNOME Shell to update style sheet from existing
  `gnome-shell.css` file. Just press Alt+F2 and type `rt`.

To make writing CSS code easier you can take a look at GNOME Shell built-in theme:
https://gitlab.gnome.org/GNOME/gnome-shell/-/tree/main/data/theme.

How to use custom font
---

You can modify interface font several ways and the change will be applied immediately.

* GNOME Tweaks → Fonts → Interface Text.
* dconf Editor → `org` → `gnome` → `desktop` → `interface` → `font-name`.
* CLI command: `gsettings set org.gnome.desktop.interface font-name "Sans 10"`.

This extension is not needed to change font name in GNOME Shell since
version 3.36 but font size is still hardcoded. More information:
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/486.

Custom styles examples
---

### Remove top panel rounded corners

```css
.panel-corner {
    -panel-corner-radius: 0px;
    -panel-corner-background-color: transparent;
    -panel-corner-border-width: 0px;
    -panel-corner-border-color: transparent;
}
```

### Make workspace switcher smaller

```css
.ws-switcher-box {
    height: 30px;
}
```

### Hide OS icon in RHEL and CentOS

```css
.panel-logo-icon {
    icon-size: 1px;
    padding-right: 0;
}
```

### Change font in calendar menu

```css
.calendar .calendar-day-base {
    font-size: 100%;
}
```


text:
# Awesome Advice [![awesome.list](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)

> A collection of awesome pieces of advice

## Priority
- The better the problem is defined, the better the solution will be

## Research
- #1. most important thing in programming is knowing how to research.
- #2. is research.
- #3. is research.

## 15 minute rule
  > general rule of thumb / proverbial saying, not 100% black-and-white, just don't be an askhole.

  - If you ask for help on a problem before doing at least 15 minutes of work researching, debugging, and defining your problem, you're doing the other person a disservice.

## Proverbial
- Measure twice, cut once
- There is never any code that is more permanent than temporary code
- When you have a hammer, everything looks like a nail
- If you're not using a framework, you're making one.

## General
- Design patterns: don't let the names dictate the form of your code
- Expressive, clearly communicative, clean code
  - Have [variable names describe their intention](https://twitter.com/svensauleau/status/856424137493008384)
- Join in the community, conversing with people interested in the same thing, helping solve problems & getting your problems solved
- Don't worry if you think it sucks, contributing open source code helps build important skills, practice makes permanent
- Muscle memory is 10x more effective than memorization: study, but don't forget to _exercise_ your learning

[eslint]: https://www.npmjs.com/package/eslint
[prettier]: https://github.com/prettier/prettier
[tslint]: https://www.npmjs.com/package/tslint-eslint-rules
[xo]: https://github.com/sindresorhus/xo

## Tools
- Consistency - use tools to keep consistent rules [[eslint][eslint], [prettier][prettier], [tslint][tslint], [xo][xo]]
- [Backwards compatibility is for suckers](http://blog.ircmaxell.com/2013/06/backwards-compatibility-is-for-suckers.html)

## Performance
- Premature optimization is the root of all evil
- Make it debuggable
- Ensure that the micro-optimizations are really things to optimize if they may do less benefit and cause more negatives than obvious ones
- [Benchmark](https://github.com/aretecode/bench-chain)

## Always
- Good APIs
- Schema validation
- Good http transactions
- Simple DBs

---

See [best-practices](best-practices.md) for Principles, Laws, and general best practices.

## Contribute

Contributions welcome!
Read the [contribution guidelines](contributing.md) first.

## License

[![CC0](http://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg)](http://creativecommons.org/publicdomain/zero/1.0)
To the extent possible under law, James has waived all copyright and related or neighboring rights to this work.

repository: aretecode/awesome-advice

repo_name: aretecode/awesome-advice


text:
# Introduction to CoreRT Repo

This is the repo for CoreRT, the .NET Core runtime optimized for AOT (Ahead of Time) compilation scenarios. This project is in early stages of its development.

## Architecture

- [Intro to .NET Native and CoreRT](intro-to-corert.md)

## Developer Guide

- [Prerequisites for building](prerequisites-for-building.md)
- [How to build and run from the Command Line](how-to-build-and-run-ilcompiler-in-console-shell-prompt.md)
- [How to build and run from Visual Studio](how-to-build-and-run-ilcompiler-in-visual-studio.md)
- [How to build and run from VSCode](how-to-build-and-run-ilcompiler-in-vscode.md)
- [How to run tests](how-to-run-tests.md)
- [Cross Compilation for ARM on Linux](cross-building.md)
- [How to Build WebAssembly](how-to-build-WebAssembly.md)

## Tools
- [ILVerify](../src/ILVerify/README.md)

repository: MichalStrehovsky/corert

gha_language: C#

repo_name: MichalStrehovsky/corert


text:
# server-deployment-practice

practice example for ci cd workflow from local machine to github and to heroku

## Author: Fizzo Pannosch

[heroku deployed site](https://fizzo-server-deploy-dev.herokuapp.com/)

[github actions](https://github.com/fizzo999/server-deployment-practice/actions)

[github pull request](https://github.com/fizzo999/server-deployment-practice/pull/1)


text:
This is an example application used to test the modeling of Play data storage.

As seen in the below Entity relation diagram, there are five tables:![Select](https://raw.github.com/kowasu/Warehouse/master/images/ERD%20for%20warehouse.png)

The design behind this model is a warehouse which stocks items.

There is a 1:1 relationship between warehouse and address because a specific warehouse can only occupy one address, just as an address should only relate to one warehouse.

Warehouses can stock multiple items. But a particular stocked items only relates to one warehouse. After it doesn't make sense that one warehouse have access to another's stock.

The stockitem is for a specific product. The reason that a product can be associated with multiple stockitems is because of different warehouses. Each warehouse will track their own stock which means that they might hold the same product, but have different amounts or prices.

A product can have many tags for description. While specific tag might have many products using it in their description.


text:
# Json Merge Patch Support for .Net 5

[![Build Status](https://dev.azure.com/matthewethomas/Public%20Projects/_apis/build/status/JsonMergePatch?branchName=master)](https://dev.azure.com/matthewethomas/Public%20Projects/_build/latest?definitionId=13&branchName=master)
![code coverage](https://img.shields.io/azure-devops/coverage/matthewethomas/Public%2520Projects/13?style=flat-square)

## Json Merge Patch
- [RFC 7396](https://tools.ietf.org/html/rfc7396)
- Backed by Newtonsoft.Json or System.Text.Json - your choice
- Supports conversion to [JSON Patch](https://benfoster.io/blog/aspnet-core-json-patch-partial-api-updates), which can perform partial resource updates
- Supports Swagger
- .Net 5

Some inspiring projects:
- [Here's a introduction to merge patch](http://blog.primarilysoftware.com/2019/json-merge-patch-dot-net/)
- [Morcatko's JsonMergePatch](https://github.com/Morcatko/Morcatko.AspNetCore.JsonMergePatch)

C# Object
JSON
Resulting C# Object

``` C#
var person = new Person()
{
    FirstName = "John",
    LastName = "Doe"
};
```

``` JSON
{
 "LastName": "Smith"
}
```

``` C#
{
    FirstName = "John",
    LastName = "Smith"
}
```

``` C#
// Apply all the changes in the patch to your existing DTO
[HttpPatch]
[Consumes(MergePatchDocument.ContentType)]
public IActionResult Patch([FromBody] IJsonMergePatch<Person> mergePatch)
{
    ...
    mergePatch.ToJsonPatch().ApplyTo(existingDTO);
    ...
}
```

``` C#
//Acting on the presence/absence of a property in the patch
[HttpPatch]
[Consumes(MergePatchDocument.ContentType)]
public IActionResult Patch([FromBody] IJsonMergePatch<Person> mergePatch)
{
    if(mergePatch.TryGetValue(x => x.LastName, out var ln)
    {
        //act accordingly
    }
}
```

``` C#
// If you need to create a patch document to call a different service
public void CreatePatch()
{
    //simple sets, one property at a time
    var mergePatch = JsonMergePatch.New();
    mergePatch.Set(x => x.LastName, "Smith");

    //or, use a builder, which can conditionally set values from other merge patchess
    var pb = JsonMergePatch.CreateBuilder<Person>();
    pb.Set(x => x.LastName).ToValue("Smith");
    var mergePatch = pb.Build();
}
```


text:
#Input Axis: Mouse

1. Stop the scene for a moment and go to the InputManager (**Edit >> Project Settings >> Input**).  *You may find it handy to use the lock icon at top right to keep it open for this exercise .*
2. Try changing the *gravity* setting in the Vertical axis to 0.  Run the game again and see how the cube behaves differently with no code changes
   * The gravity setting will 'pull' the axis value back towards zero if the user stops inputting.
    Reset the *gravity* to 3
4. Change the axis so it uses mouse movement by setting *type* to **Mouse Movement**.
5. Run the game again, and move your mouse cursor up and down. What happens now?
6. Stop the game and reopen the Input manager. Change the *Sensitivity* value to **.25** and re-run the game.
   * When using mouse or joystick as an axis, *Sensitivity* scales the value coming in. In the case of a mouse, you want low values since the incoming numbers represent dozens of pixels for each frame.
7. The game is less jittery, but still jumps a lot. In the next exercise we'll try to smooth it out.

[back](4-6.md) [next](4-8.md)

gha_language: HTML


text:
# npuer-sample
A sample that uses the no password user authentication (npuser) services

# Sample npuser client

This sample NodeJS project demonstrates how a npusr client sends the initial
authorization request to the npuser server. It then prompts the user, on the command line,
to enter the verification code.  Get and enter the code. The sample app then sends the verification
request which validates the user.

## Configuration

Copy the sample environment files into your local (not in git).
```
cp sample.dev.env .env.dev
cp sample.prod.env .env.prod
```

The DEV sample should work as is with the defaults used by a locally running npuser authorization service.

The PROD sample needs real client id and secret and email address.

Adjust the .env files to suit your needs and run the sample ...

## Build
Need to build to convert Typescript to JS
```
npm run build:run
```

## Run
```
# dev
npm run run

#prod
npm run run:prod
```

## How to obtain the verification code

This sample application sends the authorization request.  You then need to find the
verification code the npuser authorization server creaetd.

If you are running this as a developer of npuser then you can see the npuser server's
console output. The verification code is there.

If you are running this as a developer of an application that will use the npuser server
then configure this sample to reach out to a running service. You will then need to
modify the sample code to use a real email address that you can access. The verification
code will appear in your inbox.

## How was this project created?

```
# initialize the project
npm init -y

# install webbpack
npm install webpack webpack-cli --save-dev
npm install nodemon-webpack-plugin --save-dev
touch webpack.config.js

# application dependencies
npm install dotenv --save
npm install npuser-client --save
npm install readline --save

```

Add a webpage.config.js file (set target as node)
```
const NodemonPlugin = require('nodemon-webpack-plugin'); // Ding
const path = require('path')
module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve('./dist'),
    filename: 'main.js',
  },
  plugins: [
    new NodemonPlugin(), // Dong
  ],
  target: 'node'
};
```

Adjust the scripts in the package.json file.
```
  "scripts": {
    "watch": "webpack --watch --mode=development",
    "build": "webpack --mode=development && npm run run",
    "run": "node dist/main.js"
  },
```

## How I created the sample client

In the root folder, locally install the Vue CLI.  I prefer to locally install this tool whenever I need it so that I can
get the latest version without affecting any other projects.
```
npm install @vue/cli --save-dev
npm install @vue/cli-init --save-dev
```

Then to run the local Vue CLI you need to reach into the node_modules directories.

```
node<EMAIL_ADDRESS>create npuser-sample-client
```

For this sample I made the following choices.  None of these are needed for your application.
```
Vue CLI v4.5.9
? Please pick a preset: Manually select features
? Check the features needed for your project:
 ◉ Choose Vue version
 ◉ Babel
 ◉ TypeScript
 ◉ Progressive Web App (PWA) Support
❯◉ Router
 ◉ Vuex
 ◉ CSS Pre-processors
 ◉ Linter / Formatter
 ◉ Unit Testing
 ◉ E2E Testing

Vue CLI v4.5.9
? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, Babel, TS, PWA, Router, Vuex, CSS Pre-processors, Linter, Unit, E2E
? Choose a version of Vue.js that you want to start the project with 3.x (Preview)
? Use class-style component syntax? No
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: Standard
? Pick additional lint features: Lint on save
? Pick a unit testing solution: Jest
? Pick an E2E testing solution: Cypress
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? (y/N)
```

Next remove Vue icons and insert icon for my application
```
## get the npuser icon...
cd npuser-sample-client/public
cp ../../../npuser/client/public/favicon.ico .

## remove all the Vue icon files
cd img/icons
rm *
```

I then removed the boilerplate Vue code in
```
public/index.html
src/components/HelloWorld.vue
src/views/Home.vue
```

Run the client with the vue web server and verify all is OK
```
npm run serve -- --port 8081
```

I like to use Pug instead of HTML
```
node<EMAIL_ADDRESS>add pug
```

Next, let's add pages and components and routing that will require authentication, once we've set up the basic pages.
For this step I went looking for a sample so I can do what we often do, copy and paste existing code. I like the tutorials
that Digital Ocean provides and used this one for this sample. Starting at Step 3

https://www.digitalocean.com/community/tutorials/how-to-set-up-vue-js-authentication-and-route-handling-using-vue-router#step-3-%E2%80%94-updating-the-vue-router-file

## Set up sample server

Your application needs an API service.  For this sample we provide a very basic Node JS Express server that is based on the server
found in the "How To Set Up Vue.js Authentication and Route Handling Using vue-router" tutorial, mentioned above.
Because we will use NP User the server code that supports adding new users (your customers) and allowing them to
login is very simple compared to normal applications.

## The problems with passwords

In the normal flow of user authentication you're new potential customer needs to register on your application.
This is when your application will lose so many potential customers.  You invested a lot of time and effort
promoting your application or website. People are coming but are they registering?  Every step between the time
your new potential customer arrives and when they start to see value from your application is a step that can lose
a new customer.

The registration process is a jump your new users will need to make before they can see value.  Typically,
applications ask new users to provide their name, a user id, their email address and a password.

Many users want to use an easy to remember password which is often a weak password.  Weak passwords
are an attack vector on your server.  To protect your application and your customers your application
needs to impose rules to get only strong passwords.
For example, passwords must be of a certain length, contain a mixture of upper and lower case letters,
contains a mixture of numbers and symbols, etc.
Some applications go further and add more general rules such as insisting that users not reuse passwords they have used before.

To make matters more complicated, the definitions of a "strong password" changes as
security experts continue to find ways to counteract the threats from malicious
hackers.

As well, your user interface ought to guide your new customer as they compose their new password. That means
every rule imposed on the password field needs to be implemented not only on your server but also in your user interface.

Then you need to consider the privacy issues.  We've all read tragic stories of top tier corporations getting hacked
and millions of user accounts are stolen along with users passwords that we stored in plain text.

But, we are not done with the problems with passwords.  What happens when your user forgets their password?    Now, your user interface needs
a whole new set of web pages, api calls and business logic.  Plus, your application needs API to accept a password reset request.

The first step checks if the user is registered or not.  Question.  If not do you immediately tell the
user that the user id or email address they entered is a valid user?  Best practice suggests you don't because that helps
malicious hackers see who has registered with your business. The second step typically involves generating a code
and sending that to your user via email. Your application needs code to work with your application's email service.
The process continues and it has many other traps to avoid.  Instead, let's consider using NP User.

Can we sum up this topic and agree it is very challenging to correctly handle password and user registration?

## NP User no password authentication

Install the NP User client library on your API server
```
 npm install --save npuser-client
```

repository: npuserauth/npuser-sample

repo_name: npuserauth/npuser-sample


text:
# Qwerk_Engine
*This project is a work in progess and is continually in an unstable state*
A simple engine or runtime editor for the QwerkE framework.
QwerkEngine framework lives here: https://github.com/AaronAppel/QwerkE_Framework

## Getting Started
Open the Qwerk_Engine folder in the root of the respository to find the solution.

WIP: www.github.com/AaronAppel/QwerkE_Documentation

## Examples
### Installing
TODO: How to install QwerkEngine and the accompanying framework.

### Usage
Simple example usage of QwerkEngine.

WIP: www.github.com/AaronAppel/QwerkE_Documentation
~~~cpp
int main()
{
    cout << "Awaiting Documentation..." << endl;
}
~~~
...

## 3rd Party Libraries
Libraries I utilize to deliver features.

- glew: www.github.com/nigels-com/glew
- glfw: www.github.com/glfw/glfw
- RakNet: www.github.com/facebookarchive/RakNet
- lodepng: www.github.com/lvandeve/lodepng
- stb_image: www.github.com/nothings/stb
- imgui: www.github.com/ocornut/imgui
- freetype2: www.freetype.org/index.html
- glm: www.github.com/g-truc/glm
- pthreads: www.github.com/coapp-packages/pthreads
- assimp: www.github.com/assimp/assimp
- OpenAL: www.openal.org
// not currently used - vlc: www.github.com/videolan/vlc
// not currently used - nVidia video codec: https://developer.nvidia.com/nvidia-video-codec-sdk

## License
This project is licensed under the BSD3 License - see the LICENSE file for details.

## References
learnopengl.com
The Cherno : YouTube (https://www.youtube.com/user/TheChernoProject), github (https://github.com/TheCherno)
Thin Matrix : YouTube (https://www.youtube.com/channel/UCUkRj4qoT1bsWpE_C8lZYoQ)
Game engine Architecure Third Edition by Jason Gregory

## Acknowledgments
...

repository: AaronAppel/QwerkE

repo_name: AaronAppel/QwerkE


text:
# spring-security-mongo
Spring Security with mongo backend and default setup

'MongoSecurityUserRoles' collection needs to have at least 'username', 'password' and 'roles' fields. An example collection is as follows.

```json
{
    "username" : "user",
    "password" : "111",
    "roles" : [
        "ROLE_NAME_QUERY"
    ]
},
{
    "username" : "admin",
    "password" : "222",
    "roles" : [
        "ROLE_NAME_QUERY",
        "ROLE_NAME_COMMAND"
    ]
}
```

repository: canmogol/spring-security-defaults

repo_name: canmogol/spring-security-defaults


text:
# DRad'est Graph

Undirected graph implementation using adjacency list representation with some basic functions (listed below).

## Installation

To run the code from the command line:

- cd into directory with the graph files
- run `g++ dradest_graph.cpp main.cpp -o out`
- run `./out.exe`

## Functions

#### `void addEdge(int u, int w)`
Inserts an edge between u and w.
Prints a message if the edge already exists in the graph.

#### `void printGraph()`
Prints the adjacency list representation of the graph.

#### `std::vector<int> BFS(int n)`
Performs a breadth first search *iteratively* starting from node n. Returns a vector of nodes.

#### `std::vector<int> iterativeDFS(int n)`
Performs a depth first search *iteratively* starting from node n. Returns a vector of nodes.

#### `std::vector<int> recursiveDFS(int n)`
Performs a depth first search *recursively* starting from node n. Returns a vector of nodes.

#### `bool hasCycle()`
Uses DFS to detect a cycle in the graph. Preforms DFS on the graph. If, for every visited node *v*,
exists already visited node *u* that is not the parent of *v*, graph contains a cycle.

#### `bool containsCycle()`
Uses union by rank and path compression to detect a cycle in the graph. *Union by rank:* always attach
smaller depth tree under the root of a deeper tree. Rank is not always equal to depth. *Path compression:*
flatten the tree each time `find()` is called, i.e. save found root of node as its parent.

#### `std::vector<int>* primMST()`
Performs Prim's algorithm to find minimum spanning tree. Simplified, since this is unweighted graph.
Returns an adjcency list representation of a tree.

> The algorithm may informally be described as performing the following steps:
>
>1. Initialize a tree with a single vertex, chosen arbitrarily from the graph.
>2. Grow the tree by one edge: of the edges that connect the tree to vertices not yet in the tree, find the minimum-weight edge, and transfer it to the tree.
>3. Repeat step 2 (until all vertices are in the tree).

source: [wikipedia](https://en.wikipedia.org/wiki/Prim%27s_algorithm)

#### `std::vector<int>* kruskalMST()`
Performs Kruskal's algorithm to find minimum spanning tree. Simplified, since this is unweighted graph.
Returns an adjacency list representation of a tree.

Algorithm:

>* create a forest F (a set of trees), where each vertex in the graph is a separate tree
>* create a set S containing all the edges in the graph
>* while S is nonempty and F is not yet spanning
>*     remove an edge with minimum weight from S
>*     if the removed edge connects two different trees then add it to the forest F, combining two trees into a single tree
>
> At the termination of the algorithm, the forest forms a minimum spanning forest of the graph. If the graph is connected, the forest has a single component and forms a minimum spanning tree

source: [wikipedia](https://en.wikipedia.org/wiki/Kruskal%27s_algorithm)

#### `void dijkstraSPT(int root)`
Performs Dijkstra's algorithm to find shortest paths tree from root to all other nodes. Prints out nodes and their distances from root.

Algorithm:

>Let the node at which we are starting be called the initial node. Let the distance of node Y be the distance from the initial node to Y. Dijkstra's algorithm will assign some initial distance values and will try to improve them step by step.

>1. Mark all nodes unvisited. Create a set of all the unvisited nodes called the unvisited set.
>2. Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes. Set the initial node as current.
>3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances through the current node. Compare the newly calculated tentative distance to the current assigned value and assign the smaller one. For example, if the current node A is marked with a distance of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B through A will be 6 + 2 = 8. If B was previously marked with a distance greater than 8 then change it to 8. Otherwise, keep the current value.
>4. When we are done considering all of the unvisited neighbors of the current node, mark the current node as visited and remove it from the unvisited set. A visited node will never be checked again.
>5. If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished.
>6. Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new "current node", and go back to step 3.

source: [wikipedia](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)

## Useful Links

* [cpp headers](http://www.cplusplus.com/forum/articles/10627/) article on cplusplus.com
* algolist.net [dfs](http://www.algolist.net/Algorithms/Graph/Undirected/Depth-first_search)
* geeksforgeeks [graph ds and algorithms](https://www.geeksforgeeks.org/graph-data-structure-and-algorithms/)
* WilliamFiset's yt video on [topological sorting](https://youtu.be/eL-KzMXSXXI)
* isocpp.org [operator overloading tutorial](https://isocpp.org/wiki/faq/operator-overloading)

## Acknowledgement

Font used for logo / banner: [Brankovic](https://www.dafont.com/brankovic.font)

repository: dRadest/dradestGraph

repo_name: dRadest/dradestGraph