text:
# www.teknologforeningen.fi
Landing page for www.teknologforeningen.fi

## Development setup

### Otto on any platform

1. Install [otto](https://ottoproject.io/) and [VirtualBox](https://www.virtualbox.org/)
2. Clone this repository `git clone https://github.com/Teknologforeningen/www.teknologforeningen.fi.git`
3. In the project folder, run `otto compile`
4. Run ´otto dev´ this will start a virtual machine
5. Allow otto to install all of its dependencies
6. Make a note of the IP that the virtual machine is running on.
7. Log in to the virtual machine with `otto dev ssh`
	7b. Windows: Use Putty (or similar) to connect.
	7c. Write the IP in the Host Name field. Press enter.
	7d. Login: "vagrant" PW: "vagrant"
8. Run the PHP server with: `php -S <IP_ADDRESS>:5000`
9. The server is now running on port 5000 on the IP printed out in step 5

### MAMP on Mac OS X

1. Download MAMP https://www.mamp.info/en/downloads/
2. Install the .pkg file you downloaded (next, next, continue, etc.)
3. Open the MAMP application from Applications/MAMP/MAMP (the icon is a little elephant!)
4. Inside MAMP, go to *Preferences...*/*Web Server*
5. Select *Apache* and click the little folder icon to the right of "Document Root:". As "Document Root" you should choose the folder where your index.php file is located.
6. Done. Start the server from MAMP by clicking 'Start Servers'. :)

### XAMPP on Windows

1. Start by downloading and installing [XAMPP](https://www.apachefriends.org/index.html)
2. Open XAMPP Control Panel
3. Move the folder www.teknologforeningen.fi to C:\xampp\htdocs
4. Press "Start" on Apache-row
5. In case Xampp fails to run Apache, make sure Xampp isn't being stopped by your antivirus program and try rebooting your computer
6. If it starts successfully open your browser and type localhost/www.teknologforeningen.fi in the addressbar to check if it's up and running

### XAMPP on Arch Linux

1. Ladda ner nyaste XAMPP från https://www.apachefriends.org/
2. Kör vid behov chmod 755 xampp-linux-*-installer.run
3. sudo ./xampp-linux-*-installer.run
4. Lägg till din github-mapp till /opt/lampp/etc/httpd.conf, följ instruktioner på https://wiki.archlinux.org/index.php/Xampp
5. chmod o+x /väg/till/din/mapp/
6. Fungerar kanske? Om inte så hjälper StackExchange.

### TÄFFÄ API

TäffäAPI or as it is referred to in code, TaffaAPI is a class for easy
access to the taffa API located at http://api.teknolog.fi/taffa/

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
# AsplesSinatra
[![Gem Version](https://badge.fury.io/rb/asples_sinatra.svg)](https://badge.fury.io/rb/asples_sinatra) [ ![Codeship Status for asplespng/asples_sinatra](https://app.codeship.com/projects/e2e009d0-7dd8-0134-a415-22f53c89765f/status?branch=master)](https://app.codeship.com/projects/181509)

Helpers for basic Sinatra applications.
Currently a helper for generating bootstrap formatted input fields for ActiveRecord objects.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'asples_sinatra'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install asples_sinatra

## Usage
E.g. in your app.rb
```ruby
require 'asples_sinatra'
```

E.g. using haml
```ruby
@user = OpenStruct.new #could also be an active record object.
@user.errors = {name: ["An error has occured"]}
@user.name = "John Doe"

haml "= input :name, object: @user, label: 'Full name', placeholder: 'Enter your full name'"
```
This outputs

```html
<div class="form-group has-error">
  <label class="control-label" for="name">Full name:</label>
  <input class="form-control" name="name" placeholder="Enter your full name" type="text" value="John Doe">
  <span class="help-block">
    An error has occured
  </span>
</div>
```

To execute example app:

    $ ruby app.rb

## Development

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

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

## Contributing

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

## License

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

license: MIT

gha_language: Ruby


text:
SublimeText Transparent
=======================
`Package Name : Transparency`

Overview
--------
This simple plugin for Sublime Text 2 and Sublime Text 3 provides contextual menues and hotkeys to modify the application's opacity.

**This is only for SublimeText under Windows.**

Install
-------
You may install `SublimeTextTrans` via git with the below commands:

**Windows only**

**For Sublime Installed:**

    git clone https://github.com/vhanla/SublimeTextTrans.git "%APPDATA%\Sublime Text 2\Packages\SublimeTextTrans"

**Notice** that this location might change on each SublimeText version, _you can find the correct path by going to menu **Preferences - Browse Packages**_

**For Sublime as Portable:**

    git clone https://github.com/vhanla/SublimeTextTrans.git "C:\Sublime\Data\Packages\SublimeTextTrans""

*Where* ***C:\Sublime*** *is the portable's path. So change accordingly.*

You can also get it zipped from the [Releases](https://github.com/vhanla/SublimeTextTrans/releases) section.

Remember, this plugin must be inside its own directory within packages directory where you will unzip it.

**Alternative using Package Installer:**

    Ctrl+Shift+P - Install Package - Transparency

Usage:
-------
There are three methods to set transparency:

1. Visit `View > Window's Transparency` submenu to set the opacity
2. You can use the hotkeys `Ctrl+Shift+[1,2,3,4,5,6]`
3. Or you can right click and use the contextual menu

![](https://github.com/vhanla/SublimeTextTrans/raw/master/snapshot.png?raw=true)

Limitations:
------------
- Only 6 levels of transparency, [0 = invisible <-> 255 = solid] customizable on settings file.
- It requires another executable to change Sublime Text's window style mode to allow translucency.
However, you don't need to install it or launch manually, the plugin does it for you. Executable is only a `1024 bytes` and source code is included, which is in assembler language, hence that's why it is so small. Also, it is launched only once each time you start Sublime Text, and it closes itself after changing style, so no memory is used afterwards.

Changelog:
----------
[14-04-2018] v1.3

 - Modified `SetSublimeLayered.asm` to make it smaller and to avoid false positives (tested on [VirusTotal](https://www.virustotal.com/#/file/66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a/detection))

  These are `SetSublimeLayered.exe`hashes:

    - SHA-256	66b72c28f54728c6df3995b0ae026aa1aeeca96911d5b484673a502ec6592f2a
	- CRC32		54612762
    - MD5 		E113BDC6FA08BC054F7A89E7B24411BD
    - SHA-1 	376707D5579384B42586D0616BB03BBB993C6050

[15-24-2015] v1.2

 - Onload transparency (95% working due to ST API limitations)
 - Remember chosen transparency level
 - Support for user settings

[12-06-2013] v1.0

 - Added support for Sublime Text 3

Configuration:
--------------
To set custom transparency levels visit `Preferences > Package Settings > SublimeTextTrans > Settings - User`, it will open the user's custom preferences file for this plugin.

There you can modify the transparency levels, by adding the following and adjusting the levels as you wish:

    {

    	// If you like to have a different transparency level
    	// modify this array of options in your user preferences
    	// i.e. just add (copy/paste) this array and modify at wish
    	// IMPORTANT: Level of opacity varies from 0 to 255
    	// 0 = Totally transparent, 255 = Fully opaque
    	"levels": [
    		255, // Full opaque i.e not transparency - a.k.a Disabled
    		212, // Level 5
    		220, // Level 4
    		228, // Level 3
    		236, // Level 2
    		243  // Level 1
    	]
    }

You can see other options on `Settings - Default` file.

Author & Contributors
----------------------
[Victor Alberto Gil](http://profiles.google.com/vhanla) - Hope you like my work.

License
-------
The MIT License (MIT)

Copyright (c) 2013 Victor Alberto Gil <vhanla>

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.

 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: rexdf/SublimeTextTrans

repo_name: rexdf/SublimeTextTrans


text:
# Money Matters: The Role of Yields and Profits in Agricultural Technology Adoption

This repository contains the data and Stata programs (version 14) required to replicate the tables and figures in Michler et al. (2019) as well as the associated appendices. The programs generate all summary tables and figures. In order to construct the final regression tables, some manual editing (and copying/pasting across files) is required, so we do not reproduce them here. However, all relevant numbers are in the regression output generated by the programs files listed below.

The programs are as follows:
- `mm_master_program.do` replicates the all tables and graphics in the paper. This program will run all subsidiary `.do` files.
- `mm_pub_tables.do` replicates the regression results in the paper and the appendix. Specifically Tables 3-5 and B1-D1. Plus Figures 2-4 which are generated using regression results.
- `mm sum stats.do` replicates the summary statistics tables plus MW-tests in the paper and the appendix. Specifically Tables 1-2, 6, and A1.
- `mm graphs.do` replicates Figures 1, A1-A3.

The data are included in `mm.dta`. Several of the programs produce additional data files as inputs into regressions contained in the `.do` files.

Note that the code requires installing the Stata package `randcoef` as discussed in Barriga Cabanillas et al. (2018) and `tuple`.

## References
Barriga Cabanillas, O., J. D. Michler, A. Michuda, and E. Tjernström (2018). Fitting and interpreting correlated random-coefficient models using Stata. Stata Journal 18 (1), 159-73.

Michler, J.D, E. Tjernström, S. Verkaart, and K. Mausch (2019). Money matters: The role of yields and profits in agricultural technology adoption. American Journal of Agricultural Economics 101 (3): 710-31.

branch_name: refs/heads/main


text:
LazyDB
======

![Build Status](https://travis-ci.org/mekarpeles/lazydb.png)

LazyDB is a basic wrapper around the Python shelve flatfile dbm
module. LazyDB provides a couchdb/S3 like layer of abstraction around
shelve, allowing convenient access (read and write) to shelve without
sacrificing the convenience of writing pickled python objects to disk.

From the help(shelve) documentation: A "shelf" is a persistent,
dictionary-like object.  The difference with dbm databases is that the
values (not the keys!) in a shelf can be essentially arbitrary Python
objects -- anything that the "pickle" module can handle.  This
includes most class instances, recursive data types, and objects
containing lots of shared sub-objects.  The keys are ordinary strings.

Disclaimer: I wouldn't suggest using this module for production
projects as I predict it having difficulty scaling. LazyDB is ideal
for supporting smaller projects with light data in which the
programmer must move quickly and intends to implement an alternate db
solution sooner rather than later. The intent is to provide a more
elegant interface for utilizing the shelve module, not to create an
efficient replacement.

Typical usage often looks like this::

    #!/usr/bin/env Python

    from lazydb import Db

    class LazyUser:
    	  def __init__(self, name):
	      self.name = name

    db = Db('/home/user/db')
    db.put('user', LazyUser('lazybones'))
    u = db.get('user')
    u.name

## Contributors

Currently, this project is maintained by Mek.

repository: mekarpeles/lazydb

gha_language: Python

repo_name: mekarpeles/lazydb


text:
---
name: "\U0001F195 Feature Request"
about: "I have a suggestion for missing functionality or improvements"
title: ''
labels: 'i: enhancement'
assignees: ''

---

## Feature Request

<!--- ⚠ Before you describe your requested feature... ---

**Is your feature request directly related to a specific, existing command?**

If yes, make sure you are in the correct repository that contains the command you are referring to, and only create the issue in that repository.

Here's a quick overview of where to find the different commands:

* `wp (cache|transient) *` https://github.com/wp-cli/cache-command
* `wp checksum` https://github.com/wp-cli/checksum-command
* `wp config *` https://github.com/wp-cli/config-command
* `wp core *` https://github.com/wp-cli/core-command
* `wp cron *` https://github.com/wp-cli/cron-command
* `wp db *` https://github.com/wp-cli/db-command
* `wp embed *` https://github.com/wp-cli/embed-command
* `wp (eval|eval-file)` https://github.com/wp-cli/eval-command
* `wp export` https://github.com/wp-cli/export-command
* `wp (option|post|comment|user|term|site) *` https://github.com/wp-cli/entity-command
* `wp i18n` https://github.com/wp-cli/i18n-command
* `wp import` https://github.com/wp-cli/import-command
* `wp language` https://github.com/wp-cli/language-command
* `wp maintenance-mode *` https://github.com/wp-cli/maintenance-mode-command
* `wp media *` https://github.com/wp-cli/media-command
* `wp package *` https://github.com/wp-cli/package-command
* `wp (plugin|theme) *` https://github.com/wp-cli/extension-command
* `wp rewrite` https://github.com/wp-cli/rewrite-command
* `wp (role|cap) *` https://github.com/wp-cli/role-command
* `wp scaffold *` https://github.com/wp-cli/scaffold-command
* `wp search-replace` https://github.com/wp-cli/search-replace-command
* `wp server` https://github.com/wp-cli/server-command
* `wp shell` https://github.com/wp-cli/shell-command
* `wp super-admin *` https://github.com/wp-cli/super-admin-command
* `wp (widget|sidebar) *` https://github.com/wp-cli/widget-command

If you are not in the correct repository right now, you can just close this issue/window without submitting and click through to the correct one.

**Is your feature request about a new command, or a more general idea?**

If your feature request is not about making a change to one or more existing commands, but rather about adding functionality that doesn't naturally fit one of the existing commands, head over to the [`wp-cli/ideas`](https://github.com/wp-cli/ideas) repository and [create a new issue in that repository](https://github.com/wp-cli/ideas/issues/new).

The issue tracker in that repository will collect ideas that are still vague and need fleshing out and/or preparatory work (like creating a new repository) before the actual development work can begin.

--- ✅ If you are in the correct location now... --->

- [ ] Yes, I reviewed the [contribution guidelines](https://make.wordpress.org/cli/handbook/contributing/).

**Describe your use case and the problem you are facing**

A clear and concise description of what you are actually trying to do, and in what way the current version of WP-CLI is not up to the task.

**Describe the solution you'd like**

A clear and concise description of what you want to happen. Add any considered drawbacks if you can think of any.

repository: wp-cli/wp-cli

gha_language: PHP

gha_license_id: MIT

repo_name: wp-cli/wp-cli


text:
# Tracing Tasks

For solving the tasks use kibana and zipkin.

1. Query: Find a trace with imageflip (together)
2. Query: Make a transaction (image manipulation) and try to find your exact trace.
3. Analysis: Interpret your trace and tell us what you see.

repository: feature-creeps/observability-workshop

gha_language: Java

repo_name: feature-creeps/observability-workshop


text:
---
content_title: "Adding Inline Actions"
link_text: "Adding Inline Actions"
---
This tutorial shows how to call inline actions from a smart contract.

## Introduction
It was previously demonstrated by authoring the `addressbook` contract the basics of multi-index tables. In this part of the series you'll learn how to construct actions, and send those actions from within a contract.

## Step 1: Adding eosio.code to permissions

In order for the inline actions to be sent from `addressbook`, add the `eosio.code` permission to the contract's account's active permission. Open your terminal and run the following code
```shell
cleos set account permission addressbook active --add-code
```
The `eosio.code` authority is a pseudo authority implemented to enhance security, and enable contracts to execute inline actions.

## Step 2: Notify Action

If not still opened, open the `addressbook.cpp` contract authored in the last tutorial. Write an action that dispatches a "transaction receipt" whenever a transaction occurs. To do this, create a helper function in the `addressbook` class.
```cpp
[[eosio::action]]
void notify(name user, std::string msg) {}
```
This function is very simple, it just accepts a user account as a `name` type and a message as a `string` type. The user parameter dictates which user gets the message that is sent.

## Step 3: Copy action to sender using require_recipient

This transaction needs to be copied to the user so it can be considered as a receipt. To do this, use the [require_recipient](https://developers.eos.io/manuals/eosio.cdt/latest/group__action/#function-require_recipient) method.  Calling `require_recipient` adds an account to the require_recipient set and ensures that these accounts receive a notification of the action being executed. The notification is like sending a "carbon copy" of the action to the accounts in the require_recipient set.
```cpp
  [[eosio::action]]
  void notify(name user, std::string msg) {
   require_recipient(user);
  }
```
This action is very simple, however, as written, any user could call this function, and "fake" a receipt from this contract. This could be used in malicious ways, and should be seen as a vulnerability. To correct this, require that the authorization provided in the call to this action is from the contract itself, for this, use [get_self](https://developers.eos.io/manuals/eosio.cdt/latest/classeosio_1_1contract#function-get_self)
```cpp
  [[eosio::action]]
  void notify(name user, std::string msg) {
    require_auth(get_self());
    require_recipient(user);
  }
```
Now if user `bob` calls this function directly, but passes the parameter `alice` the action will throw an exception.

## Step 4: Notify helper for sending inline transactions

Since this inline action will be called several times, write a quick helper for maximum code reuse. In the private region of your contract, define a new method.
```cpp
...
  private:
    void send_summary(name user, std::string message){}
```
Inside of this helper construct an action and send it.

## Step 5: The Action Constructor

Modify the `addressbook`  contract to send a receipt to the user every time they take an action on the contract.

To begin, address the "create record" case. This is the case that fires when a record is not found in the table, i.e., when `iterator == addresses.end()` is `true`.

Save this object to an `action` variable called `notification`
```cpp
...
  private:
    void send_summary(name user, std::string message){
      action(
        //permission_level,
        //code,
        //action,
        //data
      );
    }

```
The action constructor requires a number of parameters.
- A [permission_level](https://developers.eos.io/manuals/eosio.cdt/latest/structeosio_1_1permission__level) struct
- The contract to call (initialised using `eosio::name` type)
- The action (initialised using `eosio::name` type)
- The data to pass to the action, a tuple of positionals that correlate to the actions being called.

## The Permission struct

In this contract the permission should be authorized by the `active` authority of the contract using `get_self()`. As a reminder, to use the 'active` authority inline you will need your contract's to give active authority to `eosio.code` pseudo-authority (instructions above)
```cpp
...
  private:
    void send_summary(name user, std::string message){
      action(
        permission_level{get_self(),"active"_n},
        //code,
        //action,
        //data
      );
    }
```

## The "code" AKA "account where contract is deployed"

Since the action called is in this contract, use  [get_self](https://developers.eos.io/manuals/eosio.cdt/latest/classeosio_1_1contract/#function-get_self). `"addressbook"_n` would also work here, but if this contract were deployed under a different account name, it wouldn't work. Because of this, `get_self()` is the superior option.
```cpp
...
  private:
    void send_summary(name user, std::string message){
      action(
        permission_level{get_self(),"active"_n},
        get_self(),
        //action
        //data
      );
    }
```

## The action

The `notify` action was previously defined to be called from this inline action. Use the _n operator here.
```cpp
...
  private:
    void send_summary(name user, std::string message){
      action(
        permission_level{get_self(),"active"_n},
        get_self(),
        "notify"_n,
        //data
      );
    }
```

## The Data

Finally, define the data to pass to this action. The notify function accepts two parameters, an `name` and a `string`. The action constructor expects data as type `bytes`, so use `make_tuple`, a function available through `std` C++ library.  Data passed in the tuple is positional, and determined by the order of the parameters accepted by the action that being called.

- Pass the `user` variable that is provided as a parameter of the `upsert()` action.
- Concatenate a string that includes the name of the user, and include the `message` to pass to the `notify` action.
```cpp
...
  private:
    void send_summary(name user, std::string message){
      action(
        permission_level{get_self(),"active"_n},
        get_self(),
        "notify"_n,
        std::make_tuple(user, name{user}.to_string() + message)
      );
    }
```

## Send the action.

Finally, send the action using the `send` method of the action struct.
```cpp
...
  private:
    void send_summary(name user, std::string message) {
      action(
        permission_level{get_self(),"active"_n},
        get_self(),
        "notify"_n,
        std::make_tuple(user, name{user}.to_string() + message)
      ).send();
    }
```

## Step 6: Call the helper and inject relevant messages.
Now that the helper is defined, it should probably be called from the relevant locations. There's three specific places for the new `notify` helper to be called from:
- After the contract `emplaces` a new record: `send_summary(user, "successfully emplaced record to addressbook");`
- After the contract `modifies` an existing record: `send_summary(user, "successfully modified record in addressbook.");`
- After the contract `erases` an existing record: `send_summary(user, "successfully erased record from addressbook");`

## Step 7: Recompile and Regenerate the ABI File

Now that everything is in place, here's the current state of the `addressbook` contract:
```cpp
#include <eosio/eosio.hpp>
#include <eosio/print.hpp>

using namespace eosio;

class [[eosio::contract("addressbook")]] addressbook : public eosio::contract {

public:

  addressbook(name receiver, name code,  datastream<const char*> ds): contract(receiver, code, ds) {}

  [[eosio::action]]
  void upsert(name user, std::string first_name, std::string last_name, uint64_t age, std::string street, std::string city, std::string state) {
    require_auth(user);
    address_index addresses(get_first_receiver(), get_first_receiver().value);
    auto iterator = addresses.find(user.value);
    if( iterator == addresses.end() )
    {
      addresses.emplace(user, [&]( auto& row ) {
       row.key = user;
       row.first_name = first_name;
       row.last_name = last_name;
       row.age = age;
       row.street = street;
       row.city = city;
       row.state = state;
      });
      send_summary(user, " successfully emplaced record to addressbook");
    }
    else {
      addresses.modify(iterator, user, [&]( auto& row ) {
        row.key = user;
        row.first_name = first_name;
        row.last_name = last_name;
        row.street = street;
        row.city = city;
        row.state = state;
      });
      send_summary(user, " successfully modified record to addressbook");
    }
  }

  [[eosio::action]]
  void erase(name user) {
    require_auth(user);

    address_index addresses(get_first_receiver(), get_first_receiver().value);

    auto iterator = addresses.find(user.value);
    check(iterator != addresses.end(), "Record does not exist");
    addresses.erase(iterator);
    send_summary(user, " successfully erased record from addressbook");
  }

  [[eosio::action]]
  void notify(name user, std::string msg) {
    require_auth(get_self());
    require_recipient(user);
  }

private:
  struct [[eosio::table]] person {
    name key;
    std::string first_name;
    std::string last_name;
    uint64_t age;
    std::string street;
    std::string city;
    std::string state;

    uint64_t primary_key() const { return key.value; }
    uint64_t get_secondary_1() const { return age;}
  };

  void send_summary(name user, std::string message) {
    action(
      permission_level{get_self(),"active"_n},
      get_self(),
      "notify"_n,
      std::make_tuple(user, name{user}.to_string() + message)
    ).send();
  };

  typedef eosio::multi_index<"people"_n, person,
    indexed_by<"byage"_n, const_mem_fun<person, uint64_t, &person::get_secondary_1>>
  > address_index;
};
```
Open your terminal, and navigate to `CONTRACTS_DIR/addressbook`
```shell
cd CONTRACTS_DIR/addressbook
```
Now, recompile the contract, including the `--abigen` flag since changes have been made to the contract that affects the ABI. If you've followed the instructions carefully, you shouldn't see any errors.
```shell
eosio-cpp -o addressbook.wasm addressbook.cpp --abigen
```
Smart contracts on EOSIO are upgradeable so the contract can be redeployed with changes.
```shell
cleos set contract addressbook CONTRACTS_DIR/addressbook
```

```shell
Publishing contract...
executed transaction: 1898d22d994c97824228b24a1741ca3bd5c7bc2eba9fea8e83446d78bfb264fd  7320 bytes  747 us
#         eosio <= eosio::setcode               {"account":"addressbook","vmtype":0,"vmversion":0,"code":"0061736d0100000001a6011a60027f7e0060077f7e...
#         eosio <= eosio::setabi                {"account":"addressbook","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d65...
```
Success!

## Step 8: Testing it

Now that the contract has been modified and deployed, test it. In the previous tutorial, alice's addressbook record was deleted during the testing steps, so calling `upsert` will fire the inline action just written inside of the "create" case.

Run the following command in your terminal
```shell
cleos push action addressbook upsert '["alice", "alice", "liddell", 21, "123 drink me way", "wonderland", "amsterdam"]' -p alice@active
```
`cleos` will return some data, that includes all the actions executed in the transaction
```shell
executed transaction: e9e30524186bb6501cf490ceb744fe50654eb393ce0dd733f3bb6c68ff4b5622  160 bytes  9810 us
#   addressbook <= addressbook::upsert          {"user":"alice","first_name":"alice","last_name":"liddell","age":21,"street":"123 drink me way","cit...
#   addressbook <= addressbook::notify          {"user":"alice","msg":"alicesuccessfully emplaced record to addressbook"}
#         alice <= addressbook::notify          {"user":"alice","msg":"alicesuccessfully emplaced record to addressbook"}
```
The last entry in the previous log is an `addressbook::notify` action sent to `alice`. Use [cleos get actions](https://developers.eos.io/manuals/eos/latest/cleos/command-reference/get/actions) to display actions executed and relevant to alice.
```shell
cleos get actions alice
```

```shell
#  seq  when                              contract::action => receiver      trx id...   args
================================================================================================================
#   62   2018-09-15T12:57:09.000       addressbook::notify => alice         685ecc09... {"user":"alice","msg":"alice successfully added record to ad...
```

## What's Next

- [Inline Actions to External Contracts](./70_inline-action-to-external-contract.md): Learn how to construct actions and send those actions to an external contract.

repository: jokergit/welcome

repo_name: jokergit/welcome


text:
# gulp-folder-index

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]

> Convert a buffer of files into a JSON representation of the directory structure using [gulp](https://github.com/gulpjs/gulp), with configurable file extension

## Usage

First, install `gulp-folder-index` as a development dependency:

```shell
npm install --save-dev gulp-folder-index
```

Then, add it to your `gulpfile.js`:

```javascript
let folderIndex = require("gulp-folder-index");

gulp.src('app/**/*.yml')
  .pipe(folderIndex({
    extension: '.json',       // default
    filename: 'index.json',   // default
    prefix: '',               // default
    directory: false          // default
  }))
  .pipe(gulp.dest('dist'));

```

Given this directory structure...
```
app
  | folder-1
    | folder-2
      | something.yml
    | faqs.yml
  | folder-3
    |_folder-4
      | something-else.yml
  | hello-world.yml
```

... this JSON object would be written to `dist/index.json`:

```json
[
  "hello-world.json",
  "folder-1/faqs.json",
  "folder-1/folder2/something.json",
  "folder-3/folder-4/something-else.json"
]
```

This is useful for mapping out a directory structure after passing files through a pre-processor, generating data to create navigation during build, and more. Have fun!

## API

### folder-index(options)

#### options.filename
Type: `String`
Default: `index.json`

The path to write the directory structure JSON file to.

#### options.prefix
Type: `String`
Default: none

A string to prepend to every url.

Given the directory structure above, specifiying `prefix: 'prefixed-folder'` would generate this JSON:

```json
[
  "prefixed-folder/hello-world.json",
  "prefixed-folder/folder-1/faqs.json",
  "prefixed-folder/folder-1/folder2/something.json",
  "prefixed-folder/folder-3/folder-4/something-else.json"
]
```

#### options.extension
Type: `String`
Default: json

An extension string to replace the original with.

Given the directory structure above, specifiying `extension: 'html'` would generate this JSON:

```json
[
  "hello-world.html",
  "folder-1/faqs.html",
  "folder-1/folder2/something.html",
  "folder-3/folder-4/something-else.html"
]
```

#### options.directory
Type: `Boolean`
Default: false

An extension boolean to generate json with directory and path.

Given the directory structure above, specifiying `directory: true` would generate this JSON:

```json
[
  {
    "directory": "",
    "path": "hello-world.json"
  },
  {
    "directory": "folder-1/",
    "path": "folder-1/faqs.json"
  },
  {
    "directory": "folder-1/folder2/",
    "path": "folder-1/folder2/something.json"
  },
  {
    "directory": "folder-3/folder-4/",
    "path": "folder-3/folder-4/something-else.json"
  }
]
```

## Contributing

Contributions are welcomed.  Please see [the contributing notes](CONTRIBUTING.md) for details.

## License

[MIT License](http://en.wikipedia.org/wiki/MIT_License)

## Thanks

Thanks to [@masondesu](https://github.com/masondesu) for creating the [gulp-directory-map](https://github.com/masondesu/gulp-directory-map) upon which this is based.

[npm-url]: https://npmjs.org/package/gulp-folder-index
[npm-image]: https://badge.fury.io/js/gulp-folder-index.png

[travis-url]: http://travis-ci.org/davesag/gulp-folder-index
[travis-image]: https://secure.travis-ci.org/davesag/gulp-folder-index.png?branch=master

repository: davesag/gulp-folder-index

gha_language: JavaScript

repo_name: davesag/gulp-folder-index


text:
#  Ormy
[![NPM Version](https://img.shields.io/npm/v/ormy.svg)](https://npmjs.org/package/ormy)
[![Downloads](https://img.shields.io/npm/dm/ormy.svg)](https://npmjs.org/package/ormy)
[![Build Status](https://img.shields.io/travis/lighterio/ormy.svg)](https://travis-ci.org/lighterio/ormy)
[![Code Coverage](https://img.shields.io/coveralls/lighterio/ormy/master.svg)](https://coveralls.io/r/lighterio/ormy)
[![Dependencies](https://img.shields.io/david/lighterio/ormy.svg)](https://david-dm.org/lighterio/ormy)
[![Support](https://img.shields.io/gratipay/Lighter.io.svg)](https://gratipay.com/Lighter.io/)

Ormy is a Node.js Object Relational Mapping library. It currently supports
MySQL and SQLite.

## Quick Start

Get a new database connection for one of the supported adapters.
```js
var db = require('ormy')(
  adapter: 'mysql',
  host: 'localhost'
  port: 3306,
  user: 'root',
  pass: 'MY_PASSWORD',
  name: 'MY_DATABASE'
});
```

Define a model.
```js
var User = db.define({
  table: 'users',
  fields: {
    email: 'string',
    firstName: 'string',
    lastName: 'string'
  },
  methods: {
    hello: function () {
      return 'Hello, ' + this.firstName + '!';
    }
  }
});

