text:
# Further Examples of Conditional Process Analysis

> In this chapter [Hayes built] on the foundation laid by stepping through an analysis of a more complicated conditional process model that include[d] moderation of both the indirect effects in a simple mediation model. [He did] so by first using a piecemeal approach that focuse[d] on each pathway in the model. With some understanding gained by this examination of the components in the process, [he brought] the pieces together into an integrated conditional process analysis...
>
> When an indirect effect of $X$ on $Y$ through $M$ is moderated, we call this phenomenon *moderated mediation*. In such a scenario, the mechanism represented by the $X \rightarrow M \rightarrow Y$ chain of events operates to varying degrees (or not at all) for certain people or in certain contexts. A similar-sounding phenomenon is *mediated moderation*, which refers to the scenario in which an interaction between X and some moderator $W$ on $Y$ is carried through a mediator $M$. [We'll see] in this chapter that a mediated moderation analysis is really nothing other than a mediation analysis with the product of two variables serving as the causal agent of focus. [@hayesIntroductionMediationModeration2018, p. 432]

## Revisiting the disaster framing study

Here we load a couple necessary packages, load the data, and take a `glimpse()`.

```r
library(tidyverse)

disaster <- read_csv("data/disaster/disaster.csv")

glimpse(disaster)
```

```
## Rows: 211
## Columns: 5
## $ id      <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 2…
## $ frame   <dbl> 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,…
## $ donate  <dbl> 5.6, 4.2, 4.2, 4.6, 3.0, 5.0, 4.8, 6.0, 4.2, 4.4, 5.8, 6.2, 6.0, 4.2, 4.4, 5.8, 5.4, 3.4, 7.…
## $ justify <dbl> 2.95, 2.85, 3.00, 3.30, 5.00, 3.20, 2.90, 1.40, 3.25, 3.55, 1.55, 1.60, 1.65, 2.65, 3.15, 2.…
## $ skeptic <dbl> 1.8, 5.2, 3.2, 1.0, 7.6, 4.2, 4.2, 1.2, 1.8, 8.8, 1.0, 5.4, 2.2, 3.6, 7.8, 1.6, 1.0, 6.4, 3.…
```

Load **brms**.

```r
library(brms)
```

At the top of page 433, Hayes fit a simple univariable model

$$Y = b_0 + b_1 X + e_Y,$$

where the $X$ is `frame` the $Y$ is `donate`. Here's the model.

```r
model12.1 <- brm(
  data = disaster,
  family = gaussian,
  donate ~ 1 + frame,
  chains = 4, cores = 4,
  file = "fits/model12.01")
```

Check the summary.

```r
print(model12.1, digits = 3)
```

```
##  Family: gaussian
##   Links: mu = identity; sigma = identity
## Formula: donate ~ 1 + frame
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##           Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## Intercept    4.564     0.128    4.316    4.808 1.000     4275     3070
## frame        0.084     0.182   -0.279    0.444 1.000     4781     3193
##
## Family Specific Parameters:
##       Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma    1.326     0.066    1.207    1.463 1.003     4205     3053
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

Hayes interpreted the coefficient for `frame` through the lens of a $t$ statistic and accompanying $p$-value. We'll just plot the posterior. For the figures in this chapter, we'll take theme cues from the vignettes from Matthew Kay's [**tidybayes** package](https://mjskay.github.io/tidybayes/).

```r
library(tidybayes)
theme_set(theme_tidybayes() + cowplot::panel_border())

as_draws_df(model12.1) %>%
  ggplot(aes(x = b_frame, y = 0)) +
  stat_halfeye() +
  geom_vline(xintercept = 0, linetype = 2) +
  scale_y_continuous(NULL, breaks = NULL)
```

Now we fit the moderation model

$$Y = b_0 + b_1 X + b_2 W + b_3 XW + e_Y,$$

where `skeptic` is the $W$ variable.

```r
model12.2 <- brm(
  data = disaster,
  family = gaussian,
  donate ~ 1 + frame + skeptic + frame:skeptic,
  chains = 4, cores = 4,
  file = "fits/model12.02")
```

Our `model12.2` summary matches nicely with the text.

```r
print(model12.2, digits = 3)
```

```
##  Family: gaussian
##   Links: mu = identity; sigma = identity
## Formula: donate ~ 1 + frame + skeptic + frame:skeptic
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##               Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## Intercept        5.027     0.226    4.588    5.469 1.001     2394     2921
## frame            0.678     0.333    0.027    1.335 1.000     2095     2623
## skeptic         -0.139     0.058   -0.253   -0.027 1.000     2351     2563
## frame:skeptic   -0.172     0.085   -0.341   -0.007 1.000     2026     2607
##
## Family Specific Parameters:
##       Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma    1.241     0.062    1.128    1.371 1.002     3031     2750
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

Here's our Figure 12.2.

```r
nd <- crossing(frame   = 0:1,
               skeptic = seq(from = 0, to = 7, length.out = 30))

fitted(model12.2, newdata = nd) %>%
  data.frame() %>%
  bind_cols(nd) %>%
  mutate(frame = ifelse(frame == 0, str_c("Natural causes (X = ", frame, ")"),
                        str_c("Climate change (X = ", frame, ")"))) %>%
  mutate(frame = factor(frame,
                        levels = c("Natural causes (X = 0)",
                                   "Climate change (X = 1)"))) %>%

  ggplot(aes(x = skeptic, y = Estimate)) +
  geom_ribbon(aes(ymin = Q2.5, ymax = Q97.5, fill = frame),
              alpha = 1/3) +
  geom_line(aes(color = frame)) +
  scale_fill_brewer(palette = "Set2") +
  scale_color_brewer(palette = "Set2") +
  coord_cartesian(xlim = c(1, 6),
                  ylim = c(3.5, 5.5)) +
  labs(x = expression(paste("Climate Change Skepticism (", italic(W), ")")),
       y = "Willingness to Donate to Victims") +
  theme(legend.direction = "horizontal",
        legend.position = "top",
        legend.title = element_blank())
```

In Hayes's Figure 12.2, he emphasized the differences at the three levels of `skeptic`. If you want the full difference score distributions in a pick-a-point-approach sort of way, you might plot the densities with `tidybayes::stat_halfeye()`, which places coefficient plots at the base of the densities. In this case, we show the posterior medians with the dots, the 50% intervals with the thick horizontal lines, and the 95% intervals with the thinner horizontal lines.

```r
nd <- crossing(frame   = 0:1,
               skeptic = quantile(disaster$skeptic, probs = c(.16, .5, .86)))

fitted(model12.2,
       summary = F,
       newdata = nd) %>%
  data.frame() %>%
  set_names(mutate(nd, label = str_c(frame, "_", skeptic)) %>% pull(label)) %>%
  mutate(iter = 1:n()) %>%
  pivot_longer(-iter) %>%
  separate(name, into = c("frame", "skeptic"), sep = "_", convert = T) %>%
  pivot_wider(names_from = frame, values_from = value) %>%
  mutate(difference = `1` - `0`) %>%

  ggplot(aes(x = difference, y = skeptic, fill = skeptic %>% as.character())) +
  stat_halfeye(point_interval = median_qi, .width = c(0.95, 0.5)) +
  scale_fill_brewer() +
  scale_y_continuous(breaks = quantile(disaster$skeptic, probs = c(.16, .5, .86)),
                     labels = quantile(disaster$skeptic, probs = c(.16, .5, .86)) %>% round(2)) +
  theme(legend.position = "none")
```

Here's our simple mediation model, `model12.3`, using the multivariate syntax right in the `brm()` function.

```r
model12.3 <- brm(
  data = disaster,
  family = gaussian,
  bf(justify ~ 1 + frame) +
    bf(donate ~ 1 + frame + justify) +
    set_rescor(FALSE),
  chains = 4, cores = 4,
  file = "fits/model12.03")
```

```r
print(model12.3, digits = 3)
```

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: justify ~ 1 + frame
##          donate ~ 1 + frame + justify
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##                   Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## justify_Intercept    2.801     0.089    2.626    2.974 1.004     6717     2862
## donate_Intercept     7.235     0.228    6.775    7.662 1.000     6596     3057
## justify_frame        0.135     0.130   -0.123    0.391 1.002     6215     2749
## donate_frame         0.212     0.139   -0.058    0.484 1.002     6520     3140
## donate_justify      -0.953     0.075   -1.097   -0.802 1.000     7014     3043
##
## Family Specific Parameters:
##               Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma_justify    0.934     0.047    0.849    1.033 1.002     6432     3240
## sigma_donate     0.985     0.048    0.897    1.083 0.999     5757     3084
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

Consider the Bayesian $R^2$ summaries.

```r
bayes_R2(model12.3) %>% round(digits = 3)
```

```
##           Estimate Est.Error  Q2.5 Q97.5
## R2justify    0.010     0.012 0.000 0.042
## R2donate     0.449     0.039 0.364 0.517
```

If you want the indirect effect with its intervals, you use `as_draws_df()` and data wrangle, as usual.

```r
as_draws_df(model12.3) %>%
  mutate(ab = b_justify_frame * b_donate_justify) %>%
  mean_qi(ab)
```

```
## # A tibble: 1 × 6
##       ab .lower .upper .width .point .interval
##    <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>
## 1 -0.128 -0.378  0.117   0.95 mean   qi
```

## Moderation of the direct and indirect effects in a conditional process model

Our conditional process model follows the form

\begin{align*}
M & = i_M + a_1 X + a_2 W + a_3 XW + e_M \\
Y & = i_Y + c_1' X + c_2' W + c_3' XW + b M + e_Y.
\end{align*}

We don't need to do anything particularly special to fit a model like this with **brms**. It just requires we do a careful job specifying the formulas in our `bf()` arguments. If you find this syntax a little too cumbersome, you can always specify the formulas outside of `brm()`, save them as one or multiple objects, and plug those objects into `brm()`.

```r
model12.4 <- brm(
  data = disaster,
  family = gaussian,
  bf(justify ~ 1 + frame + skeptic + frame:skeptic) +
    bf(donate ~ 1 + frame + justify + skeptic + frame:skeptic) +
    set_rescor(FALSE),
  chains = 4, cores = 4,
  file = "fits/model12.04")
```

Check the model summary.

```r
print(model12.4, digits = 3)
```

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
##          donate ~ 1 + frame + justify + skeptic + frame:skeptic
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##                       Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## justify_Intercept        2.453     0.149    2.166    2.746 1.000     3521     3162
## donate_Intercept         7.297     0.266    6.779    7.821 1.000     3780     3222
## justify_frame           -0.565     0.219   -1.001   -0.122 1.000     3289     2664
## justify_skeptic          0.105     0.038    0.029    0.178 1.000     3660     3216
## justify_frame:skeptic    0.201     0.055    0.090    0.308 1.000     3335     2809
## donate_frame             0.156     0.263   -0.357    0.671 1.002     3344     3217
## donate_justify          -0.923     0.083   -1.085   -0.756 1.001     4128     2837
## donate_skeptic          -0.044     0.047   -0.139    0.049 1.001     3737     3006
## donate_frame:skeptic     0.017     0.067   -0.115    0.149 1.002     3194     2802
##
## Family Specific Parameters:
##               Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma_justify    0.817     0.040    0.741    0.900 1.001     5063     2902
## sigma_donate     0.989     0.050    0.898    1.095 1.000     5217     2370
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

Here are the Bayesian $R^2$ summaries.

```r
bayes_R2(model12.4)
```

```
##            Estimate  Est.Error      Q2.5     Q97.5
## R2justify 0.2482236 0.04335464 0.1629624 0.3285198
## R2donate  0.4525392 0.03695545 0.3725687 0.5185562
```

### ~~Estimation using PROCESS~~.

We just fit that model. Next!

### Quantifying direct and indirect effects.

Here are summaries for $a_1$ through $a_3$.

```r
fixef(model12.4)[c(3:5), ] %>% round(digits = 3)
```

```
##                       Estimate Est.Error   Q2.5  Q97.5
## justify_frame           -0.565     0.219 -1.001 -0.122
## justify_skeptic          0.105     0.038  0.029  0.178
## justify_frame:skeptic    0.201     0.055  0.090  0.308
```

This is $b$.

```r
fixef(model12.4)["donate_justify", ] %>% round(digits = 3)
```

```
##  Estimate Est.Error      Q2.5     Q97.5
##    -0.923     0.083    -1.085    -0.756
```

We'll need to employ `as_draws_df()` to compute $(a_1 + a_3 W)b$, as shown in Table 12.2.

```r
draws <- as_draws_df(model12.4) %>%
  mutate(`indirect effect when W is 1.592` = (b_justify_frame + `b_justify_frame:skeptic` * 1.592) * b_donate_justify,
         `indirect effect when W is 2.800` = (b_justify_frame + `b_justify_frame:skeptic` * 2.800) * b_donate_justify,
         `indirect effect when W is 5.200` = (b_justify_frame + `b_justify_frame:skeptic` * 5.200) * b_donate_justify)

draws %>%
  pivot_longer(starts_with("indirect")) %>%
  group_by(name) %>%
  median_qi(value, .width = .95) %>%
  mutate_if(is.double, round, digits = 3)
```

```
## # A tibble: 3 × 7
##   name                             value .lower .upper .width .point .interval
##   <chr>                            <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>
## 1 indirect effect when W is 1.592  0.222 -0.04   0.512   0.95 median qi
## 2 indirect effect when W is 2.800  0     -0.204  0.217   0.95 median qi
## 3 indirect effect when W is 5.200 -0.44  -0.73  -0.187   0.95 median qi
```

And if you really want that full-on Table 12.2 layout, try this.

```r
draws %>%
  transmute(a1 = b_justify_frame,
            a3 = `b_justify_frame:skeptic`,
            b  = b_donate_justify,
            c1 = b_donate_frame,
            c3 = `b_donate_frame:skeptic`) %>%
  expand_grid(w = c(1.592, 2.800, 5.200)) %>%
  mutate(`a1 + a3w`      = a1 + a3 * w,
         `(a1 + a3w)b`   = (a1 + a3 * w) * b,
         `direct effect` = c1 + c3 * w) %>%
  select(-(a1:a3), -(c1:c3)) %>%
  pivot_longer(-w) %>%
  group_by(w, name) %>%
  summarise(mean = mean(value) %>% round(digits = 3)) %>%
  pivot_wider(names_from = name,
              values_from = mean) %>%
  select(w, `a1 + a3w`, b, everything())
```

```
## # A tibble: 3 × 5
## # Groups:   w [3]
##       w `a1 + a3w`      b `(a1 + a3w)b` `direct effect`
##   <dbl>      <dbl>  <dbl>         <dbl>           <dbl>
## 1  1.59     -0.245 -0.923         0.226           0.184
## 2  2.8      -0.002 -0.923         0.002           0.205
## 3  5.2       0.481 -0.923        -0.444           0.247
```

#### The conditional direct effect of $X$.

We already computed this in the last code block, above. But since we just focused on the posterior means, here's a summary of their medians and 95% intervals.

```r
draws <- draws %>%
  mutate(`direct effect when W is 1.592` = b_donate_frame + `b_donate_frame:skeptic` * 1.592,
         `direct effect when W is 2.800` = b_donate_frame + `b_donate_frame:skeptic` * 2.800,
         `direct effect when W is 5.200` = b_donate_frame + `b_donate_frame:skeptic` * 5.200)

draws %>%
  pivot_longer(starts_with("direct")) %>%
  group_by(name) %>%
  median_qi(value, .width = .95) %>%
  mutate_if(is.double, round, digits = 3) %>%
  select(name:.upper)
```

```
## # A tibble: 3 × 4
##   name                          value .lower .upper
##   <chr>                         <dbl>  <dbl>  <dbl>
## 1 direct effect when W is 1.592 0.185 -0.161  0.537
## 2 direct effect when W is 2.800 0.203 -0.069  0.481
## 3 direct effect when W is 5.200 0.248 -0.117  0.615
```

We can always plot, too.

```r
w <- c(1.592, 2.800, 5.200)

draws %>%
  expand_grid(w = w) %>%
  mutate(`conditional direct effect` = b_donate_frame + `b_donate_frame:skeptic` * w) %>%

  ggplot(aes(x = `conditional direct effect`, y = w, fill = w %>% as.character())) +
  stat_halfeye(point_interval = median_qi, .width = c(0.95, 0.5)) +
  scale_y_continuous(breaks = w) +
  scale_fill_brewer() +
  theme(legend.position = "none")
```

### Visualizing the direct and indirect effects.

We'll need to do some `draws` wrangling before we're ready to make our Figure 12.7. We'll save the results as `effects`.

```r
effects <- draws %>%
  expand_grid(w = seq(from = 0, to = 6, length.out = 30)) %>%
  mutate(`direct effect`   = b_donate_frame + `b_donate_frame:skeptic` * w,
         `indirect effect` = (b_justify_frame + `b_justify_frame:skeptic` * w) * b_donate_justify) %>%
  pivot_longer(c(`direct effect`, `indirect effect`)) %>%
  mutate(name = factor(name, levels = c("direct effect", "indirect effect"))) %>%
  select(w:value)

head(effects)
```

```
## # A tibble: 6 × 3
##       w name            value
##   <dbl> <fct>           <dbl>
## 1 0     direct effect   0.349
## 2 0     indirect effect 0.342
## 3 0.207 direct effect   0.353
## 4 0.207 indirect effect 0.302
## 5 0.414 direct effect   0.356
## 6 0.414 indirect effect 0.261
```

Now we plot.

```r
# we'll need this for `geom_text()`
text <- tibble(
  x     = c(4.2, 4.7),
  y     = c(.28, -.28),
  angle = c(3.6, 335),
  name  = factor(c("direct effect", "indirect effect"), levels = c("direct effect", "indirect effect")))

# plot!
effects %>%
  ggplot(aes(x = w, color = name, fill = name)) +
  stat_lineribbon(aes(y = value),
                  .width = .95, alpha = 1/3) +
  geom_text(data = text,
            aes(x = x, y = y,
                angle = angle,
                label = name),
            size = 5) +
  scale_fill_brewer(type = "qual") +
  scale_color_brewer(type = "qual") +
  coord_cartesian(xlim = c(1, 5.5),
                  ylim = c(-.6, .4)) +
  labs(x = expression(Climate~Change~Skepticism~(italic(W))),
       y = "Effects of Disaster Frame on Willingness to Donate") +
  theme(legend.position = "none")
```

Note how wide those 95% intervals are relative to the scale of the $y$-axis, which I specifically kept within the same range as Figure 12.7 in the text. To me the message is clear: include credible-interval ribbons in your regression slope plots. They help depict how uncertain the posterior is in a way a simple line slopes just don't.

## Statistical inference

### Inference about the direct effect.

We've already computed the 95% intervals for the direct effect, $\theta_{X \rightarrow Y}$, conditional on the three levels of $W$. Here's a different look at those intervals, superimposed on the 80% and 50% intervals, using the `tidybayes::stat_interval()` function.

```r
draws %>%
  pivot_longer(starts_with("direct")) %>%
  mutate(name = str_remove(name, "direct effect when W is ") %>% as.double()) %>%

  ggplot(aes(x = name, y = value, group = name)) +
  stat_interval(.width = c(.95, .80, .5)) +
  scale_color_brewer("Interval") +
  coord_cartesian(xlim = c(1, 5.5)) +
  labs(x = expression(paste("Climate Change Skepticism (", italic(W), ")")),
       y = "Conditional Direct Effect of Disaster Frame on\nWillingness to Donate")
```

### Inference about the indirect effect.

#### A statistical test of moderated mediation.

To get a sense of $a_3 b$, we just:

```r
draws <- draws %>%
  mutate(a3b = `b_justify_frame:skeptic` * b_donate_justify)

draws %>%
  select(a3b) %>%
  median_qi(a3b) %>%
  mutate_if(is.double, round, digits = 3)
```

```
## # A tibble: 1 × 6
##      a3b .lower .upper .width .point .interval
##    <dbl>  <dbl>  <dbl>  <dbl> <chr>  <chr>
## 1 -0.185 -0.294 -0.083   0.95 median qi
```

Here we'll combine `stat_intervalh()` and `stat_pointintervalh()` to visualize $a_3 b$ with a coefficient plot.

```r
draws %>%
  ggplot(aes(x = a3b, y = 1)) +
  stat_interval(.width = c(.95, .8, .5)) +
  stat_pointinterval(point_interval = median_qi, .width = c(.95, .8, .5),
                     position = position_nudge(y = -.75)) +
  scale_color_brewer("Interval") +
  scale_y_discrete(NULL, breaks = NULL) +
  coord_cartesian(xlim = c(-.5, 0)) +
  labs(title = expression(paste("Coefficient plot for ", italic(a)[3], italic(b), " (i.e., the index of moderated mediation)")),
       x = NULL) +
  theme(legend.position = "none")
```

#### Probing moderation of mediation.

As we discussed in Chapter 11, our Bayesian version of the JN technique should be fine because HMC does not impose the normality assumption on the parameter posteriors. In this instance, I'll leave the JN technique plot as an exercise for the interested reader. Here we'll just follow along with the text and pick a few points.

We computed and inspected these 95% intervals, above. Here's another way we might `stat_halfeye()` to look at their entire densities.

```r
draws %>%
  pivot_longer(starts_with("indirect")) %>%
  rename(`conditional indirect effect` = value) %>%
  mutate(W = str_remove(name, "indirect effect when W is ") %>% as.double()) %>%

  ggplot(aes(x = W, y = `conditional indirect effect`, fill = W %>% as.character())) +
  geom_hline(yintercept = 0, linetype = 2) +
  stat_halfeye(point_interval = median_qi, .width = 0.95) +
  scale_fill_brewer() +
  scale_x_continuous(breaks = c(1.592, 2.8, 5.2),
                     labels = c(1.6, 2.8, 5.2)) +
  coord_cartesian(ylim = c(-1, 1)) +
  theme(legend.position = "none",
        panel.grid.minor.y = element_blank())
```

### Pruning the model.

Fitting the model without the interaction term is just a small change to one of our `formula` arguments.

```r
model12.5 <- brm(
  data = disaster,
  family = gaussian,
  bf(justify ~ 1 + frame + skeptic + frame:skeptic) +
    bf(donate ~ 1 + frame + justify + skeptic) +
    set_rescor(FALSE),
  chains = 4, cores = 4,
  file = "fits/model12.05")
```

Here are the results.

```r
print(model12.5, digits = 3)
```

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
##          donate ~ 1 + frame + justify + skeptic
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##                       Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## justify_Intercept        2.453     0.149    2.153    2.743 1.000     2756     2735
## donate_Intercept         7.256     0.224    6.822    7.696 1.001     5662     3546
## justify_frame           -0.565     0.216   -0.998   -0.142 1.002     2411     2901
## justify_skeptic          0.105     0.038    0.031    0.180 1.000     2723     2672
## justify_frame:skeptic    0.201     0.054    0.098    0.307 1.002     2278     2474
## donate_frame             0.211     0.139   -0.062    0.484 1.001     4396     2667
## donate_justify          -0.918     0.080   -1.072   -0.762 1.001     4079     2733
## donate_skeptic          -0.036     0.037   -0.109    0.034 1.000     4244     3037
##
## Family Specific Parameters:
##               Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma_justify    0.817     0.040    0.740    0.905 1.002     4734     3006
## sigma_donate     0.985     0.049    0.894    1.087 1.001     4905     2826
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

Since we're altering the model, we may as well use information criteria to compare the two versions.

```r
model12.4 <- add_criterion(model12.4, criterion = "loo")
model12.5 <- add_criterion(model12.5, criterion = "loo")

loo_compare(model12.4, model12.5) %>%
  print(simplify = F)
```

```
##           elpd_diff se_diff elpd_loo se_elpd_loo p_loo  se_p_loo looic  se_looic
## model12.5    0.0       0.0  -557.7     16.6        11.0    1.3   1115.4   33.2
## model12.4   -1.0       0.3  -558.7     16.6        12.0    1.5   1117.4   33.3
```

The difference in LOO-CV values for the two models was modest. There's little predictive reason to choose one over the other. You could argue in favor of `model12.5` because it's simpler than `model12.4`. Since we've got a complex model either way, one might also consider which one was of primary theoretical interest.

## Mediated moderation

> Mediation is moderated if the indirect effect of $X$ on $Y$ through one or more mediators is contingent on a moderator. With evidence of moderated mediation, one can claim that the $X \rightarrow M \rightarrow Y$ chain of events functions differently or to varying degrees for different people, in different contexts or conditions, or whatever the moderator variable represents. Although similar in name and pronunciation to moderated mediation, the term *mediated moderation* refers to the phenomenon in which an interaction between $X$ and a moderator $W$ in a model of $Y$ is carried through a mediator. (p. 459, *emphasis* in the original)

Hayes later opined:

> Although there is an abundance of published examples of mediated moderation analysis, their frequency of occurrence in the literature should not be confused with meaningfulness of the procedure itself. I will argue toward the end of this section that rarely is the phenomenon of mediated moderation interesting when interpreted as such. It is almost always substantively more meaningful to conceptualize a mediated moderation process in terms of moderated mediation. But before doing this, I will describe how a mediated moderation analysis is undertaken. (p. 460)

### Mediated moderation as the indirect effect of a product.

Hayes explains this in the next subsection, but we've already fit this model presented in this subsection. We called it `model12.4`. Here's the summary.

```r
print(model12.4, digits = 3)
```

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
##          donate ~ 1 + frame + justify + skeptic + frame:skeptic
##    Data: disaster (Number of observations: 211)
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
##
## Population-Level Effects:
##                       Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## justify_Intercept        2.453     0.149    2.166    2.746 1.000     3521     3162
## donate_Intercept         7.297     0.266    6.779    7.821 1.000     3780     3222
## justify_frame           -0.565     0.219   -1.001   -0.122 1.000     3289     2664
## justify_skeptic          0.105     0.038    0.029    0.178 1.000     3660     3216
## justify_frame:skeptic    0.201     0.055    0.090    0.308 1.000     3335     2809
## donate_frame             0.156     0.263   -0.357    0.671 1.002     3344     3217
## donate_justify          -0.923     0.083   -1.085   -0.756 1.001     4128     2837
## donate_skeptic          -0.044     0.047   -0.139    0.049 1.001     3737     3006
## donate_frame:skeptic     0.017     0.067   -0.115    0.149 1.002     3194     2802
##
## Family Specific Parameters:
##               Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma_justify    0.817     0.040    0.741    0.900 1.001     5063     2902
## sigma_donate     0.989     0.050    0.898    1.095 1.000     5217     2370
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
```

### Why mediated moderation is neither interesting nor meaningful.

Mediated moderation and moderated mediation are statistically the same.

> The only difference between them is how they are interpreted, and on what part of the model your attention is focused.
>
> Moderated mediation focuses on the conditional nature of an indirect effect--how an indirect effect is moderated. If you think of the terms "mediation" and "indirect effect" as essentially synonymous conceptually, then moderated mediation means a moderated indirect effect. Interpretive focus in a moderated mediation analysis is directed at estimating the indirect effect and how that effect varies as a function of a moderator. Mediated moderation, by contrast, asks about the mechanism through which an interaction between $X$ and a moderator $W$ operates, where the product of $X$ and $W$ is construed as the causal agent sending its effect to $Y$ through $M$. Focus in mediated moderation is the estimation of the indirect effect of the product of $X$ and $W$. (p. 465)

Hayes later concluded that we should avoid

> the articulation of hypotheses or research questions in terms of the mediation of the effect of a product, abandoning the term *mediated moderation* entirely, and instead [reframe] such hypotheses and research questions in terms of the contingencies of an indirect effect--moderated mediation. (p. 467, *emphasis* in the original)

## Session info {-}

```r
sessionInfo()
```

```
## R version 4.2.2 (2022-10-31)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
##
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base
##
## other attached packages:
##  [1] tidybayes_3.0.2 brms_2.18.0     Rcpp_1.0.9      forcats_0.5.1   stringr_1.4.1   dplyr_1.0.10
##  [7] purrr_1.0.1     readr_2.1.2     tidyr_1.2.1     tibble_3.1.8    ggplot2_3.4.0   tidyverse_1.3.2
##
## loaded via a namespace (and not attached):
##   [1] readxl_1.4.1         backports_1.4.1      plyr_1.8.7           igraph_1.3.4         svUnit_1.0.6
##   [6] splines_4.2.2        crosstalk_1.2.0      TH.data_1.1-1        rstantools_2.2.0     inline_0.3.19
##  [11] digest_0.6.31        htmltools_0.5.3      fansi_1.0.3          magrittr_2.0.3       checkmate_2.1.0
##  [16] googlesheets4_1.0.1  tzdb_0.3.0           modelr_0.1.8         RcppParallel_5.1.5   matrixStats_0.63.0
##  [21] vroom_1.5.7          xts_0.12.1           sandwich_3.0-2       prettyunits_1.1.1    colorspace_2.0-3
##  [26] rvest_1.0.2          ggdist_3.2.1         haven_2.5.1          xfun_0.35            callr_3.7.3
##  [31] crayon_1.5.2         jsonlite_1.8.4       lme4_1.1-31          survival_3.4-0       zoo_1.8-10
##  [36] glue_1.6.2           gtable_0.3.1         gargle_1.2.0         emmeans_1.8.0        distributional_0.3.1
##  [41] pkgbuild_1.3.1       rstan_2.21.8         abind_1.4-5          scales_1.2.1         mvtnorm_1.1-3
##  [46] DBI_1.1.3            miniUI_<IP_ADDRESS>       xtable_1.8-4         bit_4.0.4            stats4_4.2.2
##  [51] StanHeaders_2.21.0-7 DT_0.24              htmlwidgets_1.5.4    httr_1.4.4           threejs_0.3.3
##  [56] RColorBrewer_1.1-3   arrayhelpers_1.1-0   posterior_1.3.1      ellipsis_0.3.2       pkgconfig_2.0.3
##  [61] loo_2.5.1            farver_2.1.1         sass_0.4.2           dbplyr_2.2.1         utf8_1.2.2
##  [66] labeling_0.4.2       tidyselect_1.2.0     rlang_1.0.6          reshape2_1.4.4       later_1.3.0
##  [71] munsell_0.5.0        cellranger_1.1.0     tools_4.2.2          cachem_1.0.6         cli_3.6.0
##  [76] generics_0.1.3       broom_1.0.2          evaluate_0.18        fastmap_1.1.0        processx_3.8.0
##  [81] knitr_1.40           bit64_4.0.5          fs_1.5.2             nlme_3.1-160         mime_0.12
##  [86] projpred_2.2.1       xml2_1.3.3           compiler_4.2.2       bayesplot_1.10.0     shinythemes_1.2.0
##  [91] rstudioapi_0.13      gamm4_0.2-6          reprex_2.0.2         bslib_0.4.0          stringi_1.7.8
##  [96] highr_0.9            ps_1.7.2             Brobdingnag_1.2-8    lattice_0.20-45      Matrix_1.5-1
## [101] nloptr_2.0.3         markdown_1.1         shinyjs_2.1.0        tensorA_0.36.2       vctrs_0.5.1
## [106] pillar_1.8.1         lifecycle_1.0.3      jquerylib_0.1.4      bridgesampling_1.1-2 estimability_1.4.1
## [111] cowplot_1.1.1        httpuv_1.6.5         R6_2.5.1             bookdown_0.28        promises_<IP_ADDRESS>
## [116] gridExtra_2.3        codetools_0.2-18     boot_1.3-28          colourpicker_1.1.1   MASS_7.3-58.1
## [121] gtools_3.9.4         assertthat_0.2.1     withr_2.5.0          shinystan_2.6.0      multcomp_1.4-20
## [126] mgcv_1.8-41          parallel_4.2.2       hms_1.1.1            grid_4.2.2           minqa_1.2.5
## [131] coda_0.19-4          rmarkdown_2.16       googledrive_2.0.0    shiny_1.7.2          lubridate_1.8.0
## [136] base64enc_0.1-3      dygraphs_<IP_ADDRESS>
```


text:
Logger
-------

Simple logger class to log info and errors. It uses apple's latesting logging classes (`os.log`)

**Note:** here you can find a better logger: https://github.com/illescasDaniel/BetterLogger

### Examples:
```swift
Logger.log("Value not good, bro", type: .error)
```
```swift
Logger.log("Couldn't load that request, oops :P", type: .error, category: .network)
```

license: MIT

repository: illescasDaniel/Logger

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: illescasDaniel/Logger


text:
throttle-callback
=======
[![total downloads of throttle-callback](https://img.shields.io/npm/dt/throttle-callback.svg)](https://www.npmjs.com/package/throttle-callback)
[![throttle-callback's License](https://img.shields.io/npm/l/throttle-callback.svg)](https://www.npmjs.com/package/throttle-callback)
[![latest version of throttle-callback](https://img.shields.io/npm/v/throttle-callback.svg)](https://www.npmjs.com/package/throttle-callback)

*Throttle a callback*

```js
const throttleCallback = require('throttle-callback')
const callback = throttleCallback(
    arg => console.log(arg),
    10 // Milliseconds
)
callback('One')
callback('Two')
callback('Three')

// Three
```

repository: kakserpom/throttle-callback

repo_name: kakserpom/throttle-callback


text:
## General

### Dates and location

ngVikings 2019 will take place on the 27-28th of May in Copenhagen, Denmark.

### Stay Informed

To stay up to date on the latest information on sessions, speakers, and activities, be sure to visit the [ngVikings website](https://ngvikings.org/), and follow us on [Facebook](https://www.facebook.com/ngVikingsConf) and [Twitter](https://twitter.com/ngVikingsConf). You can also follow and join the social conversation about ngVikings via official hashtag #ngvikings. In addition, we'll be emailing important information to all registered attendees, along with check-in instructions prior to the conference.

### Content Formats

During two conference days attendees will be able to attend sessions, chat with experts and attendees at coffee breaks and after party, and more.

### Livestream & Recordings

If you’re unable to attend ngVikings in-person, you can still be part of the magic. All the lectures from the sessions will be available for free on ngVikings [youtube channel](https://www.youtube.com/ngVikingsConf) few weeks after the conference. Workshops won’t be recorded.

## Registration

### Registration Terms & Conditions

- Tickets for ngVikings are for the full two-day conference and no single-day tickets are available.
- You may buy a ticket on behalf of the other person (for example, make a gift). Just mention during purchase the name, company and title of the person who will attend the event.
- ngVikings tickets must be used by the original registrant and are non-transferable.
- By registering and accepting any discounts, gifts, or items of value related to ngVikings, you certify that you are able to do so in compliance with applicable laws and the internal rules of your organization.
- At check-in, we’ll check your ticket prior to assigning you your ngVikings badge. If you don’t have proper identification, you won’t be able to receive a badge and won’t be admitted to the conference.
- If you buy an Student ticket and can't provide academic documentation during check-in at ngVikings, you won't be admitted or offered a refund, nor will you be able to convert your ticket to general admission. Please be sure to bring a current student ID or other proof that you are qualified to receive this special rate when you check in at the conference.
- All ticket sales are final. There will be no refunds or exchanges regardless of weather conditions, session availability, or any other circumstance.
- Attendees aren’t permitted to bring guests to ngVikings or to the after hours party. If you have someone traveling with you, they’ll need to register themselves and purchase an attendee ticket.
- Photographs and/or video taken at ngVikings by ngVikings Crew, or others on behalf of the conference organizers, may include your image or likeness. You agree that ngVikings Team may use such photographs and/or video for any purpose without any compensation to you.
- All information entered into the registration form must be correct and accurate to the best of your knowledge. All information expected to be entered in English. Some of the information entered (such as name, company and title), will be displayed on the attendee badge.
- By registering for a ticket you acknowledge that your information will be used in accordance with [Tickets provider Privacy Policy](https://ti.to/privacy?account_id=ngvikings&event_id=2019).
- All registered attendees agree to allow ngVikings Team to contact them regarding their registration and attendance at the event. By registering for a ticket, you agree to allow ngVikings Team to communicate with you via email with information regarding the event.
- You agree to be solely responsible for your own safety, belongings and well-being while participating in ngVikings. Organizers won't be liable for your participation in ngVikings.
- Applicants and attendees can request the deletion of their registration data after the event ends by emailing [contact@ngvikings.org](mailto:contact@ngvikings.org).

### Student Tickets

We offer a limited number of tickets for full-time students. To qualify, you need to be a student at a higher education institution. Be aware that PhD students are not in the list. Once purchased, general admission tickets can't be converted to Student tickets, and vice versa.

When you check in at the conference, you'll need to provide a current student ID (active during the conference dates), transcript, credential, or other form of documentation which demonstrates that you’re qualified to receive this special rate. If you buy an academic ticket and can't provide academic documentation when you arrive at ngVikings, you won't be admitted or offered a refund, nor will you be able to convert your ticket to general admission.

### More Registration Details

- Please make sure to register using the name that matches the government-issued photo ID you’ll be presenting when you check in to the event.
- Registration for ngVikings includes two full days of sessions, product demos, admission to the after hours party, and attendance at the keynotes. We also provide complimentary snacks each day. In addition, attendees receive a conference badge and may be offered additional gifts.
- If you aren’t a resident of Denmark, you should check with your local government to determine the required documents and arrangements needed for your travel to Denmark. If you require a visa letter regarding your ngVikings attendance please indicate so when completing the registration form and we’ll email it to you within 7 business days. If you haven’t received your letter or have questions regarding the process, you can contact [contact@ngvikings.org](mailto:contact@ngvikings.org). ngVikings Team won’t be able to contact an embassy on your behalf.

## Attendance Details

### Language

All presentations at ngVikings will be in English.

### Badges & Badge Pick-up

Make sure to bring your government-issued photo ID, as we’ll need to verify it prior to assigning you your ngVikings badge. If you don’t have proper identification, you won’t be able to receive a badge and won’t be admitted to the conference.

Please note, you may not share, give, or otherwise provide your badge to anyone. ngVikings badges aren’t replaceable, so don't lose yours or you won’t be readmitted to the conference. You must wear your ngVikings badge to gain admission to the conference, including the sessions, workshops, and afterparty. If requested by security, please display or provide additional identification. ngVikings badges may include your name, company or work title (if provided).

### Afterparty

All registered attendees are invited to the afterparty on the evenings of May 27th. The conference badges will be required for entry. Please join us for food, drinks, music, games, and more. Alcoholic beverages will be available for those 18 and over.

### Event Attire

ngVikings is a developer event, so please be comfortable and casual. There is no enforced dress code.

### Smoking

Smoking is only permitted in designated outdoor smoking areas.

### No Soliciting

No solicitation or selling of items or services is allowed at ngVikings. Any attendee conducting these activities may be removed from the conference.

gha_language: HTML

gha_license_id: NOASSERTION


text:
Flickr Shapefiles Geocoder
==========================

A Java reverse geocoder that uses [Geotools](http://www.geotools.org/) and [JTS](http://tsusiatsoftware.net/jts/main.html) to index [Flickr Shapefiles](http://code.flickr.com/blog/2011/01/08/flickr-shapefiles-public-dataset-2-0/) to map (latitude, longitude) to [WOEID](http://en.wikipedia.org/wiki/WOEID).

The code has no external server dependencies and runs in memory. You may have to specify a larger max heap size if you use the largest files (e.g. the localities dataset uses around 450Mb on my Mac).

ESRI Shapefiles for the Flickr dataset are included in the repository. They were converted from Flickr GeoJSON using [ogr2ogr](http://www.gdal.org/ogr2ogr.html). The original files were released under a [Creative Commons Zero Waiver](http://creativecommons.org/publicdomain/zero/1.0/), and so are these data files.

A Procfile and basic servlet are included so that the reverse geocoder can be run on Heroku.

Running the servlet
===================

Build the package with maven:

$ mvn package

And run on port 5000 like this:

$ PORT=5000 java -Xmx384m -cp 'target/classes:target/dependency/*' com.hackdiary.geo.FlickrGeocodeServlet src/main/resources/com/hackdiary/geo/zillow/ZillowNeighborhoods-CA.shp

You can add as many shapefiles as you like to the commandline argument and they will all be loaded.

Use the servlet with URLs such as:

http://localhost:5000/?lat=37.783333&lng=-122.416667

Software License
================

> Copyright (c) 2012 Matt Biddulph
>
> Permission is hereby granted, free of charge, to any person
> obtaining a copy of this software and associated documentation
> files (the "Software"), to deal in the Software without
> restriction, including without limitation the rights to use,
> copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the
> Software is furnished to do so, subject to the following
> conditions:
>
> The above copyright notice and this permission notice shall be
> included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER DEALINGS IN THE SOFTWARE.

repository: mattb/flickrgeocoder-java

gha_language: Java

repo_name: mattb/flickrgeocoder-java


text:
# Application Insights & Telemetry

## Rest API

You can study Application Insights [Bond schemas](https://microsoft.github.io/bond/)
for more
[details](https://github.com/microsoft/ApplicationInsights-Home/tree/master/EndpointSpecs/Schemas/Bond)
and
[endpoint protocol](https://github.com/microsoft/ApplicationInsights-Home/blob/master/EndpointSpecs/ENDPOINT-PROTOCOL.md)
but below are some examples that make it more concrete.

**Note**: Get yourself [Visual Studio Code](https://code.visualstudio.com/)
and [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension and save
below snippet to e.g. `AppInsights.http`. Then you can more easily
test those APIs by pressing "Send Request":

![Send Request in rest client](https://user-images.githubusercontent.com/2357647/80068327-17b37d80-8548-11ea-8995-832c9e830c53.png)

```rest
@endpoint = https://dc.services.visualstudio.com/v2/track
@ikey = your_intrumentation_key_from_azure_portal
@roleInstance = myserver
@sdk = mydemo:1.0.0

### Post single event:
# Matching .NET code:
#   var client = new TelemetryClient
#   {
#     InstrumentationKey = "key"
#   };
#   client.TrackEvent("PageView");
POST {{endpoint}} HTTP/1.1
Content-Type: application/json

{
  "name": "Event",
  "time": "{{$datetime iso8601}}",
  "iKey": "{{ikey}}",
  "tags": {
    "ai.cloud.roleInstance": "{{roleInstance}}",
    "ai.internal.sdkVersion": "{{sdk}}"
  },
  "data": {
    "baseType": "EventData",
    "baseData": {
      "ver":2,
      "name": "PageView"
    }
  }
}

### Post single event with additional properties:
# Matching .NET code:
#   client.TrackEvent("PageView",
#     new Dictionary<string, string>()
#     {
#       { "Server", "ABC123" },
#       { "Service", "SVC12345" }
#     });
POST {{endpoint}} HTTP/1.1
Content-Type: application/json

{
  "name": "Event",
  "time": "{{$datetime iso8601}}",
  "iKey": "{{ikey}}",
  "tags": {
    "ai.cloud.roleInstance": "{{roleInstance}}",
    "ai.internal.sdkVersion": "{{sdk}}"
  },
  "data": {
    "baseType": "EventData",
    "baseData": {
      "ver":2,
      "name": "PageView",
      "properties": {
        "Server": "ABC123",
        "Service": "SVC12345"
      }
    }
  }
}

### Post single event with additional properties and metrics:
# Matching .NET code:
#   client.TrackEvent("PageView",
#     new Dictionary<string, string>()
#     {
#       { "Server", "ABC123" },
#       { "Service", "SVC12345" }
#     },
#     new Dictionary<string, double>()
#     {
#       { "Level", level }
#     });
POST {{endpoint}} HTTP/1.1
Content-Type: application/json

{
  "name": "Event",
  "time": "{{$datetime iso8601}}",
  "iKey": "{{ikey}}",
  "tags": {
    "ai.cloud.roleInstance": "{{roleInstance}}",
    "ai.internal.sdkVersion": "{{sdk}}"
  },
  "data": {
    "baseType": "EventData",
    "baseData": {
      "ver":2,
      "name": "PageView",
      "properties": {
        "Server": "ABC123",
        "Service": "SVC12345"
      },
      "measurements": {
        "Level": 62.49
      }
    }
  }
}

### Post single exception with properties:
# Matching .NET code:
#   var ex = new ContosoRetailBackendException(
#    "Retail SBT Backend is not responding. " +
#    "Please follow these instructions next: " +
#    "https://bit.ly/ContosoITRetailSBTBackend");
#   client.TrackException(ex, new Dictionary<string, string>()
#   {
#     { "DataKey", "ABCDEF" },
#     { "NodeKey", "1234567890" }
#   });
POST {{endpoint}} HTTP/1.1
Content-Type: application/json

{
  "name": "Exception",
  "time": "{{$datetime iso8601}}",
  "iKey": "{{ikey}}",
  "tags": {
    "ai.cloud.roleInstance": "{{roleInstance}}",
    "ai.internal.sdkVersion": "{{sdk}}"
  },
  "data": {
    "baseType": "ExceptionData",
    "baseData": {
      "ver":2,
      "exceptions":
      [
        {
          "id": 9799115,
          "outerId":0,
          "typeName": "ContosoRetailBackendException",
          "message": "Retail SBT Backend is not responding. Please follow these instructions next: https://bit.ly/ContosoITRetailSBTBackend",
          "hasFullStack": true
        }
      ],
      "properties": {
        "DataKey": "ABCDEF",
        "NodeKey": "1234567890"
      }
    }
  }
}

### Post multiple events using line-delimited json:
# Matching .NET code:
#   client.TrackEvent("PageView");
#   client.TrackEvent("PageView");
#   client.TrackEvent("PageView");
#   client.Flush();
POST {{endpoint}} HTTP/1.1
Content-Type: x-json-stream

{"name":"Event","time":"{{$datetime iso8601}}","iKey":"{{ikey}}","tags":{"ai.cloud.roleInstance":"{{roleInstance}}","ai.internal.sdkVersion":"{{sdk}}"},"data":{"baseType":"EventData","baseData":{"ver":2,"name":"PageView"}}}
{"name":"Event","time":"{{$datetime iso8601}}","iKey":"{{ikey}}","tags":{"ai.cloud.roleInstance":"{{roleInstance}}","ai.internal.sdkVersion":"{{sdk}}"},"data":{"baseType":"EventData","baseData":{"ver":2,"name":"PageView"}}}
{"name":"Event","time":"{{$datetime iso8601}}","iKey":"{{ikey}}","tags":{"ai.cloud.roleInstance":"{{roleInstance}}","ai.internal.sdkVersion":"{{sdk}}"},"data":{"baseType":"EventData","baseData":{"ver":2,"name":"PageView"}}}
```

## How can I pass additional information to Ops or Support teams in case of failure?

Scenario: In your application code you have hard dependency
to some other 3rd party service. If that fails you want to pass as much
additional information to the Ops or Support teams as you can so that they can
act accordingly (or similar scenario when you want to pass some guidance forward).

Here is one example solution. It has following parts:

1. Custom exception for this scenario.
2. Use `TelemetryClient` for reporting this exception with additional instructions
3. Use `KQL` in Azure to find exception
4. Create necessary alerts based on selected queries

### Step 1: Custom exception

Here simple custom exception `ContosoRetailBackendException`:

```csharp
using System;
using System.Runtime.Serialization;

[Serializable]
public class ContosoRetailBackendException : Exception
{
    public ContosoRetailBackendException() { }
    public ContosoRetailBackendException(string message) : base(message) { }
    public ContosoRetailBackendException(
        string message, Exception inner) : base(message, inner) { }
    protected ContosoRetailBackendException(
        SerializationInfo info,
        StreamingContext context) : base(info, context) { }
}
```

### Step 2: Use custom exception with TelemetryClient

You can add as much additional information to the custom
exceptions as you like but one possible information
piece is link to additional instruction available for them
(of course your link can be internal SharePoint or anything like that.
It doesn't have to be public document):

```csharp
var ex = new ContosoRetailBackendException(
  "Retail SBT Backend is not responding. " +
  "Please follow these instructions next: " +
  "https://bit.ly/ContosoITRetailSBTBackend");

var client = new TelemetryClient();
client.TrackException(exception, new Dictionary<string, string>()
{
  { "DataKey", "ABCDEF" },
  { "NodeKey", "1234567890" }
});

client.Flush();
```

### Step 3: Find this data in App Insights

You can now find above exception using this query:

```sql
exceptions
| where type == "ContosoRetailBackendException"
```

You can directly see from data that all the additional data elements are part of the
log content **including the link**:
![ContosoRetailBackendException in log data](https://user-images.githubusercontent.com/2357647/76893966-e8995480-6895-11ea-8652-b8674eaa6fe3.png)

### Step 4: Create alerts

**TO BE ADDED** Step-by-step instructions.

In your alert email you'll also have the same data elements visible:

![alert email](https://user-images.githubusercontent.com/2357647/76894274-87be4c00-6896-11ea-94c8-0d5244294380.png)

This makes it easy for people to find correct troubleshooting
documents right from the alert notification.

**TO BE ADDED** User identity mapping, Exceptions with links, etc.


text:
mingw-w64 Toolchain Makefile
===

I use this thing to build a mingw-w64 cross compiler (on OSX usually).

* Put this into a `build` subdirectory.
* Get the requirements ready and unpacked: gcc, binutils, mingw-w64 (and deps)
* Fiddle with the vars to match your needs.
* `make` (parallel make is not supported)

If it helps: fine. If it doesn't, then you can either provide a pull request to
fix things, or shut up about it ;)


text:
---
layout: post
title: Devstack multinode with Puppet
date: 2014-12-11 18:57:39.000000000 +07:00
type: post
published: true
status: publish
categories:
- Tech
- News
tags:
- DevStack
meta:
  _edit_last: '61498925'
  _publicize_pending: '1'
  geo_public: '0'
author:
  login: vnstack
  email<EMAIL_ADDRESS>  display_name: vietstack
  first_name: Viet
  last_name: Stack
---

The following link will direct you how to install Devstack (stable/icehouse) multinode with the help of Puppet. Puppet is one of the most wonderful management and provision tool. By using puppet, it helps us to deploy a large system without repeated manipulation. Check it out!

Note: Get a coffee when you are waiting for everything done:)

Link github: https://github.com/vietstacker/devstack-multinode-puppet


text:
# No Script Component in Head

> Prevent usage of `next/script` in `next/head` component.

#### Why This Error Occurred

The `next/script` component should not be used in a `next/head` component.

#### Possible Ways to Fix It

Move the `<Script />` component outside of `<Head>` instead.

**Before**

```js
import Script from 'next/script'
import Head from 'next/head'

export default function Index() {
  return (
    <Head>
      <title>Next.js</title>
      <Script src="/my-script.js" />
    </Head>
  )
}
```

**After**

```js
import Script from 'next/script'
import Head from 'next/head'

export default function Index() {
  return (
    <>
      <Head>
        <title>Next.js</title>
      </Head>
      <Script src="/my-script.js" />
    </>
  )
}
```

### Useful links

- [next/head](https://nextjs.org/docs/api-reference/next/head)
- [next/script](https://nextjs.org/docs/basic-features/script#usage)

branch_name: refs/heads/canary

gha_license_id: MIT


text:
---
layout: post
title: DeathSpank
tags: [video games, old blog]
keywords: [deathspank, ps3]
image: /images/video-games/deathspank.jpg
---

To my loyal fan, who's out there… somewhere.. Sorry I haven't posted in ten days. I've been busy with school, plus I've been a bit under the weather (that's sick, for those who don't know their idioms).

Of course, I've had time to play my video games :) In addition to [Bejeweled Blitz on Facebook](https://hendrixjoseph.github.io/bejeweled-blitz-on-facebook/) I've been playing DeathSpank on the PS3:

![DeathSpank](/images/video-games/deathspank.jpg)
*DeathSpank*

It's a fun little game (was a DLC)  that's put together quite well by the same mind as Monkey Island, Ron Gilbert. The main point of this game is to save some orphans from the King of the realm, Lord Von Prong. It is a silly game with a lot on in-jokes. You'll probably laugh at the silliness a lot (even after you're "Felt by Freen.")

Anyways, pick it up and enjoy it. It's available as a DLC for PS3, I think so too for Xbox, and for Windows.

There's a second part too, which I haven't played yet. It's supposed to be more "modern," that is, with guns and other "high tech" weapons. I'll be checking it out once I beat this one.

links:
* [DeathSpank (Wikipedia)](http://en.wikipedia.org/wiki/DeathSpank)
* [Ron Gilber's webpage](http://grumpygamer.com/main)

Until next time

Joe


text:
# Someone's privileged Mattermost scripts.
+ Copyright (c) 2016-2021 by Someone<EMAIL_ADDRESS>(aka. Jan Vales<EMAIL_ADDRESS>+ published under MIT-License
+ These scripts need DB- and Filesystem-access.

Beware: These scripts run regularily and are well tested. BUT by using these scripts, MM inc. may refuse to help you, if you run into (unrelated) issues with your MM.

It all started with me starting to write my own DB+FS cleaner, after posting this: [https://mattermost.uservoice.com/forums/306457/suggestions/15357861](https://mattermost.uservoice.com/forums/306457/suggestions/15357861)
But eventually grew to include other scripts too.

consider running as cronjobs:

    00 23 * * *   (cd /srv/mattermost/mattermost-privileged; git pull --recurse-submodules=yes; git gc) &>/dev/null
    55 23 * * *   (cd /srv/mattermost/mattermost-privileged/maintenance; python3 -u db.py |tee /tmp/maintenance_db.log; python3 -u fs.py echo ""; du -sch /srv/mattermost/data/* | tail)
    59 11 * * MON (cd /srv/mattermost/mattermost-privileged/profile_badges; python3 -u main.py)
    0 0 * * 2-7   (cd /srv/mattermost/mattermost-privileged/stats; python3 -u main.py)
    0 0 * * MON   (cd /srv/mattermost/mattermost-privileged/stats; python3 -u main.py week)

## maintenance
+ permanently deletes {"deleted",orphaned,old,unused} MM-db data and unreferenced files.
+ fix db-health degrading issues MM has (had?).
+ enforce our system-policy (Can/must be enabled separately)
  + Deleting System-Spam messages and "Posts marked for deletion"
+ enforce our enhanced-system-policy (Can/must be enabled separately; Likely only makes sense for our instances)
  + Deleting inactive Channels + Users.

### **Beware: running this WILL break your instance's audit-trails. This IS intended behavior**

## profile_badges
+ Sets custom profile badges, needs DB access for post-count based badges.

## stats
+ various stats posted into channels.


text:
Installation of RPC-Designate
==============================
Table of Contents
=================
<!--ts-->
- [Installation of RPC-Designate](#installation-of-rpc-designate)
- [Table of Contents](#table-of-contents)
- [<!--te-->](#te)
- [Prerequisites](#prerequisites)
  - [Setup DNS Server](#setup-dns-server)
  - [Ports](#ports)
  - [RNDC Key File](#rndc-key-file)
    - [Ubuntu](#ubuntu)
    - [CentOS/RHEL](#centosrhel)
- [Configuration](#configuration)
    - [Name](#name)
    - [ns_records](#nsrecords)
    - [nameservers](#nameservers)
    - [targets](#targets)
<!--te-->
Installation
=============

The basic installation of Designate can be performed by running the scripts/deploy.sh script. The rest of the documentation remains for details on how to manually configure service. The deploy script will do the following:
- Detect what version of OpenStack you are running against
- Create containers for bind and for Designate on all infra hosts
- Deploy bind and configure for use with Designate
- Create a pool configuration "/etc/openstack_deploy/designate_pools.yml" to setup Designate to work with installed bind
- Deploy Designate using default configuration
- Configure firewall on infra hosts to allow communication to bind from infra IP address

Prerequisites
=============

Setup DNS Server
----------------
Designate has drivers to work with a number of different DNS back ends, the only that is supported by RPC currently is BIND9. You can either use a existing dns deployment or you can setup new DNS nodes to work with Designate.

The BIND9 configuration must have to following option defined to allow new zones to be created.

```
allow-new-zones yes;
```

To allow Designate to communicate with BIND, a rndc.key need to be created and configured for use.

```
include "/etc/bind/rndc.key";

controls {
  inet <listen address> port 953
    allow { <ip addresses of infra nodes> ; } keys {"rndc-key"; };
  inet <IP_ADDRESS> port 953
    allow { <IP_ADDRESS>; } keys {"rndc-key"; };
};
```

Ports
------
Designate need to have bi-directional communication between the infra nodes that are running the designate containers and the DNS servers.
1. Port 5354/udp needs to be open on the infra nodes to allow ingres traffic
   1. This port is used for the AXDRs from the DNS servers to the designate-mdns service
   1. DNS -> OpenStack Infra Nodes

1. The DNS servers need the following ports open
   1. 53/udp -> Open for all traffic for DNS resolution
   2. 53/tcp -> Open for all traffic for DNS resolution
   3. 953/tcp -> Used for rndc commands, this only needs to be open to allow communications from the OpenStack Infra nodes
      1. OpenStack Infra nodes -> DNS

RNDC Key File
--------------
### Ubuntu
The bind9 package will generate a rndc.key file in the /etc/bind directory.
### CentOS/RHEL
The key file will need to be generated using rndc-confgen. This will create the key file and place it in the /etc directory.
```
# rndc-confgen -a
wrote key file "/etc/rndc.key"
```

They key file needs ot be copied to this location on the deployment host
```
/etc/openstack_deploy/rndc.key
```

Configuration
=============
Designate Pool

The deploy script assumes that the designate_pool.yml file is in the OpenStack deploy directory.
A [sample](doc/sample_designate_pool.yml) file has been included in the doc directory of this repository.

There are several section to this map:

### Name
```
    - name: default
    description: Default Pool
```

### ns_records
We need to list out the NS records for the zones we are hosting within this pool
```
   ns_records:
    - hostname: ns1-1.example.org.
      priority: 1
```
### nameservers
This section is where we list out all of the name server that we are testing against.
They are used to confirm that the zone changes have been made.
```
    nameservers:
    - host: <IP_ADDRESS>
      port: 53
```
### targets
The targets section is where you define the target name server that you will be performing actions against. There are several sections that we need to pay attention to. There will be one of these sections for each external DNS server that are being used.
The type will be bind9 as that is the only currently supported option for RPC
```
  targets:
    - type: bind9
      description: BIND9 Server 1
```
The masters section is where the DNS servers that have the primary zones are defined. Normally this would be the addresses of the infra nodes.
```
      masters:
        - host: <IP_ADDRESS>
          port: 5354
```
Under the options you define the IP address, port and rndc information for the external DNS servers.

```   options:
        host: <IP_ADDRESS>
        port: 53
        rndc_host: <IP_ADDRESS>
        rndc_port: 953
        rndc_key_file: /etc/designate/rndc.key
```


text:
# react-boilerplate

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/enbermudas/react-boilerplate.svg?branch=master)](https://travis-ci.com/enbermudas/react-boilerplate)
[![Coverage Status](https://coveralls.io/repos/github/enbermudas/react-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/enbermudas/react-boilerplate?branch=master)
[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)

React boilerplate made with love.

## :sparkles: Features

-   Tests with Jest
-   Continuous integration with Travis CI
-   Code coverage with Coveralls
-   ECMAScript 2015+ code compiling with Babel
-   Linting with eslint, prettier and Airbnb style guide
-   Static type checking with Flow
-   Build with webpack

repository: codacy-badger/react-boilerplate

repo_name: codacy-badger/react-boilerplate


text:
# Changelog

All notable changes to this project will be documented in this file.

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

[//]: # 'Valid sections: Added, Changed, Deprecated, Removed, Fixed, Security'

## [Unreleased]

## [1.1.0] - 2020-10-09

### Added

-   Ability to enable and disable individual ore types for calculation

## [1.0.0] - 2020-10-07

Initial push of EVE Echoes Industry Calculator

license: ISC

repository: nkamenar/EVE-Echoes-Industry-Calculator

repo_name: nkamenar/EVE-Echoes-Industry-Calculator


text:
---
layout:     post
title:      申请季纪事番外
subtitle:   【福利】2019 Summer 暑研信息
date:       2019-02-27
author:     Jiawen Wu
header-img: img/post-bg-2015.jpg
catalog: false
tags:
    - Phd申请路
---
<script type="text/javascript">
// 禁止右键菜单
document.oncontextmenu = function(){ return false; };
// 禁止文字选择
document.onselectstart = function(){ return false; };
// 禁止复制
document.oncopy = function(){ return false; };
// 禁止剪切
document.oncut = function(){ return false; };
// 禁止粘贴
document.onpaste = function(){ return false; };
</script>

之前的Lab会不定期发一些的RA/Intern Openings
在这里汇总一下！

## **The Berkeley Early Learning Lab**
Lab info:

    The Berkeley Early Learning Lab (BELL), under the direction of Dr. Fel Xu,
    is now accepting applications from highly motivated undergraduates and
    graduating seniors for our Summer Internship Program in 2019.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kyafqq1yj30u013l7eq.jpg)

To apply, please see http://babylab.berkeley.edu/summer-internship.
The application deadline is March 22, 2019 11:59p.m. PST.
If you have further questions about the program, please refer to our website (http://babylab.berkeley.edu) or contact us at bH1abberkeIey.edu.

## **NYU Summer Institute for Social and Personality Psychology**
Program Info：
http://spsp.org/events/summer-opportunities-for-students/sispp/2019

    The 2019 Summer Institute in Social and Personality Psychology will be held at
    the New York University. The two-week intensive summer experience will accept
    100 pre-doctoral students in social and personality psychology.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kyjyjx21j30mr0h6wj1.jpg)

## **The Developmental Cognitive Neuroscience Lab at Brown University**
Lab info：
Please visit http://research.clps.brown.edu/dcnl/

    The Developmental Cognitive Neuroscience Lab at Brown University, directed by
    Dr. Dima Amso, will be hiring a Lab Manager/Research Assistant beginning
    Summer 2019.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kynrhli9j30el07twg4.jpg)

## **Summer research internship in Learning Sciences - University of Pittsburgh**

Program info:

http://www.lrdc.pitt.edu/Diversity/internship/

    The Learning Research and Development Center (LRDC) at the University of
    Pittsburgh is seeking summer undergraduate interns to promote broader
    participation in training in the Learning Sciences. The internship program
    will run from May 20-June 30, 2019 and all participants are expected to be in
    residence for the entire program. Housing and a stipend will be provided. A
    limited number of travel supplements are available to fund student travel to
    and from Pittsburgh.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kzcm5h6lj30u012uti1.jpg)

## **Yale University Computation and Cognitive Development Lab Summer Internship**
Program info:
https://compdevlab.yale.edu/join.html

    The Computation and Cognitive Development Lab at Yale University is accepting
    applications for a paid summer internship that will run from June 3 - July 26,
    2019. Interns will work closely with graduate students in all aspects of the
    research process including study design, data collection and analyses. In fact,
    four of last year’s interns are co-authors on papers currently in the pipeline!
![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kzg5g4gcj30xp0gw79c.jpg)

## **The Family Involvement Lab at University of Maryland**
Lab info:

https://education.umd.edu/research-college/labs/family-involvement-laboratory

    The Family Involvement Lab at University of Maryland (Dr. Natasha Cabrera) is
    seeking a highly motivated and organized individual to be a fulltime project
    coordinator for the EveryDay Learning Study. This NSF-funded research project
    is looking at how 2- to 3-year-olds learn math through parent- child
    interactions at home and is a collaboration with New York University and
    University of Pittsburgh. We are hoping to have someone start ASAP.

    If you are interested in applying, please refer to the attached job posting
    for more details. In addition, please feel free to check out our lab website
    for more information about our research.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kxkmhwvhj30f50lun11.jpg)

## **Gopnik Cognitive Development and Learning Lab Summer Internship Program 2019-UC Berkley**

Program Info:
    The Gopnik Cognitive Development and Learning Lab at UC Berkeley is now
    accepting applications for their summer research assistant internship. Interns
    will gain experience working on multiple projects at all stages of the
    research process.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kzipf5f8j30jy09gabv.jpg)

Please refer to gopniklab.berkeley.edu (For Applying) for application instructions. The application deadline is Friday March 29 8:00 AM PST.

Please direct any questions to Teresa Garcia at<EMAIL_ADDRESS>
## **2019 Summer Internship - UC Berkeley Language and Cognitive Development Lab**

Lab info:
http://lcdlab.berkeley.edu/summer-internship/

    The Language and Cognitive Development Lab at UC Berkeley, under the direction
    of Prof. Mahesh Srinivasan, is accepting applications for their summer
    internship. The goal of this program is to provide a comprehensive, hands-on
    research experience to highly motivated students, while making valuable
    contributions to cognitive science.

![](https://raw.githubusercontent.com/BrokenCrayons/ImageBase/master/Images/006tKfTcly1g0kzkhioobj30ds0h9q76.jpg)

---
Deadlines of most posts are approaching!
Hurry up!
Fighting!

Wish u all a lovely future ^ - ^


text:
# pstmeval

This package contains a collection of helper functions for evaluating the accuracy of single-cell trajectory inference methods.
Currently, the functions are designed for linear trajectories only, but I plan on expanding this in the future.

You can install with `devtools::install_github("pknight24/pstmeval")`.


text:
![logo](art/scrollable_big_logo.png)

[![Maven Central](https://img.shields.io/maven-central/v/ru.noties/scrollable.svg)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22scrollable%22)

---

**Scrollable** is a library for an Android application to implement various scrolling technicks. It's all started with **scrolling tabs**, but now much more can be done with it. Scrollable supports all scrolling and non-scrolling views, including: **RecyclerView**, **ScrollView**, **ListView**, **WebView**, etc and any combination of those inside a **ViewPager**. Library is designed to let developer implement desired effect without imposing one solution. Library is small and has no dependencies.

## Preview

All GIFs here are taken from `sample` application module.

*Serving suggestion

## Installation
```groovy
compile 'ru.noties:scrollable:1.3.0'
```

## Usage

To start using this library `ScrollableLayout` must be aded to your layout.

```xml
<?xml version="1.0" encoding="utf-8"?>
<ru.noties.scrollable.ScrollableLayout
    android:id="@+id/scrollable_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:scrollable_autoMaxScroll="true"
    app:scrollable_defaultCloseUp="true">

    <ru.noties.scrollable.sample.SampleHeaderView
        style="@style/HeaderStyle"
        app:shv_title="@string/sample_title_fragment_pager"/>

    <ru.noties.scrollable.sample.TabsLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="@dimen/tabs_height"
        android:background="@color/md_teal_500"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="@dimen/tabs_height"/>

</ru.noties.scrollable.ScrollableLayout>
```

Please note, that `ScrollableLayout` positions its children like vertical `LinearLayout`, but measures them like a `FrameLayout`. It is crucial that scrolling content holder dimentions must be set to `match_parent` (minus possible *sticky* view that should be extracted from it, for example, by specifying `android:layoutMarginTop="height_of_sticky_view"`).

Next, `ScrollableLayout` must be initialized in code:

```java
final ScrollableLayout scrollableLayout = findView(R.id.scrollable_layout);

// this listener is absolute minimum that is required for `ScrollableLayout` to function
scrollableLayout.setCanScrollVerticallyDelegate(new CanScrollVerticallyDelegate() {
    @Override
    public boolean canScrollVertically(int direction) {
        // Obtain a View that is a scroll container (RecyclerView, ListView, ScrollView, WebView, etc)
        // and call its `canScrollVertically(int) method.
        // Please note, that if `ViewPager is used, currently displayed View must be obtained
        // because `ViewPager` doesn't delegate `canScrollVertically` method calls to it's children
        final View view = getCurrentView();
        return view.canScrollVertically(direction);
    }
});
```

### Draggable View

This is a View, that can be *dragged* to change `ScrollableLayout` scroll state. For example, to expand header if tabs are dragged. To add this simply call:
```java
// Please note that `tabsLayout` must be a child (direct or indirect) of a ScrollableLayout
scrollableLayout.setDraggableView(tabsLayout);
```

### OnScrollChangedListener

In order to apply custom logic for different scroll state of a `ScrollableLayout` `OnScrollChangedListener` can be used (to change color of a header, create parallax effect, sticky tabs, etc)

```java
scrollableLayout.addOnScrollChangedListener(new OnScrollChangedListener() {
    @Override
    public void onScrollChanged(int y, int oldY, int maxY) {

        // `ratio` of current scroll state (from 0.0 to 1.0)
        // 0.0 - means fully expanded
        // 1.0 - means fully collapsed
        final float ratio = (float) y / maxY;

        // for example, we can hide header, if we are collapsed
        // and show it when we are expanded (plus intermediate state)
        header.setAlpha(1.F - ratio);

        // to create a `sticky` effect for tabs this calculation can be used:
        final float tabsTranslationY;
        if (y < maxY) {
            // natural position
            tabsTranslationY = .0F;
        } else {
            // sticky position
            tabsTranslationY = y - maxY;
        }
        tabsLayout.setTranslationY(tabsTranslationY);
    }
});
```

### OnFlingOverListener

To *continue* a fling event for a scrolling container `OnFlingOverListener` can be used.

```java
scrollableLayout.setOnFlingOverListener(new OnFlingOverListener() {
    @Override
    public void onFlingOver(int y, long duration) {
        recyclerView.smoothScrollBy(0, y);
    }
});
```

### OverScrollListener

To create custom *overscroll* handler (for example, like in `SwipeRefreshLayout` for loading, or to zoom-in header when cannot scroll further) `OverScrollListener` can be used

```java
scrollableLayout.setOverScrollListener(new OverScrollListener() {
    @Override
    public void onOverScrolled(ScrollableLayout layout, int overScrollY) {

    }

    @Override
    public boolean hasOverScroll(ScrollableLayout layout, int overScrollY) {
        return false;
    }

    @Override
    public void onCancelled(ScrollableLayout layout) {

    }

    @Override
    public void clear() {

    }
});
```

`OverScrollListener` gives you full controll of overscrolling, but it implies a lot of handling. For a simple case `OverScrollListenerBase` can be used

```java
scrollableLayout.setOverScrollListener(new OverScrollListenerBase() {
    @Override
    protected void onRatioChanged(ScrollableLayout layout, float ratio) {

    }
});
```

For example, this is `onRatioChanged` method from `ZoomInHeaderOverScrollListener` from `sample` application:
```java
@Override
protected void onRatioChanged(ScrollableLayout layout, float ratio) {
    final float scale = 1.F + (.33F * ratio);
    mHeader.setScaleX(scale);
    mHeader.setScaleY(scale);

    final int headerHeight = mHeader.getHeight();
    mContent.setTranslationY(((headerHeight * scale) - headerHeight) / 2.F);
}
```

### Scrolling Header

There is support for scrolling header. This means that if header can scroll, it will scroll first to the final position and only after that scroll event will be redirected. There are no extra steps to enable this feature if scrolling header is the first view in `ScrollableLayout`. Otherwise a XML attribute `app:scrollable_scrollingHeaderId` can be used, it accepts an id of a view.

## Various customizations

### CloseUpAlgorithm

In order to *close-up* `ScrollableLayout` (do not leave in intermediate state, allow only two scrolling states: collapsed & expanded, etc), `CloseUpAlgorithm` can be used. Its signature is as follows:

```java
public interface CloseUpAlgorithm {

    int getFlingFinalY(ScrollableLayout layout, boolean isScrollingBottom, int nowY, int suggestedY, int maxY);

    int getIdleFinalY(ScrollableLayout layout, int nowY, int maxY);
}
```

And usage is like this:

```java
scrollableLayout.setCloseUpAlgorithm(new MyCloseUpAlgorithm());
```

Library provides a `DefaultCloseUpAlgorithm` for a most common usage (to allow `ScrollableLayout` only 2 scrolling states: collapsed and expanded). It can be set via java code: `scrollableLayout.setCloseUpAlgorithm(new DefaultCloseUpAlgorithm())`  and via XML with `app:scrollable_defaultCloseUp="true"`.

Also, there is an option to set duration after which CloseUpAlgorithm should be evaluated (idle state - no touch events). Java: `scrollableLayout.setConsiderIdleMillis(100L)` and XML: `app:scrollable_considerIdleMillis="100"`. `100L` is the default value and may be omitted.

If *close-up* need to have different animation times, `CloseUpIdleAnimationTime` can be used. Its signature:

```java
public interface CloseUpIdleAnimationTime {
    long compute(ScrollableLayout layout, int nowY, int endY, int maxY);
}
```
If animation time is constant (do not depend on current scroll state), `SimpleCloseUpIdleAnimationTime` can be used. Java: `scrollableLayout.setCloseUpIdleAnimationTime(new SimpleCloseUpIdleAnimationTime(200L))`, XML: `app:app:scrollable_closeUpAnimationMillis="200"`. `200L` is default value and can be omitted.

If one want to get control of `ValueAnimator` that is used to animate between scroll states, `CloseUpAnimatorConfigurator` can be used. Its signature:

```java
public interface CloseUpAnimatorConfigurator {
    // when called will already have a duration set
    void configure(ValueAnimator animator);
}
```

If only `Interpolator` must be configured, a `InterpolatorCloseUpAnimatorConfigurator` can be used. Java: `scrollableLayout.setCloseAnimatorConfigurator(new InterpolatorCloseUpAnimatorConfigurator(interpolator))`, XML: `app:scrollable_closeUpAnimatorInterpolator="app:scrollable_closeUpAnimatorInterpolator="@android:interpolator/decelerate_cubic"`

### Auto Max Scroll

If you layout has a header with dynamic height, or it's height should be obtained at runtime, there is an option to automatically obtain it. Java: `scrollableLayout.setAutoMaxScroll(true)`, XML: `app:scrollable_autoMaxScroll="true"`. With this option there is no need manually set `maxScrollY`. Please note, that if not specified explicitly this option will be set to `true` if `maxScroll` option is not set (equals `0`). Also, if at runtime called `scrollableLayout.setMaxScroll(int)`, `autoMaxScroll` if set to `true`, will be set to `false`.

By default the first View will be used to calculate height, but if different one must be used, there is an option to specify `id` of this view. XML: `app:scrollable_autoMaxScrollViewId="@id/header"`

### Disable Handling

If `ScrollableLayout` must not evaluate its scrolling logic (skip all touch events), `scrollableLayout.setSelfUpdateScroll(boolean)` can be used. Pass `true` to disable all handling, `false` to enable it.

### Animate Scroll

To animate scroll state of a `ScrollableLayout`, `animateScroll(int)` can be used:

```java
// returns ValueAnimator, that can be configured as desired
// `0` - expand fully
// `scrollableLayout.getMaxScroll()` - collapse
scrollableLayout.animateScroll(0)
        .setDuration(250L)
        .start();
```

Please note that `ScrollableLayout` caches returned `ValueAnimator` and reuses it. First of all because it doesn't make sense to have two different scrolling animations on one `ScrollableLayout`. So, it's advisable to clear all possible custom state before running animation (just like `View` handles `ViewPropertyAnimator`)

## License

```
  Copyright 2015 Dimitry Ivanov<EMAIL_ADDRESS>
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
```


text:
### Curriculum Vitae of Daniel Hübner

![Daniel Hübner](assets/images/daniel_huebner_2018.jpg)

---

#### Work experiance

idealo internet GmbH

  	2013 - now

  	Senior software developer, DevOps, Clean Coder and Craftperson

proventis GmbH

  	2007 - 2013

  	Software developer and Clean Coder

Jamba! GmbH

  	2007 - 2013

  	Junior software developer

---

#### Skills

- @color[#DC143C](Java 8): Advanced
- @color[#DC143C](Spring & Spring Boot): Advanced
- @color[#DC143C](MongoDB): Experienced
- @color[#DC143C](Apache Kafka / Kafka Streams): Experienced

---

#### Personal

- @color[#DC143C](Music): Listen and play
- @color[#DC143C](Painting): With pencil, crayon and brush
- @color[#DC143C](Family): Proud father and husband

---

#### Contact information

-<EMAIL_ADDRESS>- @DanielHuebner76
- LinkedIn & Xing

repository: huebnerdaniel/cv

repo_name: huebnerdaniel/cv


text:
---
title: Social distancing at RHS Wisley
date: '2020-07-05'
heroImage: './images/DSC_6080.jpg'
heroImagePosition: 'top center'
thumbnail: ./images/DSC_6097.jpg
featured: true
country: United Kingdom
region: Surrey
---

You might remember that we visited Wisley when the boy was a little babe in arms. Lockdown naturally prevented further visits, until July when the restrictions eased.

We booked our slot online a good few weeks in advance, and hoped for a warm sunny day. We weren't disappointed!

|                                                    |                                             |
| -------------------------------------------------- | ------------------------------------------- |
| ![Wisley Summer](./images/IMG_20200705_124506.jpg) | ![Wisley](./images/IMG_20200705_124719.jpg) |

![Wisley Summer](./images/IMG_20200705_124552.jpg)

This beautiful ruby acer was the perfect spot for a cheeky Mum and Dad selfie while the baby napped, and we planned our route round the garden.

![Wisley Summer](./images/DSC_6080.jpg)

|                                                    |                                  |
| -------------------------------------------------- | -------------------------------- |
| ![Wisley Summer](./images/IMG_20200705_125410.jpg) | ![Wisley](./images/DSC_6073.jpg) |

It was a shame to have missed spring in full bloom, but summer's flowers put on a stunning display. Accompanied by so many insects flitting around, lazily feasting and gorging on the nectar.

![Wisley Summer](./images/DSC_6057.jpg)

|                                         |                                  |
| --------------------------------------- | -------------------------------- |
| ![Wisley Summer](./images/DSC_6059.jpg) | ![Wisley](./images/DSC_6067.jpg) |

Now we're getting that bit older, we've been enjoying taking inspiration from the gardens we visit. We have one shady bed in our garden which we're slowly filling; seeing the candy pink astilbe happily in the shade of a large tree gave us a prompt to visit our local garden centre the next day!

![Wisley Summer](./images/DSC_6083.jpg)

|                                         |                                  |
| --------------------------------------- | -------------------------------- |
| ![Wisley Summer](./images/DSC_6097.jpg) | ![Wisley](./images/DSC_6128.jpg) |

The red admiral (above) and peacock (above left) were the most beautiful, pristine specimens. Is there anything more archetypally bucolic than a packed annual and perennial border, buzzing with bees and butterflies?

![Wisley Summer](./images/DSC_6131.jpg)

|                                                      |                                  |
| ---------------------------------------------------- | -------------------------------- |
| ![Wisley Summer](./images/MVIMG_20200705_142438.jpg) | ![Wisley](./images/DSC_6171.jpg) |

And finally, some pictures of our smiley, stripy boy loving family time and our outside adventure.

![Wisley Summer](./images/DSC_6178.jpg)

|                                         |                                  |
| --------------------------------------- | -------------------------------- |
| ![Wisley Summer](./images/DSC_6199.jpg) | ![Wisley](./images/DSC_6185.jpg) |

###The useful bits:###

- RHS Wisley is near Woking, Surrey, and is located just off the A3 (London to Portsmouth A-road).
- We drove to the Garden (parking is free), but public transport is possible. Plan your visit [here](https://www.rhs.org.uk/gardens/wisley/Plan-your-visit).
- If you do use public transport, your entry ticket is a discounted £12.
- Normal entry costs £16.50; we used our membership. Entry is strictly bookings only during this bizarre and unprecedented time - but it's a quick and easy process online.

gha_language: JavaScript


text:
# Employee Directory App

This project is centered on creating a site to help company admin see their team members and attributes of each team member. This is the first web app build using react.

![Employee Directory App](https://github.com/dancornutt/employee-directory/blob/main/assets/employee-directory.png)

## Getting Started

Luckily this is a static site so there isn't much set-up to do. knowledge of react is a must if anyone is planning on building out more functionality.
View the site here: [Employee Directory](https://dancornutt.github.io/employee-directory/)

### Prerequisites

You'll need to have a good text editor or IDE for making edits to the code. For this project VS Code was used and was very useful.
Below are the tools used for this site:
    * Text Editor
    * Git
    * Github account
    * React
    * React Bootstrap
    * Browser (Chrome was used for development)

### Installing

These are the installation steps to get the site up and running:

    * Log into Github
    * Fork this repo
    * Clone your Forked repo on your local machine
    * 'cd' one level down to employee-directory
    * Run 'npm i' in install dependencies
    * Navigate to root location and run 'npm run start'

## Running the tests

No tests were constructed, this is an area of opportunity for any one interested in collaborating.

## Deployment

This site is hosted via GitHub, using gh-pages. The build script is in the package.json file, it will create a 'build' folder with all production files needed for deployment.

## Built With

* [React](https://reactjs.org/) - Front end web framework used
* [Boostrap React](https://react-bootstrap.github.io/) - Front end component library
* [git](https://git-scm.com/) - Version control
* [GitHub](https://github.com/) - Used to store the code base
* [Chrome](https://www.google.com/chrome/) - Used as the browser

## Contributing

Anyone is welcome to contribute! Reach out via github for collaboration.

## Authors

* **Dan Cornutt** - *Complete work*

repository: dancornutt/employee-directory

branch_name: refs/heads/main

repo_name: dancornutt/employee-directory


text:
Golang client library for StockDB

# Example

[example](https://github.com/miaolz123/stockdb/tree/master/example/golang)

# Instllation

```shell
$ go get github.com/miaolz123/stockdb/stockdb
```

# Reference

[Official Repos](https://github.com/miaolz123/stockdb)

[Document](http://docs.stockdb.org/)


text:
# Sphinx Inline Tabs

![demo image](https://raw.githubusercontent.com/pradyunsg/sphinx-inline-tabs/main/docs/_static/demo.png)

<!-- start-include-here -->

Add inline tabbed content to your Sphinx documentation.

## Installation

This project is available on PyPI, and can be installed using pip:

```
pip install sphinx-inline-tabs
```

You'll also want to add the extension to `extensions` in `conf.py`:

```python
extensions = [
    ...,
    "sphinx_inline_tabs",
    ...,
]
```

## Features

- **Elegant design**: Small footprint in the markup and generated website, while looking good.
- **Configurable**: All the colors can be configured using CSS variables.
- **Synchronisation**: Tabs with the same label all switch with a single click.
- **Works without JavaScript**: JavaScript is not required for the basics, only for synchronisation.

<!-- end-include-here -->

## Contributing

sphinx-inline-tabs is a volunteer maintained open source project, and we welcome contributions of all forms. This is a fairly small package, and the development workflow is very similar to [Furo's development workflow](https://pradyunsg.me/furo/contributing/workflow/).

The [Code of Conduct](CODE_OF_CONDUCT.md) applies within all community spaces. If you are not familiar with our Code of Conduct policy, take a minute to read the policy before starting with your first contribution.

repository: astrojuanlu/sphinx-inline-tabs

repo_name: astrojuanlu/sphinx-inline-tabs


text:
# `use-form`

This is a custom hook to provide an easier way to manage form state in React.

# Props

## values: object

This prop serves a single purpose that is provide the initial values for the
fields in your form.

This object can have any specific structure, you need as long as you use the
proper name in your fields to map them to your resulting object.

**Example**

```js
const { values, dispatch } = useForm(
	{
		name: 'Jane Doe',
		children: [
			{
				name: 'Mary Poppins',
				age: 7,
			},
			{
				name: 'James Bond',
				age: 13,
			},
		],
	},
	schema
);
```

Then you can refer to these fields as follows:

```js
<input type="text" name="name" />

<input type="text" name="children.0.name" />

<input type="text" name="children.1.name" />
```

## schema?: object

With this object you will establish validation rules to be applied to the fields
in your form.

The names of your fields will act as keys and the value - a `string`, `array` or
`object` containing the rules to be applied on that field value
(`<fieldName>: <string>|<array>|<object>`).

The rules can be written as follows:

### - string

Here you will use a predefined validator.

This hooks comes wired with a series of validators and you can apply any of them
just providing its name.

Important to notice that you should a string typed rule whenever you validation
_does not_ required any additional arguments.

**Example**

```js
const schema = {{
  name: [
    'required'
  ]
}}
```

Currently we support the following predefined validators:

#### `permissive`

This is a fallback validator that returns `true` (which means 'valid') always.

#### `required`

This validator returns `true` if the field's value is nor `null` neither
`undefined`.

#### `string.blank`

This validator returns `true` if a trimmed version of the given string is not
empty (`null` or `undefined` included).

#### `string.empty`

Same as `string.blank`, except it does not check for `null` or `undefined`.

### - array

Here you will use a predefined validator with additional arguments.

**Example**

```js
const schema = {{
  name: [
    'required',
    ['string.length.range', 3, 15]
  ]
}}
```

Currently we support the following predefined validators:

#### `number.max`

Checks if the field value is less than or equals to the provided argument.

**Example**

```js
const schema = {{
  age: [
    ['number.max', 21]
  ]
}}
```

#### `number.min`

Checks if the field value is greater than or equals to the provided argument.

**Example**

```js
const schema = {{
  age: [
    ['number.min', 18]
  ]
}}
```

#### `number.range`

Checks if the field value is between the min/max range (inclusive).

**Example**

```js
const schema = {{
  age: [
    ['number.range', 18, 21]
  ]
}}
```

#### `string.length.max`

Checks if the string field value has length less than or equals to the provided
argument.

**Example**

```js
const schema = {{
  name: [
    ['string.length.max', 255]
  ]
}}
```

#### `string.length.min`

Checks if the string field value has length greater than or equals to the
provided argument.

**Example**

```js
const schema = {{
  name: [
    ['string.length.max', 255]
  ]
}}
```

#### `string.length.range`

Checks if the string field value has length between the min/max arguments.

**Example**

```js
const schema = {{
  name: [
    ['string.length.range', 3, 255]
  ]
}}
```

#### `string.length`

Checks if the string field value has length equals to the provided arguments.

**Example**

```js
const schema = {{
  name: [
    ['string.length.range', 3, 255]
  ]
}}
```

### - object

Allows you to write your own validator or to use additional options for a
predefined validator.

You can include the following options:

-   `validator` - function or promise that will perform your custom validation;
    the first parameter it will receive is the `values` object, which contains the
    current values for your fields, followed by any additional arguments you
    provide using `args`;
-   `args` - Aditional arguments to be provided to your `validator`;
-   `except`- function or promise that you can use to dinamycally prevent your
    custom validation from being run;
-   `name` - This is name for your custom validator, which will be used to
reference any error it returns. **If you use the name of an existing predefined
validator, your customized one will be mercilessly overriden**.
<!-- - on, -->

**Example**

```js
const myWeirdArg = 18;
const schema = {{
  list: [
    {
      name: 'my-custom-validator',
      validator: function({ age, list }, myWeirdArg) {
        if (age > myWeirdArg) {
          return list.length > 0;
        }

        return true;
      },
      args: [myWeirdArg],
      except: function({ age }) {
        return age > 65;
      }
    }
  ],
  age: 'required',
  name: 'required'
}}
```

## About design decisions

-   `useValidation` was created from the idea that changing a field value does not
    necessarily has to do with validation (you are supposed to run validation
    whenever you want/need). Besides that, being able to run asynchronous
    validation must not interfere with field maintenance and its result should not
    be managed as separate state (using `useState`) inside field set/reset
    reducer.

repository: cheesebit/ui

repo_name: cheesebit/ui