User.create({
  email<EMAIL_ADDRESS>  firstName: 'Ormy',
  lastName: 'Team'
}, function (err, item) {
  console.log('Created item: ', item);
});

User.create([{
  email<EMAIL_ADDRESS>  firstName: 'Ormy',
  lastName: 'Team'
}, {
  email<EMAIL_ADDRESS>  firstName: 'Lighter',
  lastName: 'Team'
}], function (err, items) {
  console.log('Created array of items: ', items);
});

User.get(1, function (err, item) {
  console.log('User with ID 1: ', item);
});

User.get({email<EMAIL_ADDRESS>function (err, item) {
  console.log('User with Ormy Email: ', item);
});

User.find({lastName: "Team"}, function (err, items) {
  console.log('"Team" users: ', items);
  items.forEach(function (item) {
    item.lastName = 'Core';
    item.save();
  })
});
```

## Acknowledgements

We would like to thank all of the amazing people who use, support,
promote, enhance, document, patch, and submit comments & issues.
Ormy couldn't exist without you.

Additionally, huge thanks go to [Goin’](https://goin.io) for employing
and supporting [Ormy](http://lighter.io/ormy) project maintainers,
and for being an epically awesome place to work (and play).

## MIT License

Copyright (c) 2014 Sam Eubank

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.

 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.

## How to Contribute

We welcome contributions from the community and are happy to have them.
Please follow this guide when logging issues or making code changes.

### Logging Issues

All issues should be created using the
[new issue form](https://github.com/lighterio/ormy/issues/new).
Please describe the issue including steps to reproduce. Also, make sure
to indicate the version that has the issue.

### Changing Code

Code changes are welcome and encouraged! Please follow our process:

1. Fork the repository on GitHub.
2. Fix the issue ensuring that your code follows the
   [style guide](http://lighter.io/style-guide).
3. Add tests for your new code, ensuring that you have 100% code coverage.
   (If necessary, we can help you reach 100% prior to merging.)
   * Run `npm test` to run tests quickly, without testing coverage.
   * Run `npm run cover` to test coverage and generate a report.
   * Run `npm run report` to open the coverage report you generated.
4. [Pull requests](http://help.github.com/send-pull-requests/) should be made
   to the [master branch](https://github.com/lighterio/ormy/tree/master).

### Contributor Code of Conduct

As contributors and maintainers of Ormy, we pledge to respect all
people who contribute through reporting issues, posting feature requests,
updating documentation, submitting pull requests or patches, and other
activities.

If any participant in this project has issues or takes exception with a
contribution, they are obligated to provide constructive feedback and never
resort to personal attacks, trolling, public or private harassment, insults, or
other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, edits, issues, and other contributions
that are not aligned with this Code of Conduct. Project maintainers who do
not follow the Code of Conduct may be removed from the project team.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue or contacting one or more of the project
maintainers.

We promise to extend courtesy and respect to everyone involved in this project
regardless of gender, gender identity, sexual orientation, ability or
disability, ethnicity, religion, age, location, native language, or level of
experience.

repository: zerious/talks

repo_name: zerious/talks


text:
---
slug: "/blog/bubble-tea-a-unique-drink"
date: "2020-08-24"
title: "Bubble Tea: A unique drink"
author: "Ben Wang"
---

For those who do not know, bubble tea is traditionally black milk tea with boiled tapioca pearls originating from Taiwan. Nowadays you can find all different kinds of flavors and toppings at the countless bubble tea stores around the world. Today I want to talk about the idea of a *liquid snack* and how bubble tea could be considered one.

## Why?

Because bubble tea isn’t a common drink (unless you can make it) you want to enjoy the moments when you can drink your no sugar, no ice, large milk tea with bubbles. I think because it is a drink that some people would be inclined to drink it while eating food and therein lies the issue. The special part about bubble tea is that the pearls add to the tea and having other solid food blobs in there ruins the pearls. So instead of having a cohesive drink you instead get like spicy chicken mixed in with your pearls and that is not quite as popular.

## Shouldn’t it be in the category of a dessert?

It totally could be! I think what makes bubble tea unique is the fact that you can just go out and have bubble tea with friends. It’s a strange mix of a dessert and coffee (including the caffeine and price) and due to this I think it deserves its own category: liquid snack. There are also other drinks that I think belong in this category but bubble tea is definitely the one I drink the most.

## What other drinks are considered liquid snacks?

The first one that comes to mind is sugary coffee drinks.  I mean a java chip frappuccino with extra whip since it’s more like a chocolate milkshake than a coffee.
Another drink that popped into my head is a chunky fruit smoothie. I’d say a cold smoothie with strawberry chunks would also be considered a liquid snack.
Of course you have something like soylent but I’m going to pretend that doesn’t exist.

## Conclusion

I really like bubble tea. Like a lot.
And there’s a bubble tea emoji in unicode 13: 🧋


text:
+++
Talk_date = ""
Talk_start_time = ""
Talk_end_time = ""
Title = "A Security State of Mind: Compliance and Vulnerability Audits for Containers"
Type = "talk"
Speakers = ["chris-van-tuin"]
youtube = ""
+++

Data breaches are on the rise and placing increased pressure on Enterprise IT to protect
the business. With the rise of DevOps and as hackers takes advantage of known vulnerabilities
on unpatched or misconfigured systems, Enterprise IT increasingly needs to automate
vulnerability management, security management, and compliance checking.

In this talk, you’ll learn about:

* How Containers enable DevOps and the security risks with deploying containers in the enterprise
* Automating security vulnerability and compliance management in your CI/CD pipeline
* Scanning online and offline containers for security compliance vulnerabilities and generating
security audit reports with OpenScap

Join, Chris Van Tuin, Chief Technologist, West at Red Hat, as he walks through an overview
of the underlying Container technologies, the security risks with deploying containers, and how
to address these security challenges in a DevOps environment.

repository: sveinung/devopsdays-web

gha_language: HTML

repo_name: sveinung/devopsdays-web


text:
---
title: "Handle loading/errors"
metaTitle: "Apollo Error Handling | Next.js GraphQL Serverless Tutorial"
metaDescription: "We will handle the GraphQL loading and error states in React app using the Apollo useQuery React hook properties - loading and error "
---

As we saw in the previous step, Apollo returned a result object with properties . Among them `loading` and `error` are common ones that you will need to handle in your app.

Now let's go back to the `useQuery` React hook that you wrote in the previous step.

```javascript

  const TodoPrivateListQuery = () => {
  const { loading, error, data } = useQuery(GET_MY_TODOS);

  if (loading) {
    return <div>Loading...</div>;
  }
  if (error) {
    console.error(error);
    return <div>Error!</div>;
  }
  return <TodoPrivateList todos={data.todos} />;
};

```

### Apollo Query Loading State
When this component mounts, the GraphQL query sent in the background may not have been completed. But we need to handle that temporary state of no data and hence we return some useful text during `loading` state.
In this loading state, typically you can do fancy things like displaying a loading spinner.

### Apollo Query Error State
Now, the query could also end up in an `error` state due to various reasons. Sometimes the graphql query could be wrong, or the server isn't responding. Whatever may be the reason, the user facing UI should show something to convey that an error has occurred.
In this error state, typically you can send these error messages to third-party services to track what went wrong.

All said and done, these are two important states that need to be handled inside your component. What you have written above is basic, but sufficient for this tutorial.

repository: hasura/learn-graphql

repo_name: hasura/learn-graphql


text:
Title: About the god(s) project
Slug: about
Satus: hidden

**What is the god(s) project?**

the god(s) project explores how people in this city experience spirituality and create meaning for their lives.  In Hong Kong, with its dazzling distractions and churn of work-sleep-success, how do people pursue their religions?  We want to follow the followers and understand what happens when a community congregates in a shared sacred space, and how individuals define and connect with their God, gods and/or Truth (with a capital T).

**How do you exist?**

the god(s) project was selected as one of a few English-language programs to be broadcast on DAB 31, RTHK under CIBS, the Community Involvement Broadcasting Service.  CIBS is funded by the government’s Community Involvement Broadcasting Fund, which provides resources for groups or individuals to produce their own radio programs.

the god(s) project makes its own editorial decisions.

**Why are you doing this?**

Hong Kong is one of the most religiously diverse cities in the world, which is awesome - but beyond walking past mosques, temples, churches and other places of worship on a daily basis, there is little opportunity to know what goes on in the lives of the people who seek behind those walls.  the god(s) project intends to explore faith beyond the cursory tenets of each religion.  Faith can play a significant part in how people think about themselves and their actions, and we want to see how its texture changes throughout someone’s life.  That’s really what it comes down to - understanding how faith and its variety of forms spur people to think about how they live and who they are.

**Who are you, even?**

I’m Steph.

repository: tijptjik/thegodsproject

repo_name: tijptjik/thegodsproject


text:
# (PART) MEDIATION ANALYSIS {-}

# The Simple Mediation Model

Hayes closed the opening with:

> Whereas answering questions about *when* or *for whom* is the domain of moderation analysis, questions that ask about *how* pertain to *mediation*, the focus of this and the next three chapters. In this chapter, [we'll explore] the *simple mediation model* and illustrate using ~~OLS regression-based~~ Bayesian path analysis how the effect of an antecedent variable $X$ on some final consequent $Y$ can be partitioned into two paths of influence, *direct* and *indirect*. [@hayesIntroductionMediationModeration2018, p. 78, *emphasis* in the original]

## The simple mediation model

> Mediation analysis is a statistical method used to evaluate evidence from studies designed to test hypotheses about how some causal antecedent variable $X$ transmits its effect on a consequent variable $Y$.
>
> When thinking about whether a phenomenon or theory you are studying could be conceptualized as a mediation process, it is important to keep in mind that mediation is ultimately a causal explanation. It is assumed that the relationships in the system are causal, and, importantly, that $M$ is causally located *between* $X$ and $Y$. It must be assumed, if not also empirically substantiated, that $X$ causes $M$, which in turn causes $Y$. $M$ cannot possibly carry $X$’s effect on $Y$ if $M$ is not located causally between $X$ and $Y$. (pp. 78--81, *emphasis* in the original)

## Estimation of the direct, indirect, and total effects of $X$

Given the simple three-term mediation model, the statistical model is expressed in the two equations

\begin{align*}
M & = i_M + a X + e_M \\
Y & = i_Y + c' X + b M + e_Y.
\end{align*}

When using OLS software, as Hayes promotes throughout the text, these equations are estimated sequentially. However, the **brms** package has multivariate capabilities. As such, our results will be from a Bayesian multivariate model that computes both equations at once. They're both part of a joint model. When we consider more advanced models later in the text, our multivariate models will fit even more than two equations at once. None of this is a problem for **brms**.

## Example with dichotomous $X$: The influence of presumed media influence

Here we load a couple necessary packages, load the data, and take a peek.

```r
library(tidyverse)

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

glimpse(pmi)
```

```
## Rows: 123
## Columns: 6
## $ cond     <dbl> 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0…
## $ pmi      <dbl> 7.0, 6.0, 5.5, 6.5, 6.0, 5.5, 3.5, 6.0, 4.5, 7.0, 1.0, 6.0, 5.0, 7.0, 7.0, 7.0, 4.5, 3.5, 7…
## $ import   <dbl> 6, 1, 6, 6, 5, 1, 1, 6, 6, 6, 3, 3, 4, 7, 1, 6, 3, 3, 2, 4, 4, 6, 7, 4, 5, 4, 6, 5, 5, 7, 4…
## $ reaction <dbl> 5.25, 1.25, 5.00, 2.75, 2.50, 1.25, 1.50, 4.75, 4.25, 6.25, 1.25, 2.75, 3.75, 5.00, 4.00, 5…
## $ gender   <dbl> 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0…
## $ age      <dbl> 51.0, 40.0, 26.0, 21.0, 27.0, 25.0, 23.0, 25.0, 22.0, 24.0, 22.0, 21.0, 23.0, 21.0, 22.0, 2…
```

You can get the male/female split like so.

```r
pmi %>%
  count(gender)
```

```
## # A tibble: 2 × 2
##   gender     n
##    <dbl> <int>
## 1      0    80
## 2      1    43
```

Here is the split by `condition`.

```r
pmi %>%
  count(cond)
```

```
## # A tibble: 2 × 2
##    cond     n
##   <dbl> <int>
## 1     0    65
## 2     1    58
```

Here is how to get the ungrouped mean and $\textit{SD}$ values for `reaction` and `pmi`, as presented in Table 3.1.

```r
pmi %>%
  pivot_longer(c(reaction, pmi)) %>%
  group_by(name) %>%
  summarise(mean = mean(value),
            sd   = sd(value)) %>%
  mutate_if(is.double, round, digits = 3)
```

```
## # A tibble: 2 × 3
##   name      mean    sd
##   <chr>    <dbl> <dbl>
## 1 pmi       5.60  1.32
## 2 reaction  3.48  1.55
```

You might get the mean and $\textit{SD}$ values for `reaction` and `pmi` grouped by `cond` like this.

```r
pmi %>%
  pivot_longer(c(reaction, pmi)) %>%
  group_by(cond, name) %>%
  summarise(mean = mean(value),
            sd   = sd(value)) %>%
  mutate_if(is.double, round, digits = 3)
```

```
## # A tibble: 4 × 4
## # Groups:   cond [2]
##    cond name      mean    sd
##   <dbl> <chr>    <dbl> <dbl>
## 1     0 pmi       5.38  1.34
## 2     0 reaction  3.25  1.61
## 3     1 pmi       5.85  1.27
## 4     1 reaction  3.75  1.45
```

Let's load our primary statistical package, **brms**.

```r
library(brms)
```

Before we begin, I should acknowledge that I greatly benefited by [this great blog post on path analysis in brms](https://www.imachordata.com/2017/12/21/bayesian-sem-with-brms/) by [Jarrett Byrnes](https://www.imachordata.com/about/). With **brms**, we handle mediation models using the [multivariate syntax](https://CRAN.R-project.org/package=brms/vignettes/brms_multivariate.html) [@Bürkner2022Multivariate].  Let's start simple.

If you look at the path model in Figure 3.3, you'll note that `reaction` is predicted by `pmi` and `cond`. `pmi`, in turn, is predicted solely by `cond`. So we have two regression models, which is just the kind of thing the **brms** multivariate syntax is for. So first let's specify both models, which we'll nest in `bf()` functions and save as objects.

```r
y_model <- bf(reaction ~ 1 + pmi + cond)
m_model <- bf(pmi ~ 1 + cond)
```

Now we have our `bf()` objects in hand, we'll combine them with the `+` operator within the `brm()` function. We'll also specify `set_rescor(FALSE)` because we are not interested in adding a residual correlation between `reaction` and `pmi`.

```r
model3.1 <- brm(
  data = pmi,
  family = gaussian,
  y_model + m_model + set_rescor(FALSE),
  cores = 4,
  file = "fits/model03.01")
```

Here are our results.

```r
print(model3.1)
```

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: reaction ~ 1 + pmi + cond
##          pmi ~ 1 + cond
##    Data: pmi (Number of observations: 123)
##   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
## reaction_Intercept     0.52      0.55    -0.55     1.58 1.00     6477     3316
## pmi_Intercept          5.38      0.15     5.08     5.67 1.00     6251     3184
## reaction_pmi           0.51      0.10     0.31     0.70 1.00     6169     3365
## reaction_cond          0.25      0.26    -0.26     0.76 1.00     5433     2768
## pmi_cond               0.48      0.23     0.04     0.93 1.00     6831     3069
##
## Family Specific Parameters:
##                Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma_reaction     1.41      0.09     1.24     1.60 1.00     5651     2932
## sigma_pmi          1.32      0.08     1.17     1.49 1.00     6248     2910
##
## 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).
```

If you compare our model summary with the coefficients in the path model in Figure 3.3, you'll see our coefficients are the same. The **brms** summary also includes intercepts and residual variances, which are typically omitted in path diagrams even though they're still part of the model.

If you're getting lost in all the model output, try taking out the constant and error terms.

```r
fixef(model3.1)[3:5, ] %>% round(digits = 3)
```

```
##               Estimate Est.Error   Q2.5 Q97.5
## reaction_pmi     0.507     0.098  0.314 0.696
## reaction_cond    0.252     0.258 -0.263 0.757
## pmi_cond         0.478     0.227  0.035 0.929
```

In his Table 3.2, Hayes included the $R^2$ values. Here are ours.

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

```
##            Estimate Est.Error  Q2.5 Q97.5
## R2reaction    0.209     0.056 0.101 0.317
## R2pmi         0.039     0.030 0.001 0.111
```

It's worth it to actually plot the $R^2$ distributions. We'll take our color palette from the [**ggthemes** package](https://CRAN.R-project.org/package=ggthemes) [@R-ggthemes].

```r
library(ggthemes)

bayes_R2(model3.1, summary = F) %>%
  data.frame() %>%
  pivot_longer(everything()) %>%
  mutate(name = str_remove(name, "R2")) %>%

  ggplot(aes(x = value, fill = name)) +
  geom_density(color = "transparent", alpha = 2/3) +
  scale_fill_colorblind(NULL) +  # we got this color palette from the ggthemes package
  coord_cartesian(xlim = 0:1) +
  labs(title = expression(paste("The ", italic("R")^{2}, " distributions for model3.1")),
       x = NULL) +
  theme_classic()
```

We went through the trouble of plotting the $R^2$ distributions because it's useful to understand that they won't often be symmetric when they're near their logical boundaries (i.e., 0 and 1). This is where asymmetric Bayesian credible intervals can really shine.

Let's get down to business and examine the indirect effect, the $ab$ pathway. In our model,

* $a$ = `pmi_cond` and
* $b$ = `reaction_pmi`.

You can isolate them with `fixef()[i, ]`.

```r
fixef(model3.1)[5, ]
```

```
##   Estimate  Est.Error       Q2.5      Q97.5
## 0.47826304 0.22688910 0.03540068 0.92879374
```

```r
fixef(model3.1)[3, ]
```

```
##   Estimate  Est.Error       Q2.5      Q97.5
## 0.50655988 0.09764479 0.31385098 0.69578157
```

So the naive approach would be to just multiply them.

```r
(fixef(model3.1)[5, ] * fixef(model3.1)[3, ]) %>% round(digits = 3)
```

```
##  Estimate Est.Error      Q2.5     Q97.5
##     0.242     0.022     0.011     0.646
```

Now, this does get us the correct 'Estimate' (i.e., posterior mean). However, the posterior $\textit{SD}$ and 95% intervals are off. If you want to do this properly, you need to work with the poster samples themselves. We do that with the `as_draws_df()` function.

```r
draws <- as_draws_df(model3.1)

glimpse(draws)
```

```
## Rows: 4,000
## Columns: 12
## $ b_reaction_Intercept <dbl> 3.504173e-01, 3.709087e-01, 9.834039e-02, 8.472168e-01, 1.308578e-01, 6.617100e…
## $ b_pmi_Intercept      <dbl> 5.593477, 5.221651, 5.596498, 5.008179, 5.221197, 5.440538, 5.495575, 5.421468,…
## $ b_reaction_pmi       <dbl> 0.5264621, 0.5493630, 0.5681480, 0.4454483, 0.5533578, 0.4959108, 0.5118134, 0.…
## $ b_reaction_cond      <dbl> -0.252662935, 0.617586525, 0.220744749, 0.282507395, 0.316521189, 0.210106073, …
## $ b_pmi_cond           <dbl> 0.20475270, 0.63722353, 0.24630473, 0.87306055, 0.34635204, 0.43479263, 0.60891…
## $ sigma_reaction       <dbl> 1.432913, 1.390006, 1.434894, 1.371039, 1.486793, 1.278881, 1.297105, 1.298125,…
## $ sigma_pmi            <dbl> 1.301103, 1.273754, 1.299293, 1.380452, 1.365904, 1.342461, 1.386392, 1.283587,…
## $ lprior               <dbl> -6.673399, -6.699569, -6.675656, -6.710765, -6.738489, -6.658791, -6.669843, -6…
## $ lp__                 <dbl> -431.8571, -430.0315, -427.7059, -429.1300, -429.2515, -427.2221, -428.7214, -4…
## $ .chain               <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ .iteration           <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, …
## $ .draw                <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, …
```

Here we compute the indirect effect, `ab`.

```r
draws <- draws %>%
  mutate(ab = b_pmi_cond * b_reaction_pmi)
```

Now we have `ab` as a properly computed vector, we can summarize it with the `quantile()` function.

```r
quantile(draws$ab, probs = c(.5, .025, .975)) %>%
  round(digits = 3)
```

```
##   50%  2.5% 97.5%
## 0.232 0.017 0.513
```

And we can even visualize it as a density.

```r
draws %>%
  ggplot(aes(x = ab)) +
  geom_density(color = "transparent",
               fill = colorblind_pal()(3)[3]) +
  scale_y_continuous(NULL, breaks = NULL) +
  labs(title = expression(paste("Our indirect effect, the ", italic("ab"), " pathway")),
       x = NULL) +
  theme_classic()
```

It's also worth pointing out that as the indirect effect isn't perfectly symmetric, its mean and median aren't quite the same.

```r
draws %>%
  summarize(mean   = mean(ab),
            median = median(ab)) %>%
  round(digits = 3)
```

```
## # A tibble: 1 × 2
##    mean median
##   <dbl>  <dbl>
## 1 0.242  0.232
```

Their magnitudes are similar, but this asymmetry will be a source of contrast to our estimates and the OLS estimates Hayes reported throughout his text. This is also something to consider when reporting on central tendency. When the indirect effect--or any other parameter, for that matter--is quite asymmetric, you might prefer reporting the median rather than the mean.

On page 90, Hayes computed the *adjusted means* for $Y$. For both `cond == 1` and `cond == 0`, he computed the expected values for `reaction` when `pmi` was at its mean. A natural way to do that in **brms** is with `fitted()`. First we'll put our input values for `cond` and `pmi` in a tibble, which we'll call `nd`. Then we'll feed `nd` into the `newdata` argument within the `fitted()` function.

```r
nd <-
  tibble(cond = 1:0,
         pmi  = mean(pmi$pmi))

fitted(model3.1, newdata = nd)
```

```
## , , reaction
##
##      Estimate Est.Error     Q2.5    Q97.5
## [1,] 3.613162 0.1901055 3.230107 3.978794
## [2,] 3.360795 0.1750825 3.009563 3.702770
##
## , , pmi
##
##      Estimate Est.Error     Q2.5    Q97.5
## [1,] 5.856210 0.1706542 5.511162 6.191147
## [2,] 5.377947 0.1546516 5.081493 5.674961
```

Because `model3.1` is a multivariate model, `fitted()` returned the model-implied summaries for both `reaction` and `pmi`. If you just want the adjusted means for `reaction`, you can use the `resp` argument within `fitted()`.

```r
fitted(model3.1, newdata = nd, resp = "reaction") %>% round(digits = 3)
```

```
##      Estimate Est.Error Q2.5 Q97.5
## [1,]    3.613     0.190 3.23 3.979
## [2,]    3.361     0.175 3.01 3.703
```

Note how this is where the two values in the $Y$ adjusted column in Table 3.1 came from.

However, if we want to reproduce how Hayes computed the total effect (i.e., $c' + ab$), we'll need to work with the posterior draws themselves, `draws`. Recall, we've already saved the indirect effect as a vector, `ab`. The direct effect, $c'$, is labeled `b_reaction_cond` within `draws`. To get the total effect, $c$, all we need to is add those vectors together.

```r
draws <- draws %>%
  mutate(total_effect = b_reaction_cond + ab)
```

Here are the posterior mean with its quantile-based 95% intervals.

```r
draws %>%
  summarize(mean = mean(total_effect),
            ll   = quantile(total_effect, prob = .025),
            ul   = quantile(total_effect, prob = .975))
```

```
## # A tibble: 1 × 3
##    mean      ll    ul
##   <dbl>   <dbl> <dbl>
## 1 0.495 -0.0285  1.04
```

### ~~Estimation of the model in PROCESS for SPSS and SAS.~~

Nothing new for us, here.

## Statistical inference

Our approach will not match up neatly with Hayes's on this topic.

### Inference about the total effect of $X$ on $Y$.

As we mentioned in Chapter 2, we can indeed focus on rejecting $H_0$ when using Bayesian statistics. I, however, am not a fan of that approach and I will not be focusing on Bayesian $p$-values. But throughout this project, we will make great efforts to express the (un)certainty in our models with various plots of posterior distributions and summary statistics, such as measures of central tendency (e.g., means) and spread (e.g., percentile-based 95% intervals).

So instead of $t$- and $p$-values for $c'$, we are going to focus on the distribution. We already gave the mean and 95% intervals, above. Here's a look at the density.

```r
 draws %>%
  ggplot(aes(x = total_effect)) +
  geom_density(color = "transparent",
               fill = colorblind_pal()(3)[2]) +
  scale_y_continuous(NULL, breaks = NULL) +
  xlab(expression(paste(italic(c)," (i.e., the total effect)"))) +
  theme_classic()
```

### Inference about the direct effect of $X$ on $Y$.

Like in the last section, we will just look at the posterior distribution for the direct effect (i.e., $c'$, `b_reaction_cond`).

```r
draws %>%
  ggplot(aes(x = b_reaction_cond)) +
  geom_density(color = "transparent",
               fill = colorblind_pal()(4)[4]) +
  geom_vline(xintercept = 0, color = "white", linetype = 2) +
  scale_y_continuous(NULL, breaks = NULL) +
  labs(title = expression(paste("Yep, 0 is a credible value for ", italic("c"), ".")),
       x = NULL) +
  theme_classic()
```

If you wanted to quantify what proportion of the density was less than 0, you could execute something like this.

```r
draws %>%
  summarize(proportion_below_zero = mean(b_reaction_cond < 0))
```

```
## # A tibble: 1 × 1
##   proportion_below_zero
##                   <dbl>
## 1                 0.160
```

This is something like a Bayesian $p$-value. But of course, you could always just look at the posterior intervals.

```r
posterior_interval(model3.1)["b_reaction_cond", ]
```

```
##       2.5%      97.5%
## -0.2628266  0.7570081
```

### Inference about the indirect of $X$ on $Y$ through $M$.

> The indirect effect quantifies how much two cases that differ by a unit on $X$ are estimated to differ on $Y$ as a result of $X$'s influence on $M$, which in turn influences $Y$. The indirect effect is relevant as to [what extent] $X$'s effect on $Y$ can be said to be transmitted through the mechanism represented by the $X \rightarrow M \rightarrow Y$ causal chain of events. (p. 95)

#### The normal theory approach.

This is not our approach.

#### Bootstrap confidence interval.

This is not our approach.

However, Markov chain Monte Carlo (MCMC) methods are iterative and share some characteristics with boostrapping. On page 98, Hayes outlined 6 steps for constructing the $ab$ bootstrap confidence interval. Here are our responses to those steps w/r/t Bayes with MCMC--or in our case HMC (i.e., Hamiltonian Monte Carlo).

If HMC or MCMC, in general, are new to you, you might check out [this lecture](https://youtu.be/BWEtS3HuU5A) or the [*Stan Reference Manual*](https://mc-stan.org/docs/reference-manual/index.html) if you're more technically oriented.

Anyway, Hayes's 6 steps:

##### Step 1.

With HMC we do not take random samples of the data themselves. Rather, we take random draws from the posterior distribution. The posterior distribution is the joint probability distribution of our model.

##### Step 2.

After we fit our model with the `brm()` function and save our posterior draws in a data frame (i.e., `draws <- as_draws_df(my_model_fit)`), we then make a new column (a.k.a. vector, variable) that is the product of our coefficients for the $a$ and $b$ pathways. In the example above, this looked like `draws %>% mutate(ab = b_pmi_cond * b_reaction_pmi)`. Let's take a look at those columns.

```r
draws %>%
  select(b_pmi_cond, b_reaction_pmi, ab) %>%
  slice(1:10)
```

```
## # A tibble: 10 × 3
##    b_pmi_cond b_reaction_pmi     ab
##         <dbl>          <dbl>  <dbl>
##  1      0.205          0.526 0.108
##  2      0.637          0.549 0.350
##  3      0.246          0.568 0.140
##  4      0.873          0.445 0.389
##  5      0.346          0.553 0.192
##  6      0.435          0.496 0.216
##  7      0.609          0.512 0.312
##  8      0.195          0.453 0.0881
##  9      0.157          0.472 0.0741
## 10      0.757          0.549 0.416
```

Our `draws` data frame has 4,000 rows. Why 4,000? By default, **brms** runs 4 HMC chains. Each chain has 2,000 iterations, 1,000 of which are warmups, which we always discard. As such, there are 1,000 good iterations left in each chain and $1{,}000 \times 4 = 4{,}000$. We can change these defaults as needed.

Each row in `draws` contains the parameter values based on one of those draws. And again, these are draws from the posterior distribution. They are not draws from the data.

##### Step 3.

We don't refit the model $k$ times based on the samples from the data. We take a number of draws from the posterior distribution. Hayes likes to take 5,000 samples when he bootstraps. Happily, that number is quite similar to our default 4,000 HMC draws. Whether 5,000, 4,000 or 10,000, these are all large enough numbers that the distributions become fairly stable. With HMC, however, you might want to increase the number of iterations if either measure of effective sample size, 'Bulk_ESS' and 'Tail_ESS' in the `print()` output, are substantially smaller than the number of iterations.

##### Step 4.

When we use the `quantile()` function to compute our Bayesian credible intervals, we've sorted. Conceptually, we've done this.

```r
draws %>%
  select(ab) %>%
  arrange(ab) %>%
  slice(1:10)
```

```
## # A tibble: 10 × 1
##         ab
##      <dbl>
##  1 -0.169
##  2 -0.151
##  3 -0.119
##  4 -0.118
##  5 -0.114
##  6 -0.112
##  7 -0.0969
##  8 -0.0852
##  9 -0.0809
## 10 -0.0804
```

##### Step 5.

Yes, this is what we do, too.

```r
ci <- 95

0.5 * (100 - ci)
```

```
## [1] 2.5
```

##### Step 6.

This is also what we do.

```r
ci <- 95

(100 - 0.5 * (100 - ci))
```

```
## [1] 97.5
```

Also, notice the headers in the rightmost two columns in our `posterior_summary()` output:

```r
posterior_summary(model3.1)
```

```
##                          Estimate  Est.Error          Q2.5        Q97.5
## b_reaction_Intercept    0.5232358 0.55352497   -0.55282255    1.5844332
## b_pmi_Intercept         5.3779469 0.15465163    5.08149251    5.6749606
## b_reaction_pmi          0.5065599 0.09764479    0.31385098    0.6957816
## b_reaction_cond         0.2523672 0.25764158   -0.26282664    0.7570081
## b_pmi_cond              0.4782630 0.22688910    0.03540068    0.9287937
## sigma_reaction          1.4065683 0.09342141    1.23984559    1.6009736
## sigma_pmi               1.3154905 0.08394439    1.16517292    1.4909963
## lprior                 -6.6890553 0.03639370   -6.76662165   -6.6238346
## lp__                 -429.6149997 1.85613599 -434.22405270 -427.0217300
```

Those .025 and .975 quantiles from above are just what **brms** is giving us in our 95% Bayesian credible intervals.

Here's our version of Figure 3.5.

```r
# these will come in handy in the subtitle
ll <- quantile(draws$ab, probs = .025) %>% round(digits = 3)
ul <- quantile(draws$ab, probs = .975) %>% round(digits = 3)

draws %>%
  ggplot(aes(x = ab)) +
  geom_histogram(color = "white", linewidth = 0.25,
                 fill = colorblind_pal()(5)[5],
                 binwidth = .025, boundary = 0) +
  geom_vline(xintercept = quantile(draws$ab, probs = c(.025, .975)),
             linetype = 3, color = colorblind_pal()(6)[6]) +
  labs(subtitle = str_c("95% of the posterior draws are between ", ll, " and ", ul),
       x = expression(Indirect~effect~(italic(ab))),
       y = "Frequency in 4,000 HMC posterior draws") +
  theme_classic()
```

Again, as Hayes discussed how to specify different types of intervals in PROCESS on page 102, you can ask for different kinds of intervals in your `print()` or `summary()` output with the `probs` argument, just as you can with `quantile()` when working directly with the posterior draws.

Hayes discussed setting the seed in PROCESS on page 104. You can do this with the `seed` argument in the `brm()` function, too.

#### Alternative "asymmetric" confidence interval approaches.

This section does not quite refer to us. I'm a little surprised Hayes didn't at least dedicate a paragraph or two on Bayesian estimation. Sure, he mentioned Monte Carlo, but not within the context of Bayes. So it goes... But if you're interested, you can read about Bayesian intervals for mediation models in Yuan and MacKinnon's [-@yuanBayesianMediationAnalysis2009] [*Bayesian mediation analysis*](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2885293/pdf/nihms171111.pdf). And yes, Hayes is aware of this. He has cited it in his work [e.g., @hayesIndexTestLinear2015].

## An example with continuous $X$: Economic stress among small-business owners

Here's the `estress` data.

```r
estress <- read_csv("data/estress/estress.csv")

glimpse(estress)
```

```
## Rows: 262
## Columns: 7
## $ tenure   <dbl> 1.67, 0.58, 0.58, 2.00, 5.00, 9.00, 0.00, 2.50, 0.50, 0.58, 9.00, 1.92, 2.00, 1.42, 0.92, 2…
## $ estress  <dbl> 6.0, 5.0, 5.5, 3.0, 4.5, 6.0, 5.5, 3.0, 5.5, 6.0, 5.5, 4.0, 3.0, 2.5, 3.5, 6.0, 4.0, 6.0, 3…
## $ affect   <dbl> 2.60, 1.00, 2.40, 1.16, 1.00, 1.50, 1.00, 1.16, 1.33, 3.00, 3.00, 2.00, 1.83, 1.16, 1.16, 1…
## $ withdraw <dbl> 3.00, 1.00, 3.66, 4.66, 4.33, 3.00, 1.00, 1.00, 2.00, 4.00, 4.33, 1.00, 5.00, 1.66, 4.00, 1…
## $ sex      <dbl> 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0…
## $ age      <dbl> 51, 45, 42, 50, 48, 48, 51, 47, 40, 43, 57, 36, 33, 29, 33, 48, 40, 45, 37, 42, 54, 57, 37,…
## $ ese      <dbl> 5.33, 6.05, 5.26, 4.35, 4.86, 5.05, 3.66, 6.13, 5.26, 4.00, 2.53, 6.60, 5.20, 5.66, 5.66, 5…
```

The model set up is just like before. There are no complications switching from a binary $X$ variable to a continuous one.

```r
y_model <- bf(withdraw ~ 1 + estress + affect)
m_model <- bf(affect ~ 1 + estress)
```

With our `y_model` and `m_model` defined, we're ready to fit.

```r
model3.2 <- brm(
  data = estress,
  family = gaussian,
  y_model + m_model + set_rescor(FALSE),
  cores = 4,
  file = "fits/model03.02")
```

Let's take a look at the results.

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

```
##  Family: MV(gaussian, gaussian)
##   Links: mu = identity; sigma = identity
##          mu = identity; sigma = identity
## Formula: withdraw ~ 1 + estress + affect
##          affect ~ 1 + estress
##    Data: estress (Number of observations: 262)
##   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
## withdraw_Intercept    1.447     0.252    0.941    1.939 1.001     6104     3178
## affect_Intercept      0.801     0.144    0.520    1.078 0.999     5670     2713
## withdraw_estress     -0.077     0.052   -0.176    0.025 1.002     5583     2865
## withdraw_affect       0.769     0.102    0.568    0.971 1.000     6092     3573
## affect_estress        0.172     0.030    0.115    0.231 0.999     5979     2635
##
## Family Specific Parameters:
##                Estimate Est.Error l-95% CI u-95% CI  Rhat Bulk_ESS Tail_ESS
## sigma_withdraw    1.137     0.050    1.044    1.237 1.001     6604     2757
## sigma_affect      0.685     0.031    0.629    0.752 1.000     6054     3071
##
## 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).
```

The 'Rhat', 'Bulk_ESS', and 'Tail_ESS' values look great. Happily, the values in our summary cohere well with those Hayes reported in Table 3.5. Here are our $R^2$ values.

```r
bayes_R2(model3.2)
```

```
##             Estimate  Est.Error       Q2.5     Q97.5
## R2withdraw 0.1826110 0.03810231 0.10802441 0.2576083
## R2affect   0.1163637 0.03415353 0.05366559 0.1869456
```

These are also quite similar to those in the text. Here's our indirect effect.

```r
# putting the posterior draws into a data frame
draws <- as_draws_df(model3.2)

# computing the ab coefficient with multiplication
draws <- draws %>%
  mutate(ab = b_affect_estress*b_withdraw_affect)

# getting the posterior median and 95% intervals with `quantile()`
quantile(draws$ab, probs = c(.5, .025, .975)) %>% round(digits = 3)
```

```
##   50%  2.5% 97.5%
## 0.131 0.081 0.193
```

We can visualize its shape, median, and 95% intervals in a density plot.

```r
draws %>%
  ggplot(aes(x = ab)) +
  geom_density(color = "transparent",
               fill = colorblind_pal()(7)[7]) +
  geom_vline(xintercept = quantile(draws$ab, probs = c(.025, .5, .975)),
             color = "white", linetype = c(2, 1, 2), size = c(.5, .8, .5)) +
  scale_x_continuous(breaks = quantile(draws$ab, probs = c(.025, .5, .975)),
                     labels = quantile(draws$ab, probs = c(.025, .5, .975)) %>% round(2) %>% as.character()) +
  scale_y_continuous(NULL, breaks = NULL) +
  labs(title = expression(Behold~our~italic("ab")*'!'),
       x = NULL) +
  theme_classic()
```

```
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
```

Here's $c'$, the direct effect of `esterss` predicting `withdraw`.

```r
posterior_summary(model3.2)["b_withdraw_estress", ]
```

```
##    Estimate   Est.Error        Q2.5       Q97.5
## -0.07672057  0.05164764 -0.17575304  0.02536043
```

It has wide flapping intervals which do straddle zero.


text:
# Home Movies

This application is written with dotnetcore 2.0. The UI is written in Angular.

You will need the dotnetcore sdk and nodejs to be able to build/run this app.

The following are instructions of how to build/run the app after cloning this repository.

## Building

```powershell
cd HomeMovies
npm install -g @angular/cli
npm install
npm run build

dotnet restore
dotnet build
dotnet run
```

Once the server starts running you will be able to access the application using this url: `http://localhost:51815`

repository: oleachka/home-movies

repo_name: oleachka/home-movies


text:
# Signal

A simple way for triggered shutdown by system signals

# Usage

```go
package main

import (
	"github.com/lygo/runner"
	"github.com/lygo/runner/plugin/signal"
	"github.com/lygo/runner/examples/someapp"
)

func main() {
    app := someapp.New(someapp.NewConfig())

    // or it can be used inner someapp.New
    signal.RegisterShutdownBySignals(app)

    app.Run()
    <-app.Started

    os.Exit(<-app.Done)
}

```

repository: lygo/runner

gha_language: Go

repo_name: lygo/runner


text:
## Lib_Kafka
### Introduction
Lib_Kafka is a python library for Robotframework to test Kafka. It's based on open source project [pykafka](https://github.com/Parsely/pykafka).

The goal of LibKafka contains:
* Producer: Produce the specific events to Kafka.
* Consumer: Wait the specific event assertion from Kafka.

### Get Started
#### How to use?
```
1. pip install pykafka
2. Including the Lib_Kafka.py in Robotframework script. And start to call the following keyword function from Robotframework.
```
#### Functions - event_consumer
Waiting to get event from Kafka for a period of time from specific topic.

```
String event_consumer(host_kafka, host_zookeeper, topic, assertion_event_content, match_partially=False, timeout_sec=20)
```

#### Parameters
Required | Parameters              | Description                                 | Default Value | Example
-------- | ----------------------- | ------------------------------------------- | ------------- | -------------
   O     | host_kafka              | Kafka broker host:IP                        | N/A           | <IP_ADDRESS>:9092
   O     | host_zookeeper          | Zookeeper host:IP                           | N/A           | <IP_ADDRESS>:2181
   O     | topic                   | Topic name for receiving events             | N/A           | test_topic
   O     | assertion_event_content | Specific event content assertion            | N/A           | Stop_event
   X     | match_partially         | Match partially/all event content assertion | False         | True
   X     | timeout_sec             | Timeout seconds                             | 20            | 30

#### Return Values
Values             | Description
------------------ | -------------------------------------------------------------------
GotEvent           | Got the specific event content from specific topic before timeout
Timeout            | Didn't received specific event content from specific topic timeout
KafkaConnectFailed | Can't connect to specific Kafka host

#### Functions - event_consumer_multiple_match_partially
Waiting to get multiple event assertion of single event from Kafka for a period of time from specific topic.

```
String event_consumer_multiple_match_partially(host_kafka, host_zookeeper, topic, assertion_event_content_arr, timeout_sec=20)
```

#### Parameters
Required | Parameters                  | Description                                 | Default Value | Example
-------- | --------------------------- | ------------------------------------------- | ------------- | -------------
   O     | host_kafka                  | Kafka broker host:IP                        | N/A           | <IP_ADDRESS>:9092
   O     | host_zookeeper              | Zookeeper host:IP                           | N/A           | <IP_ADDRESS>:2181
   O     | topic                       | Topic name for receiving events             | N/A           | test_topic
   O     | assertion_event_content_arr | Specific event content assertion            | N/A           | [Stop_event, A, B]
   X     | timeout_sec                 | Timeout seconds                             | 20            | 30

#### Return Values
Values             | Description
------------------ | -------------------------------------------------------------------
GotEvent           | Got all assertion of specific event content from specific topic before timeout
Timeout            | Didn't received specific event content or part of the assertion didn't match from specific topic and reached timeout_sec
KafkaConnectFailed | Can't connect to specific Kafka host

#### Functions - event_single_consumer
Waiting to get single event from Kafka for a period of time from specific topic.

```
String event_single_consumer(host_kafka, host_zookeeper, topic, timeout_sec=20)
```

#### Parameters
Required | Parameters              | Description                                 | Default Value | Example
-------- | ----------------------- | ------------------------------------------- | ------------- | -------------
   O     | host_kafka              | Kafka broker host:IP                        | N/A           | <IP_ADDRESS>:9092
   O     | host_zookeeper          | Zookeeper host:IP                           | N/A           | <IP_ADDRESS>:2181
   O     | topic                   | Topic name for receiving events             | N/A           | test_topic
   X     | timeout_sec             | Timeout seconds                             | 20            | 30

#### Return Values
Values             | Description
------------------ | -------------------------------------------------------------------
GotEvent           | Got the specific event content from specific topic before timeout
Timeout            | Didn't received specific event content from specific topic timeout
KafkaConnectFailed | Can't connect to specific Kafka host

#### Functions - event_consume_to_latest
Consume the event from specific topic to latest offset

```
String event_consume_to_latest(host_kafka, host_zookeeper, topic)
```

#### Parameters
Required | Parameters              | Description                                 | Default Value | Example
-------- | ----------------------- | ------------------------------------------- | ------------- | -------------
   O     | host_kafka              | Kafka broker host:IP                        | N/A           | <IP_ADDRESS>:9092
   O     | host_zookeeper          | Zookeeper host:IP                           | N/A           | <IP_ADDRESS>:2181
   O     | topic                   | Topic name for receiving events             | N/A           | test_topic

#### Return Values
Values             | Description
------------------ | -------------------------------------------------------------------
ConsumeDone        | Consume the event to the latest offset
Error              | Error when consuming event
KafkaConnectFailed | Can't connect to specific Kafka host

#### Functions - event_producer
Produce the events to Kafka.

```
String event_producer(host_kafka, topic, event_content_arr, wait_ack=False)
```

#### Parameters
Required | Parameters              | Description                                               | Default Value | Example
-------- | ----------------------- | --------------------------------------------------------- | ------------- | -------------
   O     | host_kafka              | Kafka broker host:IP                                      | N/A           | <IP_ADDRESS>:9092
   O     | topic                   | Topic name for sending events                             | N/A           | test_topic
   O     | event_content_arr       | Event content array                                       | N/A           | A B C Stop_event
   X     | wait_ack                | While sending the events, should wait for the ack or not. | False         | True

#### Return Values
Values             | Description
------------------ | -------------------------------------------------------------------
SendSuccess        | All the events is send successfully
SendFailed         | Part of/All of the events send failed
KafkaConnectFailed | Can't connect to specific Kafka host

repository: automatedguy/robotframework-kafka

repo_name: automatedguy/robotframework-kafka


text:
gearman client/worker for asyncio
==============================

Requirements
------------

- Python 3.3

- asyncio http://code.google.com/p/tulip/

License
-------

gearman is offered under the BSD license.

repository: Lupino/aiogear

repo_name: Lupino/aiogear


text:
# leiningen

## Description

Leiningen is a project automation tool for Clojure.
This module downloads the leiningen bootstrap script to a specified executable directory, and sets executable permissions on it.

### Beginning with leiningen

    node default {
      require leiningen
    }

See init.pp for parameters.
Note that the module does not execute leiningen and perform the actual bootstrapping. This will happen implicitly the first time you attempt a lein command.

## Reference

### Leiningen

http://leiningen.org/

## Limitations

Only tested on EL7.
May not work on Windows due to https://github.com/maestrodev/puppet-wget/issues/72

repository: james-stocks/puppet-leiningen

gha_language: Puppet

repo_name: james-stocks/puppet-leiningen


text:
Display Manager
===============

[![License][license-img]][license-url]
[![GitHub Release][release-img]][release-url]
[![Github Releases][downloads-img]][downloads-url]
[![GitHub Issues][issues-img]][issues-url]

> A command line tool for recording and restoring Windows display configurations

## Use Case

* You have a Windows 8/10 PC with a couple of monitors / flatscreen TVs attached
* You are not always using all of your monitors, instead you like to switch between different display configurations

## Usage

This tool is quite minimalistic.

1. Use the Windows display settings dialog to configure your monitors to your liking
2. Run `DisplayMan.exe --save MyDisplayConfigA.xml` on the command line
3. Configure your monitors in another way
4. Run `DisplayMan.exe --save MyDisplayConfigB.xml`

Now you have two recorded configurations and you can toggle between them

1. Run `DisplayMan.exe --load MyDisplayConfigB.xml`
2. Run `DisplayMan.exe --load MyDisplayConfigA.xml`

It is a good idea to create links (shortcuts) for the different configurations, with nice icons, of course.
You can place these links on the desktop or in a toolbar inside the taskbar.

![Shortcuts in Taskbar](img/taskbar.png)

## Help Text

```
Mastersign DisplayManager
-------------------------
Version: 1.1.0

Usage:
  DisplayMan
      With no arguments: Show the current display configuration.
  DisplayMan <file path>
      With one file path as the only argument:
      Load display configuration from XML file persistently.
  DisplayMan [<options>]*
      With one or more options: See descriptions below.

Options:

  -h, --help, -?, /?
      Does print this help text. Ignores all other options.

  -v, --version
      Prints version information. Ignores all other options.

  -i, --info, --show-config
      Show the current display configuration.

  -s, --save, --record <target file>
      Write the current display configuration to an XML file.

  -l, --load, --restore <source file>
      Loads the display configuration from the specified XML file.
      If this option is used, the --reset option is ignored.
      By default, the configuration is loaded temporarily.

  -p, --persistent
      If loading a display configuration, makes the new configuration
      persistent.

  -r, --reset
      Resets the display configuration to the last persistent state.
      Can be used to switch back after loading a display configuration
      temporarily.
```

## Hotkeys

A good combination also, is to run `DisplayMan.exe` with [AutoHotkey](https://autohotkey.com).

As a preparation, you need to place a copy of the AutoHotkey executable,
named `hotkeys.exe`, in the same folder as `DisplayMan.exe`.
Then create a AutoHotkey script, named `hotkeys.ahk`, besides `hotkeys.ahk`.
What is important, is that the script file has the same name as the executable.
This way you can just start `hotkeys.exe` and it will find the AHK script
by itself.

To switch to `C:\Users\Me\Documents\MyDisplayConfigA.xml` by pressing `Win` + `Ctrl` + `A`,
you can use the following script (for AutoHotkey version 1.1) as a starting point:

```ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

SwitchToDisplayConfig(configFile)
{
    run, "%A_ScriptDir%\DisplayMan.exe" --load "%configFile%", %A_ScriptDir%, Min
}

#^A::SwitchToDisplayConfig("C:\Users\Me\Documents\MyDisplayConfigA.xml")
```

Now place a link (shortcut) for `hotkeys.exe` in your startmenus autorun folder,
and you can use the hotkey(s) even after a reboot.

## Technical Insight

This tool makes use of the [Windows API for Connecting and Configuring Displays](https://msdn.microsoft.com/en-us/library/windows/hardware/hh406259.aspx).
This API is available since Windows 7.
It only uses the methods
`QueryDisplayConfig`, `GetDisplayConfigBufferSize` and `SetDisplayConfig` in the `User32.dll`.
It does nothing more then to query the current configuration
and store it with the .NET XML serialization into a file.
For restore, it just loads the configuration with .NET XML deserializaton and passes them to the Windows API.

## Acknowledgements

After spending quite some time with the older API (`EnumDisplayDevices`, `ChangeDisplaySettings`, ...)
I finally found the [question](https://stackoverflow.com/questions/16082330)
of [Erti-Chris Eelmaa](https://stackoverflow.com/users/1936622)
with the answer from [Stephen Martin](https://stackoverflow.com/users/12845)
and edits from [Lennart](https://stackoverflow.com/users/368354) and
[David Heffernan](https://stackoverflow.com/users/505088)
on StackOverflow.
The rest was easy. Thanks a lot guys, you saved my day!

## License

This project is released under the MIT license.

Copyright © by Tobias Kiertscher<EMAIL_ADDRESS>
[release-url]: https://github.com/mastersign/Mastersign.DisplayManager/releases/latest/
[release-img]: https://img.shields.io/github/release/mastersign/Mastersign.DisplayManager.svg?style=flat-square
[downloads-url]: https://github.com/mastersign/Mastersign.DisplayManager/releases/latest/
[downloads-img]: https://img.shields.io/github/downloads/mastersign/Mastersign.DisplayManager/total.svg?style=flat-square
[license-url]: https://github.com/mastersign/Mastersign.DisplayManager/blob/master/LICENSE.md
[license-img]: https://img.shields.io/github/license/mastersign/Mastersign.DisplayManager.svg?style=flat-square
[issues-url]: https://github.com/mastersign/Mastersign.DisplayManager/issues
[issues-img]: https://img.shields.io/github/issues/mastersign/Mastersign.DisplayManager.svg?style=flat-square


text:
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [`testcase` Documentation](#testcase-documentation)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# `testcase` Documentation

- [Spec](/docs/spec)
- [BDD](/docs/bdd.md)
- [nesting](/docs/nesting.md)
- [why](/docs/why.md)

repository: hemantjadon/testcase

repo_name: hemantjadon/testcase


text:
---
layout: post
title: Notes for which we continue learning after IBM open project course
---

 1. The SEARCH verb (sequential and binary variations) is used quite often in Cobol programs.

Interview question: "Explain table handling in Cobol."  Hint: Use the SEARCH verb and the REDEFINES clause in the DATA DIVISION.

 2. Study 88 level items in the DATA DIVISION, what they are and how to use them. Also involves the SET verb.

 3. INSPECT and INSPECT REPLACING (older IBM pre-COBOL II compilers used EXAMINE), is used quite often.

 4. Making 2 fields print on the same line together (e.g. first and last name) without blank space in between, is also a concept.  Hint:  use the STRING verb.

 5. Study the UNSTRING verb.

 6. Look at the COBOL Language Reference Manual, and study all the available reserved words in Chapter 20. Learn their purpose and what they do. IBM Cobol Language Reference Manual v6.3 http://publibfp.boulder.ibm.com/epubs/pdf/igy6lr30.pdf.

 7. Study the Cobol intrinic functions available, Chapter 21 of the same manual.

 8.  Don't ever use the GO TO verb, no need to use it.

 9. Don't ever use the ALTER (GO TO) verb, and pray you don't run into any programs that do.

 10. Avoid tying your program up in "NOT"s (for non-English speakers, this is a play on words; the word "not" vs. the word "knot"), i.e. don't ever use NOT in conditional statements, or at least very sparingly.  You can use CONTINUE (nop in other languages) to accomplish the same thing with positive, rather than negative logic.

 11.  Study the case structure verb, EVALUATE, EVALUATE TRUE, and EVALUATE variable-name.  Be sure to use WHEN OTHER as a final condition in an EVALUATE statement.

 12. Next, you should familiarize yourself with JCL.  Study the examples.  z/OS MVS JCL Reference v2r3, https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3SA231385/$file/ieab600_v2r3.pdf

 13. Then after all that, study the DFSORT manual (and also ICETOOL).  Sorting (using DFSORT or a 3rd party software product, e.g. SYNCSORT is very common) is heavily used in commercial (real world) environments. If you only learn one general use utility, this is the one to learn.  DFSORT Application Programming Guide, v2r3, https://www-01.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc236878/$file/icea100_v2r3.pdf  Most of you here probably already know how to program in other languages better than I.  What will be most beneficial to you, is to learn many of the unique things about Cobol (the above items are a start), and understand why Cobol is well suited to process transactions, i.e. processing files containing lines of data to process, whether to update another output "flat" file or a database.

 Lots of things to study, learn and try.  And ask questions in this forum for the benefit of all, perhaps to motivate others here to learn another thing or two that they didn't already know!  Good luck! (edited)

url: https://raw.githubusercontent.com/Dlthomass/dlthomass.github.io/23850a74efca49ba35cec6dd0a8b940bad390215/_posts/2020-4-21- Slack talking about COBOL learn.md


text:
# Function codomain

https://en.wikipedia.org/wiki/Codomain
https://proofwiki.org/wiki/Definition:Codomain_(Set_Theory)/Relation

The codomain of a function
, or the target set,
is the set into which
all of the output of the function
is constrained to fall.

It is the set Y in the notation f: X → Y.

The term range is sometimes ambiguously used to refer to either the codomain or image of a function.

A codomain is part of a function f if f is defined as a triple (X, Y, G) where X is called the domain of f, Y its codomain, and G its graph.

The set of all elements of the form f(x), where x ranges over the elements of the domain X, is called the image of f. The image of a function is a subset of its codomain so it might not coincide with it. Namely, a function that is not surjective has elements y in its codomain for which the equation f(x) = y does not have a solution.

A codomain is not part of a function f if f is defined as just a graph.
For example in set theory it is desirable to permit the domain of a function to be a proper class X, in which case there is formally no such thing as a triple (X, Y, G). With such a definition functions do not have a codomain, although some authors still use it informally after introducing a function in the form f: X → Y.

---

A codomain of a function is the target set in operations or relations on two sets.

Given two sets `A` and `B`, where `∀a ∈ A` and `∀b ∈ B`, set `B` is the codomain:
- in set operations (union, intersection, etc.), e.g. `A U B = {a ∨ b}`
- in the dot product, `A x B = {(a,b)}`
- in relations on sets, `aRb` i.e. `{(a,b)} = R ⊆ A x B`
- in functions, `f :: A -> B` and `f = {(a,b)}`

The codomain set is sometimes denoted by $$B_{cod}$$.

license: Unlicense


text:
- Tests

        Contain the Testcase Robot file based on below DB source,
		01_SRC_RODS- RODS
		02_SRC_MEDS- MEDS
		03_SRC_IMED- IMEDIDATA
		04_SRC_DALTON- DALTON
                05_SRC_SBJ- SUBJECTS

-Execution

         Command: robot -d Results/R2M_Results Tests/RODS_TO_MEDS
         use for debug: robot -d Results/R2M_Results -L DEBUG Tests/RODS_TO_MEDS
         use to run parallel execution: pabot -d Results/R2M_Results Tests/RODS_TO_MEDS
         use when no tags: robot -d Results/R2M_Results -r NONE -l NONE -o NONE  Tests/RODS_TO_MEDS
         use for tag: robot -d Results/R2M_Results -r NONE -l NONE -o NONE -v Default_Tag:Smoke  Tests/RODS_TO_MEDS

- Results

        Contains execution results in different formats like html and xml. Also generates a csv file that holds source/target counts and exceptions along with a study name used for comparison

branch_name: refs/heads/Production

gha_language: RobotFramework

gha_license_id: Unlicense


text:
# Contributing to this repository <!-- omit in toc -->

## Getting started <!-- omit in toc -->

Before you begin:
- Have you read the [code of conduct](CODE_OF_CONDUCT.md)?
- Check out the [existing issues](https://github.com/figment-networks/kong-plugin-connections-quota/issues).

### Ready to make a change? Fork the repo

Fork using GitHub Desktop:

- [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop.
- Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)!

Fork using the command line:

- [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them.

Fork with [GitHub Codespaces](https://github.com/features/codespaces):

- [Fork, edit, and preview](https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces/creating-a-codespace) using [GitHub Codespaces](https://github.com/features/codespaces) without having to install and run the project locally.

### Make your update:
Make your changes to the file(s) you'd like to update.

### Self review
You should always review your own PR first.

Make sure that:
- [ ] Linter do not complains (`pongo lint`)
- [ ] Your changes are covered in specs
- [ ] Run tests and check if they all passed (`KONG_VERSION=nightly pongo run`)
- [ ] If there are any failing checks in your PR, troubleshoot them until they're all passing.

### Open a pull request
When you're done making changes and you'd like to propose them for review open your PR (pull request) with a clear list of what you've done.
Make sure you included specs.
Always write a clear log message for your commits. One-line messages are fine for small changes

### Submit your PR & get it reviewed
- Once you submit your PR, we will review it. The first thing you're going to want to do is a [self review](#self-review).
- After that, we may have questions, check back on your PR to keep up with the conversation.
- Did you have an issue, like a merge conflict? Check out [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) on how to resolve merge conflicts and other issues.

### Your PR is merged!
Congratulations! The whole community thanks you. :sparkles:

repository: infwonder/kong-plugin-connections-quota

repo_name: infwonder/kong-plugin-connections-quota


text:
# Abstract Factory

An abstract factory defines an interface to construct a variety of
closely related objects. The example here (**CarPartFactory**)
provides an interface to construct a variety of car parts so that a
car can be constructed. The concrete factories
(**MercedesCarPartsFactory**, **BMWCarPartsFactory**) then
specifically define how to construct parts for each type of car.

By providing a **CarPartFactory** (either for a Mercedes or BMW), the
**CarFactory** can construct a car without knowing about the specific
concrete classes used for each car part. CarFactory can create an
engine, 2 doors, and 4 wheels, but the the implementation (whether
it is a BMW or a Mercedes) is abstracted away.

You can create each car as follows:
```
Car bmw = new CarFactory(new BMWCarPartsFactory()).createCar();
Car mercedes = new CarFactory(new MercedesCarPartsFactory()).createCar();
```
where both BMWCarPartsFactory and BMercedesCarPartsFactory both
implement CarPartsFactory.