text:
---
layout: website-normal
title: Global Web Fabric
toc: /guide/toc.json
---

This example shows how to build a multi-site web application *fabric*
with DNS configured on the front-end to combine the sites,
routing users to the location closest to them.

It can combine with the [Simple Web Cluster](../webcluster) example
or the [Portable Cloud Foundry](https://github.com/cloudsoft/brooklyn-cloudfoundry) example,
but does not assume knowledge of either of these.

{% read ../before-begin.include.md %}

Now, go to this particular example's directory:

{% highlight bash %}
% cd global-web-fabric
{% endhighlight %}

The CLI needs to know where to find your compiled examples. You can set this up by exporting
the ``BROOKLYN_CLASSPATH`` environment variable in the following way:

{% highlight bash %}
% export BROOKLYN_CLASSPATH=$(pwd)/target/classes
{% endhighlight %}

The project ``global-web-fabric`` contains the code used
in this example under ``src/main/java``.

### Setting Up Geographic DNS

This example uses [geoscaling.com](http://www.geoscaling.com) to provide **free** geographic-dependent DNS services.
This will forward a domain name of your choice to various IPs depending on a script,
e.g. computing the nearest IP based on latitude and longitude of the requester and the targets.
Brooklyn will automatically generate and update this script, but you do need to
create and configure a Geoscaling account:

 1. Create the free account [here](https://www.geoscaling.com/dns2/?module=register).
 1. Click the link in the email you receive.
 1. Enter the domain name you wish to use into geoscaling (see below).

The simplest domain name to choose is something unique under `geopaas.org`, e.g. `yourname.geopaas.org`,
which we have already configured for Geoscaling to manage.
If you are using your own domain name,
set its nameservers as advised by geoscaling (e.g. `ns{1,2,3,4}.geoscaling.com`).

Next we need to supply this information to Brooklyn at runtime.
The simplest way is to create or add the following fields to `~/.brooklyn/brooklyn.properties`:

{% highlight bash %}
brooklyn.geoscaling.username=yourname
brooklyn.geoscaling.password=s3cr3t
brooklyn.geoscaling.primaryDomain=yourname.geopaas.org
{% endhighlight %}

Replace the values of these fields as appropriate, of course!
You can, if you prefer, supply (or override) these values in your Brooklyn application.

### Setting Up the Locations Database

In order to generate the "closest-IP" script,
Brooklyn needs a way to find out the latitude and longitude of the
servers you are using.
The simplest way to do this is do download the free GeoCityLite binary flatfile
from [MaxMind](http://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads),
unpack it, and copy it to `~/.brooklyn/GeoLite2-City.mmdb`.

This will be picked up automatically if it is installed.
You can instead specify to use an online lookup service, such as
[utrace.de](http://www.utrace.de) by specifying
`-Dorg.apache.brooklyn.core.location.geo.HostGeoLookup=UtraceHostGeoLookup`;
but note this has a cap of 100 per day.

This information is also used to display locations on the map
in the Brooklyn dashboard.
Note however that these free services are not 100% accurate;
they are handy for dev/test but in a production system
you may wish to specify the geographical information manually in your application,
or purchase a commercial locations-database subscription.

## The Code

Now let's start writing our application.
The heavy lifting will be done by off-the-shelf Brooklyn classes:

 * `DynamicFabric` will create the entity specified by `factory` in each location it is given
 * `GeoscalingDnsService` monitors children of a specified entity (the `DynamicFabric`)
   and adds them as DNS targets for the region they are in

First, however, let's create the Java class -- call it `GlobalWebFabricExample`.
This will extend the Brooklyn `AbstractApplication`:

{% highlight java %}
package brooklyn.demo;

import static com.google.common.base.Preconditions.checkNotNull;
import org.apache.brooklyn.core.entity.AbstractApplication;

public class GlobalWebFabricExample extends AbstractApplication {
    @Override
    public void init() {
         // TODO create our app!
    }
}
{% endhighlight %}

### The Fabric

The `DynamicFabric` by default has no knowledge of what it will build,
other than the `factory` it is given to create an entity in each region.
We'll use the class `ElasticJavaWebAppService.Factory` which creates
an elastic Java Web App service,
such as the `ControlledDynamicWebAppCluster` used in the
[Simple Web Cluster](../webcluster) example, if deploying to VMs,
or perhaps a `CloudFoundryJavaWebAppCluster` if deploying to a Cloud Foundry location
(see [brooklyn-cloudfoundry repo](https://github.com/cloudsoft/brooklyn-cloudfoundry)).

{% highlight java %}
        DynamicFabric webFabric = addChild(EntitySpec.create(DynamicFabric.class)
                .displayName("Web Fabric")
                .configure(DynamicFabric.FACTORY, new ElasticJavaWebAppService.Factory())
                .configure(ElasticJavaWebAppService.ROOT_WAR, WAR_PATH));
{% endhighlight %}

Here we have specified the WAR to use with `configure(ElasticJavaWebAppService.ROOT_WAR, WAR_PATH)`.
The war configuration used in the previous example is only available on web-aware entities;
configuration specified with a ConfigKey can be done on any entity,
and is inherited at runtime, so this provides a useful way to specify the WAR to use
even though the web-aware entities are only constructed at runtime.

### Stitching the Fabric together with DNS

To stitch these together seamlessly, another entity will run a policy
which collects the public-facing IP address of each cluster created by the fabric,
as it comes online, by watching for `SERVICE_UP` sensors.
First, however, let's make sure any load-balancer proxies (e.g. nginx) in these clusters
are listening on port 80:

{% highlight java %}
        DynamicFabric webFabric = addChild(EntitySpec.create(DynamicFabric.class)
                .displayName("Web Fabric")
                .configure(DynamicFabric.FACTORY, new ElasticJavaWebAppService.Factory())
                .configure(ElasticJavaWebAppService.ROOT_WAR, WAR_PATH)
                .configure(AbstractController.PROXY_HTTP_PORT, PortRanges.fromInteger(80)));
{% endhighlight %}

Let's now define the Geoscaling entity which does the stitching.
We need to supply the username, password, and primaryDomainName for Geoscaling;
we'll take this from the `brooklyn.properties` file mentioned above.
We'll also specify a `smartSubdomainName`, to use Geoscaling's facility for
lightweight sub-domains to prevent DNS caching and multiple instances of our application
from confusing us -- e.g. `brooklyn-1234.yourname.geopaas.org`.

{% highlight java %}
        StringConfigMap config = getManagementContext().getConfig();

        GeoscalingDnsService geoDns = addChild(EntitySpec.create(GeoscalingDnsService.class)
                .displayName("GeoScaling DNS")
                .configure("username", checkNotNull(config.getFirst("brooklyn.geoscaling.username"), "username"))
                .configure("password", checkNotNull(config.getFirst("brooklyn.geoscaling.password"), "password"))
                .configure("primaryDomainName", checkNotNull(config.getFirst("brooklyn.geoscaling.primaryDomain"), "primaryDomain"))
                .configure("smartSubdomainName", "brooklyn"));
{% endhighlight %}

Lastly we need to tell this instance what entity it should monitor
for children to include as targets:

{% highlight java %}
        geoDns.setTargetEntityProvider(webFabric);
{% endhighlight %}

### Cloud Foundry and other PaaS Targets

At this point our core application is ready, and can be deployed to AWS or another VM cloud.
This may take between 15 and 30 minutes to run,
mainly spent downloading software
(unless of course you specify a pre-configured `imageId` which contains the software).

A quicker alternative is to deploy to a Java Web App platform-as-a-service
such as Cloud Foundry.  A major advantage here is that they can provision very quickly,
in a matter of seconds.  Code for this can be found in the
[brooklyn-cloudfoundry repo](https://github.com/cloudsoft/brooklyn-cloudfoundry),
along with an example global-web-fabric app.

### Imports

Your imports should look as follows:

{% highlight java %}
import static com.google.common.base.Preconditions.checkNotNull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.config.StringConfigMap;
import org.apache.brooklyn.core.entity.AbstractApplication;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.entity.dns.geoscaling.GeoscalingDnsService;
import org.apache.brooklyn.entity.group.DynamicFabric;
import org.apache.brooklyn.entity.proxy.AbstractController;
import org.apache.brooklyn.entity.webapp.ElasticJavaWebAppService;
import PortRanges;
{% endhighlight %}

### Use of main method (optional)

In this example, we will use the brooklyn CLI launcher. However, it is possible to write your own main method.

The following static constants are assumed (most of these as in the [Simple Web Cluster](../webcluster) example and others):

 * `WAR_PATH`, pointing to the webapp to deploy (a default supplied as part of the Brooklyn examples is used here)
 * `DEFAULT_LOCATIONS`, containing a string spec of the locations to deploy to if none are supplied on the command-line;
   for this example `localhost` will frequently not work unless Geoscaling can see it
   (i.e. it has a public IP and appropriate firewall settings)

The code (which can safely be omitted) is as follows:

{% highlight java %}
import org.apache.brooklyn.launcher.BrooklynLauncher;
import org.apache.brooklyn.util.CommandLineUtil;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

// class definition, and rest of class goes here...

    public static final Logger log = LoggerFactory.getLogger(GlobalWebFabricExample.class);

    // points to the webapp to deploy (a default supplied as part of the Brooklyn examples is used here)
    public static final String WAR_PATH = "classpath://hello-world-webapp.war";

    // locations to deploy to if none are supplied on the command-line; for this example `localhost` will
    // frequently not work unless Geoscaling can see it (i.e. it has a public IP and appropriate firewall settings)
    static final List<String> DEFAULT_LOCATIONS = ImmutableList.of(
            "aws-ec2:eu-west-1",
            "aws-ec2:ap-southeast-1",
            "aws-ec2:us-west-1" );

    public static void main(String[] argv) {
        List<String> args = Lists.newArrayList(argv);
        String port =  CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
        String locations = CommandLineUtil.getCommandLineOption(args, "--locations", Joiner.on(",").join(DEFAULT_LOCATIONS));

        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
                .application(EntitySpec.create(StartableApplication.class, GlobalWebFabricExample.class).displayName("Brooklyn Global Web Fabric Example"))
                .webconsolePort(port)
                .locations(Arrays.asList(locations))
                .start();

        Entities.dumpInfo(app);
    }
{% endhighlight %}

## Running the Example

Now let's run this example.

{% highlight bash %}
${BROOKLYN_HOME}/bin/brooklyn launch --app brooklyn.demo.GlobalWebFabricExample \
--location jclouds:aws-ec2:eu-west-1,jclouds:aws-ec2:ap-southeast-1,jclouds:aws-ec2:us-west-1
{% endhighlight %}

The management web console will start,
followed by the web-app services in the locations specified
creating the VM's as needed.
Let's look at the management web console, on port 8081:

[![Web Console Map](console-map-w700.png "Web Console Map")](console-map.png)

This shows the targets (e.g. Ireland (AWS eu-west-1),  Singapore (AWS ap-southeast-1),  and California (AWS us-west-1)).
This also shows the current status of the application.

Navigating to the "applications" tab, we can view sensors, invoke effectors, control policies,
and track activity,
for instance if a cluster is slow to start and you want to find out what is going on
(you'll find additional information in the `brooklyn.log` file).
Let's drill down on the Geoscaling DNS entity's sensors:

[![Web Console Geoscaling Details](console-geoscaling-details-w700.png "Web Console Geoscaling Details")](console-geoscaling-details.png)

Here we see it has chosen `brooklyn-vOZ7b4BL.martincloudsoft.geopaas.org` as the geo-load-balanced domain name.
(Yours will be under `yourname.geopaas.org`, unless you chose a different domain earlier.)
We can also see the hosts it is forwarding to, one for each cluster, corresponding to the
children of the Web Fabric (propagated from the nginx hostnames, in the case of the ControlledDynamicWebAppCluster instances).

### Checking the Web App

Once Geoscaling reports at least one target, you should be able to access it on the geo-load-balanced domain name:

[![Our Deployed Application](geopaas-deployed-app-w700.png "Our Deployed Application")](geopaas-deployed-app.png)

Under the covers you are being routed to one of the clusters that has been deployed --
whichever one is closest to you.
(Due to DNS caching, at your machine or your ISP, clusters which come online after your first lookup
will not be picked up until TTL expires, typically 10m, although often more if DNS services don't respect TTL.)

### Checking DNS Information

Let's find out exactly where we were routed:

{% highlight bash %}
% dig brooklyn-csgFCzTm.geopaas.org

; <<>> DiG 9.4.3-P3 <<>> brooklyn-csgFCzTm.geopaas.org

;; QUESTION SECTION:
;brooklyn-csgFCzTm.geopaas.org. IN      A

;; ANSWER SECTION:
brooklyn-csgFCzTm.geopaas.org. 120 IN   CNAME   ec2-46-137-138-4.eu-west-1.compute.amazonaws.com.
ec2-46-137-138-4.eu-west-1.compute.amazonaws.com. 215 IN A <IP_ADDRESS>
{% endhighlight %}

This was run from Scotland so it seems a sensible choice.
(Some portions of the output from `dig` have been removed for readability.)

We can get more information by looking at the TXT records:

{% highlight bash %}
% dig +trace @ns1.geoscaling.com TXT brooklyn-csgFCzTm.geopaas.org

; <<>> DiG 9.4.3-P3 <<>> +trace @ns1.geoscaling.com TXT brooklyn-csgFCzTm.geopaas.org

...

geopaas.org.            86400   IN      NS      ns1.geoscaling.com.
geopaas.org.            86400   IN      NS      ns2.geoscaling.com.
geopaas.org.            86400   IN      NS      ns3.geoscaling.com.
geopaas.org.            86400   IN      NS      ns4.geoscaling.com.
;; Received 133 bytes from <IP_ADDRESS>#53(a2.org.afilias-nst.info) in 45 ms

brooklyn-csgFCzTm.geopaas.org. 300 IN   TXT     "Request from [54,-2]-(GB) directed to Ireland (IE)"
brooklyn-csgFCzTm.geopaas.org. 300 IN   TXT     "GeoScaling config auto-updated by Brooklyn 2012-04-26 12:27:25 UTC"
;; Received 189 bytes from <IP_ADDRESS>#53(ns3.geoscaling.com) in 60 ms
{% endhighlight %}

## Next Steps

This example has shown how to create a multi-region fabric, using the abstractions from
[jclouds](http://jclouds.org) under the covers to make it easy to access different hosting providers
simultaneously, and using higher-level abstractions in Brooklyn to mix PaaS systems with
bare-VM (or even bare-metal, if you specify fixed IPs).

This is meant as just the beginning however.
Here are some questions to think about and code challenges to give you a steer for what to explore next.

 1. The routines used at Geoscaling optimize for latency between the user and the location of the web-cluster.
    What other strategies might be used?  Cost?  Compliance?  How would you code these?

 2. This example ignores data, but you clearly can't do that in the real world.
    When big-data is involved, does this introduce other considerations for optimizing geo-location?

 3. Add a data tier to this system, such as MySQL or Mongo, or even Hadoop.
    You might start with a single instance or cluster,
    but the real fun starts with a fabric, and defining the synchronization/replication strategies
    between the different clusters.
    This isn't for the faint-hearted, but whatever you create will certainly be of interest
    to people in the Brooklyn community.
    Please [let us know](/guide/meta/contact.md) what you've built!


text:
# Re-reselect [![Build Status][ci-img]][ci]

Enhance **[Reselect][reselect] selectors** by wrapping `createSelector` function and returning a memoized **collection of selectors** indexed with the **cache key** returned by a custom **resolver function**.

Useful to **reduce selectors recalculation** when:
- the same selector is repeatedly **called with one/few different arguments**
- the same selector is **imported by different modules** at the same time

[reselect]:                     https://github.com/reactjs/reselect
[ci-img]:                       https://travis-ci.org/toomuchdesign/re-reselect.svg
[ci]:                           https://travis-ci.org/toomuchdesign/re-reselect

```js
import createCachedSelector from 're-reselect';

const selectorA = state => state.a;
const selectorB = state => state.b;

const cachedSelector = createCachedSelector(
    // Set up your Reselect selector as normal

    // reselect inputSelectors:
    selectorA,
    selectorB,
    (state, someArg) => someArg,

    // reselect resultFunc:
    (A, B, someArg) => expensiveComputation(A, B, someArg}),
)(
    // Resolver function used as map cache key
    // (It takes the same selector arguments and must return a string)
    // In this case it will use the second arguments as cache key
    (state, someArg) => someArg,
);

// 2 different selector are created and cached
const fooSelector = cachedSelector(state, 'foo');
const barSelector = cachedSelector(state, 'bar');

// "foo" hits the cache: "foo" selector is retrieved and called again
const fooAgain = cachedSelector(state, 'foo');
```

## Installation
```console
npm install re-reselect
```

## Why? + example
I found my self wrapping a library of data elaboration (quite heavy stuff) with reselect selectors (`getPieceOfData` in the example).

On each store update, I had to call the selector again again in order to retrieve all the pieces of data needed by my UI. Like this:

```js
getPieceOfData(state, itemId, 'dataA', otherArg);
getPieceOfData(state, itemId, 'dataB', otherArg);
getPieceOfData(state, itemId, 'dataC', otherArg);
```
What happens, here? `getPieceOfData` **selector cache is invalidated** on each call because of the changing 3rd `dataX` argument.

### Re-reselect solution
`createCachedSelector` keeps a private collection of selectors and store them by `key`.

`key` is the string output of the `resolver` function declared in selector initialization phase.

`resolver` is a custom function which receives the same arguments of final selector (in the example: `state`, `itemId`, `'dataX'`, `otherArgs`) and returns a `string` or `number`.

That said, I was able to configure `re-reselect` to create a map of selector using the 3rd argument as key:

```js
const getPieceOfData = createCachedSelector(
  state => state,
  (state, itemId) => itemId
  (state, itemId, dataType) => dataType
  (state, itemId, dataType, otherArg) => otherArg
  (state, itemId, dataType, otherArg) => expensiveComputation(state, itemId, dataType, otherArg),
)(
  (state, itemId, dataType) => dataType,    // Memoize by dataType
);
```
The final result is a normal selector taking the same arguments as before.

But now, each time a selector is called, the following happens:
- Run `resolver` function and get its result (the cache key)
- Look for a matching key from the cache
- Return a cached selector or create a new one if no matching key is found in cache
- Call selector with with provided arguments

**Re-reselect** stays completely optional and uses **your installed reselect** library under the hoods (reselect is declared as a **peer depenency**).

Furthermore you can use any custom selector (see [API](#api)).

### Other viable solutions

#### 1- Declare a different selector for each different call
Easy but doesn't scale.

#### 2- Declare a `makeGetPieceOfData` selector factory as explained in [Reselect docs](https://github.com/reactjs/reselect/tree/v2.5.4#sharing-selectors-with-props-across-multiple-components)

Fine, but has 2 downsides:
- Bloat your selectors module by exposing both `get` selectors and `makeGet` selector factories
- Two different selector instances given the same arguments will individually recompute and store the same result (read [this](https://github.com/reactjs/reselect/pull/213))

#### 3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector

This is what **re-reselect** actually does. It's quite verbose (since should be repeated for each selector), that's why I decided to move it into a separate module.

### How to wrap my existing selector with re-reselect?

```js
import { createSelector } from 'reselect';

export const getMyData = createSelector(
  selectorA,  // eg: selectors receive: (state, arg1, arg2)
  selectorB,
  selectorC,
  (A, B, C) => doSomethingWith(A, B, C),
);
```

Becomes:
```js
import createCachedSelector from 're-reselect';

export const getMyData = createCachedSelector(
  selectorA,  // eg: selectors receive: (state, arg1, arg2)
  selectorB,
  selectorC,
  (A, B, C) => doSomethingWith(A, B, C),
)(
  (state, arg1, arg2) => arg2,   // Use arg2 as cache key
);
```
Voilà!

## API

**Re-reselect** consists in just one method exported as default.

```js
import reReselect from 're-reselect';
```

### reReselect([reselect's createSelector arguments])(resolverFunction, selectorCreator = selectorCreator)

**Re-reselect** accepts your original [selector creator arguments](https://github.com/reactjs/reselect/tree/v2.5.4#createselectorinputselectors--inputselectors-resultfunc) and returns a new function which accepts **2 arguments**:

- `resolverFunction`
- `selectorCreator` *(optional)*

`resolverFunction` is a function which receives the same arguments of your selectors (and `inputSelectors`) and *must return a string or number*. The result is used as cache key to store/retrieve selector instances.

Cache keys of type `number` are treated like strings, since they are assigned to a JS object as arguments.

The resolver idea is inspired by [Lodash's .memoize](https://lodash.com/docs/4.17.4#memoize) util.

`selectorCreator` is an optional function in case you want to use custom selectors. By default it uses Reselect's `createSelector`.

## Todo's
- Consider to expose a cache clearing method
- Named exports?

license: MIT

repository: olslash/re-reselect

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: olslash/re-reselect


text:
# jupyterlab-katex

### WARNING
**This repository is deprecated. It has been moved to the [jupyter-renderers](https://github.com/jupyterlab/jupyter-renderers) repository**.

An extension for JupyterLab that provides [KaTeX](https://khan.github.io/KaTeX/) rendering for math.

The default LaTeX renderer in JupyterLab uses [MathJax](https://www.mathjax.org/),
which, while powerful, can be slow to render complex equations.
This extension substitutes the MathJax renderer with the KaTeX renderer.
KaTeX is much faster, at the cost of being less full-featured than MathJax.
If you want faster math processing and the subset of LaTeX provided by KaTeX is
sufficient for your purposes, this may be the extension for you!

If you equations are not rendering properly with this extension,
you probably will want to fall back to MathJax.

## Prerequisites

* JupyterLab 0.28

## Installation

To install this extension into JupyterLab (requires node 5 or later), enter the following in your terminal:

```bash
jupyter labextension install jupyterlab-katex
```

## Development

From the `jupyterlab-katex` directory, run

```bash
npm install
npm run build
jupyter labextension link .
```

You can then watch the `src` directory for changes by running
```bash
npm run watch
```
Launch JupyterLab in watch mode (`jupyter lab --watch`), and
it wil automatically pick up changes to the built assets
of this extension and rebuild the application.

repository: ian-r-rose/jupyterlab-katex

repo_name: ian-r-rose/jupyterlab-katex


text:
# TransactionSummary

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** |  |
**date** | **date** |  |
**amount** | **int** | The transaction amount in milliunits format |
**cleared** | **str** | The cleared status of the transaction |
**approved** | **bool** | Whether or not the transaction is approved |
**account_id** | **str** |  |
**deleted** | **bool** | Whether or not the transaction has been deleted.  Deleted transactions will only be included in delta requests. |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

repository: mike-halpin/ynab-client-python

repo_name: mike-halpin/ynab-client-python


text:
---
title: Making sense of COVID - it got us! But it won't get us
date: '2021-02-03'
slug: making-sense-of-covid-in-our-family
categories: []
tags: []
---

One theme of this blog has been posting about things that I think it's important to post about.

These are occasionally political, often professional (and maybe not _that_ important), and fairly
often personal. This one is in the last category and is an effort at making sense of COVID, specifically
COVID in our family, with one big caveat that we are okay and are going to be okay. Posting
here made more sense to me than posting on social media; that's not to say this will be fleshed
out or necessarily worthy of being a post, but here goes.

We've been cautious about COVID, in part because we've been able to. My wife started her internship
in a school two weeks ago, and, crappily, contracted COVID sometime last week, probably late last week.
This was disappointing, in part because she was _so_ cautious about COVID and making sure
that she and our son (and I) did not get it.  There were active
COVID cases at the school - part of what makes this disappointing.

Once Katie tested positive, we... well, we didn't spring into action. Often these kinds of
things require you to think quickly on your feet, and we didn't. Honestly, we thought that it was
certain that my son and I had it, too, but were asymptomatic or - more likely - were a few days
behind her. Katie put a mask on promptly, and, I did too. The first night was weird - were in this
liminal state. I had actually tried to make an appointment for a rapid test that same day,
but something weird happened with my appointment at CVS. Fortunately, when rescheduling,
I found an urgent care that could test my son and I both around noon the next day.

We isolated the next morning, except for immediately before we left for the appointment, when
Katie gave me a hand to get ready. We waited for around 30 minutes (outside - time which we
spent jumping over a puddle) at the urgent care and then had our tests done. 15 minutes later
we received the results, we were COVID negative. My first message to Katie was a bad word. We
spoke on the phone on the way home and discussed some options: we get a hotel, and Katie isolates
at home; Katie gets a hotel, and we isolate at home; we visit my parents, and Katie stays at home;
and, we stay at home and isolate in different rooms. We chose the last option and basically hoped
for the best. Our plan was for Katie to stay in our bedroom. I would sleep in our living room.
We have doors from our bedroom outside; we were able to use this to share (food, clothes) between us.
We bought the best HVAC system air filters I could find on Amazon. And so this is what we have done for the
last almost four days.

Thankfully, and most importantly, Katie is strong and is doing well. We are optimistic that
her symptoms will not be worse than mild-moderate. It is pretty weird to be doing this. I think
it is a good test of and testimony to the strength of our marriage. We are doing fine.

Our little one is doing fine. He misses his Mom a lot! It is very odd for him. He will need to
be home from daycare for at least 14 days. He and I will continue to get tested. Ultimately,
I feel very lucky. I have been able to cancel meetings and basically focus on my son and
Katie. I do not have to worry about employment and friends and family have been more than
supportive. So it is a weird, weird, weird time, and it is disappointing, and I am thankful.


text:
---
title: "Odoo Development: Create a settings page"
slug: odoo_development_create_a_settings_page
date: 2021-09-14T16:36:23+02:00
categories:
 - Odoo
tags:
 - odoo
 - development
 - tutorial
images:
 - /images/odoo_development.jpg
---

Odoo stores all module settings in the `res.config.settings` model. This model is based on the `models.TransientModel` class, which means that the settings data is not persisted with this model.

This is just nice to know. I will show how you can create a settings page for your Odoo module and let you know about its limitations.

<!--more-->

The examples are based on the Odoo App [Certificate Planner](https://github.com/Mint-System/Certificate-Planner).

We are going to complete four actions:
1. Inherit the settings model
2. Add settings view
3. Add settings menu and action
4. Get the settings param

## Inherit the settings model

Creating new settings fields is simple. Inherit the `res.config.settings` model and add new fields.

**models/res_config_settings.py**

```py
from odoo import fields, models

class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    title_page_text = fields.Char(string='Title Page Text',
        config_parameter='certificate_planer.title_page_text',
        default="This document contains confidential information and is proprietary to Example.")

    footer_text = fields.Char(string='Footer Text',
        config_parameter='certificate_planer.footer_text',
        default="Copyright by Example")
```

Not the `config_parameter` attributes. This will ensure that the fields value is also stored in the `ir.config_parameter` model.

In our example we have two configurable text fields. The usage of field types are limited to boolean, integer, float, char, selection or many2one.

## Add settings view

Next we create the settings view.

**views/res_config_settings.xml**

```xml
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

    <record id="res_config_settings_view_form" model="ir.ui.view">
        <field name="name">certificate_planer.res.config.settings.form</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="base.res_config_settings_view_form" />
        <field name="arch" type="xml">
            <xpath expr="//div[hasclass('settings')]" position="inside">
                <div class="app_settings_block" data-string="Certificate Planner" string="Certificate Planner" data-key="certificate_planer">

                    <h2>Demand Planner</h2>
                    <div class="row mt16 o_settings_container" id="certificate_planer_setting_container">
                        <div class="col-12 col-lg-12 o_setting_box" id="certificate_planer_text_block">

                            <div class="o_setting_right_pane">
                                <div class="text-muted">
                                    Text blocks for MDL report.
                                </div>
                                <div class="content-group">

                                    <div class="row mt16">
                                        <label class="col-lg-3 o_light_label" string="Title Page Text" for="title_page_text"/>
                                        <field name="title_page_text" class="oe_inline" style="width: 70% !important;"/>
                                    </div>

                                    <div class="row mt16">
                                        <label class="col-lg-3 o_light_label" string="Footer Text" for="footer_text"/>
                                        <field name="footer_text" class="oe_inline" style="width: 70% !important;"/>
                                    </div>

                                </div>
                            </div>

                        </div>
                    </div>

                </div>
            </xpath>
        </field>
    </record>

</odoo>
```

Wow, that's very bloated. This view definition describes the settings menu on the left side and the parameters on the right side of the settings page. Orient yourself by having a look at the rendered page:

![](/images/odoo-development-settings-page.png)

## Add settings menu and action

We have the setting fields and the view, now we can add an action that opens the settings view and a menu entry to call the action.

**views/menu.xml**

```xml
<odoo>
  ...

  <record id="settings_action" model="ir.actions.act_window">
    <field name="name">Settings</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">res.config.settings</field>
    <field name="view_mode">form</field>
    <field name="target">inline</field>
    <field name="context">{'module': 'certificate_planer'}</field>
  </record>
  ...

  <menuitem name="Settings"
    id="settings_menu"
    sequence="0"
    parent="certificate_planer.configuration_menu"
    action="certificate_planer.settings_action"/>
  ...

</odoo>
```

## Get the settings param

Finally, I'll give you an example on how to retrieve a stored settings value.

**report/document_report.py**

```py
return {
	...
	'title_page_text': self.env['ir.config_parameter'].sudo().get_param('certificate_planer.title_page_text'),
	'footer_text': self.env['ir.config_parameter'].sudo().get_param('certificate_planer.footer_text')
}
```

The settings values are stored in the `ir.config_parameter` model. Access permission checks must be skipped by using `sudo()`. The get param name is equal to  `config_parameter` attribute of the field definition.


text:
# Raspberry Turk

The Raspberry Turk is a robot that can play chess—it's entirely open source, based on Raspberry Pi, and inspired by the 18th century chess playing machine, the Mechanical Turk. The project incorporates aspects of computer vision, data science, machine learning, robotics, 3D printing, and—of course—chess.

## Website

A website describing the robot and how it was made can be found [here](http://www.raspberryturk.com).

## Creator

[Joey Meyer](http://www.raspberryturk.com/aboutme.html)

## License

Raspberry Turk is available under the MIT license. See the LICENSE file for more info.

repository: hemanlinks/raspberryturk

gha_license_id: MIT

repo_name: hemanlinks/raspberryturk


text:
### Explore fastq sequences

1. Login to binfservms01 using ssh protocol
2. Create a new directory called dataPreprocess in your home directory.
3. Change directory to dataPreprocess
4. Download the following fastq files from NCBI short read archive (http://ncbi.nlm.nih.gov/sra)
```
wget  ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR102/001/SRR1027171/SRR1027171_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR102/001/SRR1027171/SRR1027171_2.fastq.gz
```
-	The above files belong to the study- [GSE52194](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE52194)
-	 Click the above link to take you to SRA (Sequence Read Archive) where you can find more information about these two sets.

Questions:
1. What is the name and size of the files you downloaded ?
2. Use unix head command to see how the header line of fastq looks like. Does it look like the example you saw in the lecture ?
```
head SRR1027171_1.fastq.gz
```

#### Fastqc

We will check the quality of the fastq files using the software program called fastqc.

Fastqc documentation is available here
https://www.bioinformatics.babraham.ac.uk/projects/fastqc/Help/

We use the slurm cluster managment program to run the fastqc job.

##### Request resources using the following srun command

First use the _srun_ command to request for resources like CPU and RAM to run the program
```
srun --partition=pcourse80 --cpus-per-task 4 --time=1:00:00 --mem=1G --pty /bin/bash
```
Questions:
Do you understand all the arguments passed to _srun_ ?

##### running fastqc at the shell prompt interactively
Once you are logged into one of the servers, load the software module in the following manner

```
 module add UHTS/Quality_control/fastqc/0.11.5;
 ```

 Launch fastqc with the two fastq files in the following manner

 ```
  fastqc --extract SRR1027171_1.fastq.gz SRR1027171_2.fastq.gz –threads  4
  ```

#### Job Script
The above job can also be launched using bash script on the head node. In this case _SLURM_ looks for node with required resources and launches it on the cluster.
Please exit the interactive session before launching the job

```
exit
cat >run_fastqc.sh
#!/bin/bash
#SBATCH --time=1:00:00
#SBATCH --mem=2G
#SBATCH --output=fastqc.out
#SBATCH --error=fastqc.err
#SBATCH --job-name=test
#SBATCH --cpus-per-task=4
#SBATCH --partition=pcourse32

module add UHTS/Quality_control/fastqc/0.11.5;
fastqc --extract SRR1027171_1.fastq.gz SRR1027171_2.fastq.gz --threads  4
<CTRL-D>
```
Sumbit the job to the cluster

```
sbatch run_fastqc.sh
```
Questions:
1. Is your job running ? (Hint :use _squeue_)
It should take ~5 mins for the job to finish.
2. How many output files have been produced by fastqc ? what are the types ?

#### zip files
Let’s transfer the zip files to our local computers so we can open and view them in our browsers. We’ll use the command scp to do this.
scp (secure copy protocol) is a means of securely transferring computer files between a local host and a remote host. We can use this command to transfer files between two computers. We need to run this command on our local computers (i.e. from the windows machine).

First tells create a new directory to store the zip files we will be transferring. Create a new folder called fastqc_html under your students directory in G.

```
G:\IGEH\_PhD_Sequencing_2018\<student>\fastqc_html
```
Now Launch the windows terminal called the command prompt  by typing cmd in the windows search and double click the command prompt app. At the prompt H:>\  type the following command

```
pscp student51@binfservms01.unibe.ch:/home/student27/RNA-seq/*zip G:\IGEH\_PhD_Sequencing_2019\<student51>\fastqc_html
```
replace the student27 with your ID.

Now from the fastqc_html directory:
1. Unzip the zip files by double clicking on the files in the file explorer
2. Double click on the SRR1027171_1_fastqc/fastqc_report.html to open in a browser
3. Double click on the SRR1027171_2_fastqc/fastqc_report.html to open in a browser

Answer the following Questions:
1. How many reads did the files have ?
2. Do you find any test failed ?
3. What amount over-representation you see in the two files ?
4. What are these over-represented sequences ?

#### Filtering adapters and low quality bases
Several tools exist that can remove the adapters and filter low quality base. Examples include trimmomatic,fastx cutadapt, sickle etc. Here we will use fastp to remove the adapters and low quality bases. The fastp manual is available here
https://github.com/OpenGene/fastp

Create the bash script to run fastp with the fastq files in the following manner

```
cat >run_fastp.sh
#!/bin/bash
#SBATCH --time=1:00:00
#SBATCH --mem=2G
#SBATCH --output=qual.out
#SBATCH --error=qual.err
#SBATCH --job-name=fastp
#SBATCH --cpus-per-task=4
#SBATCH --partition=pcourse32
module add UHTS/Quality_control/fastp/0.12.5;

fastp -w 4 -q 15 -z 5 -l 50  -i SRR1027171_1.fastq.gz -I SRR1027171_2.fastq.gz -o SRR1027171_1.clean.fq.gz -O SRR1027171_2.clean.fq.gz
```

The arguments passed to cut-adapt were based on the following:
- Trim low-quality ends from reads before adapter removal if quality is less than 15 (-q 15)
- Discard trimmed reads that are shorter than 50 bases after trimming (-l 50)
- compression level for gzip output (-z 5)
- set number of threads to 4 (-w 4)

The best is to run the fastp algorithm using a job script. This way you are recording all the parameters and can be easily added to your methods in manuscripts for the cause reproducibility research.

#### FastQC again
- Now run fastqc on the cleaned fastq files.
- Similar to the previous done exercise scp the *zip files to a local directory, unzip and view the fastqc_report.html file for the results
- Record the changes you see in the cleaned and trimmed reads

repository: vetsuisse-unibe/NGS-course-docs

repo_name: vetsuisse-unibe/NGS-course-docs


text:
# formal-modeling-intersection
This repository contains NuSMV file used for the formal modeling of traffic lights controller for intersection with contraflow lanes (the file NuSMV-4armedjunction.smv).

In addition, we also put an animation video which illustrates the operation (i.e., lights transition) of our proposed traffic lights controller for the intersection with contraflow lanes (the file 4armed-junction-contraflow.mkv)

The contraflow lanes are designed based on the proposed designated contraflow lanes for TransJakarta, a bus rapid transit system in Jakarta, Indonesia.

license: Unlicense

repository: csmarz/formal-modeling-intersection

repo_name: csmarz/formal-modeling-intersection


text:
---
title: "Gantry"
slug: "gantry"
---

* toc
{:toc}

The Gantry has seen significant change in V0.2. The most notable is the switch from a looped belt drive system that ran the full length of each track to a belt and pinion style system. Feeding the belt through the extrusions in V0.1 was hard for 1.5m length tracks and nearly impossible for 3m length tracks. The belt and pinion system uses half of the belt length and greatly simplifies installations and tightening of the belt. It also eliminates the need for pulleys and mounting plates at the end of the tracks.

Genesis V0.2 prototype plates cut out of MDF with a CNC router
In addition, the belt and pinion system allows the drive motor to be positioned on the gantry, allowing it to move with the other electronics, thereby simplifying wiring as all electronics move together. Also, a single drive motor in combination with a driveshaft allows for synchronized movement between both sides of the gantry along each track.

The other major improvement is the use of custom brackets which greatly simplifies the construction while making the Gantry more rigid. In V0.2, 1 base bracket and 4 wheels at the track/gantry interface replaces the 1 extrusion, 3 brackets, and 8 wheels for this same interface in V0.1. The base plates also provide locations for the endstops to be mounted.

{% include gallery.html images="
![GenesisV2Plates.jpg](_images/GenesisV2Plates.jpg)
![Gantry_Belt_and_Pinion_System.jpg](_images/Gantry_Belt_and_Pinion_System.jpg)
" %}

repository: onumag/farmbot-genesis

branch_name: refs/heads/main

repo_name: onumag/farmbot-genesis


text:
---
title: Summer term 2.3
layout: post
author: anokh.tiwana-parmar
permalink: /summerterm2-3/
source-id: 12uctKUnEcAEPQInKN7VhU9tgv8_qFXJ7ooVXBYR0tVQ
published: true
---

    Title:
    Summer term 2. Lesson 3
     Date:

    Starting point:
    Github and repl continuation

    Target for this lesson?
    To learn some new coding skills by myself and to use githubs again and make my posts work and work on repl,it

    Did I reach my target?
(add details to "Lesson Review")
    Pretty much

    Lesson Review

    How did I learn? What strategies were effective?

    Today, my github showed up. I started working on a new repl.it game asking people for names and giving opinions. My code didn't work. I looked at other people’s codes to help. I am currently trying to add these blogs into my github ready for my teacher to mark.

    What limited my learning? Which habits do I need to work on?

    My understanding of the code i was developing. I need to learn about how to make these games instead of just attempting without any good ideas on a foundation level.

    What will I change for next time? How will I improve my learning?

    I will keep working on my blogs and coding in repl.it around lessons


text:
---
title: 🥊 Code-first vs. schema-first development in GraphQL
metaDesc: Which approach is better?
socialImage: /images/graphql-logo.png
date: '2020-02-27'
tags:
  - graphql
  - server
  - guide
  - pop
---

I wrote my third article for the [LogRocket Blog](https://blog.logrocket.com/), where I explain my journey on conceptualizing, designing and implementing a [GraphQL](https://graphql.org) server, as I have done for [GraphQL by PoP](https://graphql-by-pop.com):

[Code-first vs. schema-first development in GraphQL](https://blog.logrocket.com/code-first-vs-schema-first-development-graphql/)

This article describes the 2 approaches to implementing a GraphQL server:

- Schema-first: we first define the schema for the GraphQL service using the [Schema Definition Language](https://www.howtographql.com/basics/2-core-concepts/) (or SDL) and then we implement the code by matching the definitions in the schema
- Code-first: we start by coding the resolvers, and then, from code as a single source of truth, we have the schema generated as an artifact

In the article I compare both approaches, listing down the advantages and drawbacks of each, recommending when to use one or the other, and finally expressing why I prefer the code-first approach since it enables to support a myriad of features in [GraphQL by PoP](https://graphql-by-pop.com) which would not be feasible otherwise.

This is an ongoing series, and coming soon will be more article on the different strategies employed to tackle all different concerns: decentralization, federation, security, and others.

Enjoy!

gha_language: Nunjucks


text:
---
layout: post
title: Floating Point
category: posts
---

You’ve written some absurdly simple code, say for example:

```ruby
>> 0.1 + 0.2
```

and got a really unexpected result:

```ruby
=> 0.30000000000000004
```

Maybe you asked for help on some forum and got pointed to a long
article with lots of formulas that didn’t seem to help with your
problem.

[floating-point-gui.de] is a website that can help you with all
things float. Give it a spin :)

[floating-point-gui.de]: http://floating-point-gui.de/

extension: markdown

gha_language: CSS


text:
# Crystal Reports Ninja
This is a complete rewritten based on [Crystal-Reports-Exporter](https://github.com/rainforestnet/Crystal-Reports-Exporter#crystal-reports-exporter) in order to enhance code readability and maintainability.

Crystal Reports Ninja is an open source Windows Console program runs on .NET Framework 4.5.
It loads external Crystal Report file (.rpt) and export into various file formats such as xls, pdf as well as print to printer.

Since it is a console (command-line) app, it can be invoked by Task Scheduler, batch file (.bat), command line file (.cmd), as well as Web API or Web Applications.

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

## Directory structure
* - Source (Source Code)
* - Deployment
	- CRforVS_redist_install_32bit_13_0_20.zip (runtime needed for 32-bit Windows machine)
	- CRforVS_redist_install_64bit_13_0_20.zip (runtime needed for 64-bit Windows machine)
	- CrystalReportsNinja.exe  (Executable compiled by Visual Studio 2017 for .NET Framework 4.5)

## Installation
Copy CrystalReportsNinja.exe and install the right CRforVS runtime of your platform and it should work.

## How to use
Locate the folder of CrystalReportsNinja.exe and run CrystalReportsNinja -?
The only mandatory argument is "-F", in which is for user to specify a Crystal Reports file.

### List of arguments

* -F Crystal Reports filename to be loaded (i.e. "C:\Report Source\Report1.rpt")
* -O Crystal Reports Output filename (i.e. "C:\Reports Output\Report1.pdf" ) [Optional]
* -E Intended file format to be exported.(i.e. pdf, doc, xls .. and etc). If you wish to print Crystal Reports to a printer, simply "-E print" instead of specifying file format.

* -N Printer Name. If printer name is not specified, it looks for default printer in the computer. If network printer, -N \\computer01\printer1
* -C Number of copy to be printed (any integer value i.e. 1,2,3..)
* -S Server Name for server where data resides. Only one server per Crystal Reports is allowed.
* -D Database Name.
* -U Data source / server login username. Do not specify username and password for Integrated Security connection.
* -P Data source / server login password. Do not specify username and password for Integrated Security connection.
* -a Pass Crystal Reports file parameter set on run-time
* -l Create a log file into CrystalReportsNinja.exe directory

### -F, Crystal Reports source file
This is the only mandatory (must specify) argument, it allows your to specify the Crystal Reports filename to be exported.

### -O, Crystal Reports output file
If -O is not specified, Crystal Reports Exporter will just export the Crystal Reports into the same directory when Crystal Reports source file is resided.

The filename of the exported file is the same as Crystal Report source file and ending with timestamp (yyyyMMddHHmmss).

### -E, Crystal Reports Export File Type
There are 13 file formats that you can export a Crystal Reports file.

Use -E to specify desired file format. If -E argument is not supplied, CrystalReportsNinja will look into the output file extension,
if output file is report1.pdf, it will then set to be Adobe PDF format.
If file extension cannot be mapped into supported file format, CrystalReportsNinja will export your Crystal Reports into plain text file.

File type
Descriptions

txt
Plain text file

pdf
Adobe Portable Document format (pdf)

doc
Microsoft Word

xls
Microsoft Excel

xlsdata
Microsoft Excel with Data Only

rtf
Rich Text format

ertf
Editable Rich Text format

tab
Tab delimited text file

csv
Comma delimited text file

xml
xml file

htm
HTML file

rpt
Crystal Reports file

print
Print Crystal Report to a printer

### -S, Server name or Data Source name
Most of the time, you need not specify the server name or data source name of your Crystal Reports file as every Crystal Reports file saves data source information during design time.

Therefore, you only specify a server name when you want Crystal Reports to retrieve data from another data source that is different from what it is saved in Crystal Reports file during design time.

If your crystal Reports data source is one of the ODBC DSN (regardless of User DSN or System DSN), the DSN will be your Server Name (-S).

### -D, Database name
Similarly to Server Name. Database Name is completely optional. You only specify a Database Name when you intend to retrieve data from another database that is different from default database name that is saved in Crystal Reports file.

### -U and - P, Username and Password to login to Data source
If you are using database like Microsoft SQL server, MySQL or Oracle, you are most likely required to supply a username and password to login to database.

If you are using trusted connection to your SQL server, you wouldn't need to supply username and password when you run CrystalReportsNinja.

If you are using a password protected Microsoft Access database, you need only to specify password and not username.

### -a Passing in Parameters of Crystal Reports
We can have as many Parameters as we want in one Crystal Reports file.
When we refresh a report, it prompts user to input the value of parameter in runtime in order to produce the result that user wants.

You can pass parameter value to CrystalReportsNinja.exe when it is executed.

###Example 1
Let's take an example of a Crystal Reports file test.rpt located in C: root directory. The Crystal Reports file has two parameters, namely Supplier and Date Range.
```
c:\>CrystalReportsNinja -U user1 -P mypass -S server1 -D Demo
-F c:\test.rpt -O d:\test.pdf -E pdf -a "Supplier:Active Outdoors"
-a "Date Range:(12-01-2001,12-04-2002)"
```

Rule to pass parameters
Use double quote (") to enclose the parameter string (parameter name and parameter value)
A colon (:) must be placed between parameter name and parameter value.
Use comma (,) to separate start value and end value of a Range parameter.
Use pipe (|) to pass multiple values into the same parameter.
Parameter name is case sensitive

###Example 2
The following crystal Reports "testTraining.rpt" has 5 discrete parameters and 2 range parameters.
Discrete parameters are:
* company
* customer
* branch

Range parameters are:
* Daterange
* Product

Example of Single value parameters :

```
c:\>CrystalReportsNinja -U user1 -P secret -F C:\Creport\Statement.rpt
-O D:\Output\Statement.pdf -E pdf -S"AnySystem DB"
-a "company:The One Computer,Inc" -a "customer:"MyBooks Store"
-a "branch:Malaysia" -a "daterange:(12-01-2001,12-04-2002)"
-a "product:(AFD001,AFD005)"
```

Example of Multiple values parameters :
```
c:\>CrystalReportsNinja -F testreport.rpt -O testOutput.xls
-E xlsdata -S order.mdb -a "date:(01-01-2001,28-02-2001)|(02-01-2002,31-10-2002)|(02-08-2002,31-12-2002)"
-a "Client:(Ace Soft Inc,Best Computer Inc)|(Xtreme Bike Inc,Zebra Design Inc)"
```

Example to print Crystal Reports output to printer
```
c:\>CrystalReportsNinja -F report101.rpt -E print -N "HP LaserJet 1200" -C 3
```

gha_language: C#


text:
# Abies concolor var. lowiana (Gordon & Glend.) Lemmon VARIETY

#### Status
SYNONYM

#### According to
Integrated Taxonomic Information System

#### Published in
Cone-bear. trees Pacif. Slope ed. 3:64. 1895

#### Original name
null

### Remarks
null

repository: mdoering/backbone

path: /life/Plantae/Pinophyta/Pinopsida/Pinales/Pinaceae/Abies/Abies lowiana/ Syn. Abies concolor lowiana/README.md

repo_name: mdoering/backbone


text:
![ffartlogoAsset 1](https://user-images.githubusercontent.com/43297083/120124080-19278e80-c1bb-11eb-885c-bba5b97024e1.png)
# ffart.studio It's an evolving idea.

<h3>art for art, art society

#

## What's this ffart.studio

This idea, which emerged from the needs in the field of graphic design and art, is based on several foundations.
- Of course, our top priority is to build a help network.
- and opening this help network to all enthusiasts, not just professionals.
- watching art emerge from a society, not from a single person.
- seeing the ideas that different people bring.

#


text:
# Design

This folder contains the high-level documentation created to design the My Thai Star application.

The documents provided in this folder are:
  - First step analysis presentation, used to present the epics, user stories, mockups and architecture overview to the customer.
  - Accelerated Solution Design document, used to explain to the development team the expected behavior of the solution.


text:
## Shell Registration

Images can also be integrated with the Windows shell. The `register` command will create Start Menu shortcuts and file associations in the shell for the image so that it behaves similar to an installed application.

```
# Register 7-zip to the shell
> turbo register 7-zip/7-zip
```

Configuring shortcuts and file associations for an image is done in Turbo Studio. See the [reference](/docs/reference/turbo-studio) section for more details.


text:
---
layout: post
title: "Digging deeper: online resources for intermediate to advanced R users"
excerpt_separator: <!--more-->
---

Anybody wanting to learn R from scratch will find an incredible wealth of tutorials, interactive learning websites, and high-quality videos at their disposal—almost to a point where it's difficult to know where to start! This is of course a good thing, and is mainly due to R's quickly growing popularity, with a constant stream of new users from both industry and academia wanting to learn the fundamentals.

But I've found that once you reach a certain level of confidence with the language, it becomes more difficult to find material for intermediate/advanced users who wish to become really good at R programming. But these materials do exist—they just tend to be mentioned and highlighted less frequently by the community.

Hence this post, where I've tried to gather a variety of books, courses and resources that should be beneficial to you, if you're at that level where you don't need another tidyverse tutorial, but wish you could get advanced insights from seasoned R programmers.

<!--more-->

Note that I've only listed here material that I've actually tested and used (maybe not entirely, but at least enough to judge its benefits). I'm sure there are many more resources out there that are as valuable!

---

## Books

There are actually quite a few books available on intermediate/advanced R programming ([O'Reilly](https://www.oreilly.com/search/?query=R&extended_publisher_data=true&highlight=true&include_assessments=false&include_case_studies=true&include_courses=true&include_playlists=true&include_collections=true&include_notebooks=true&is_academic_institution_account=false&source=user&formats=book&sort=relevance&facet_json=true&page=0&include_facets=false&include_scenarios=true&include_sandboxes=true&json_facets=true) is usually a good source for this), but I've chosen the four books below in particular because:

* They cover broad areas of R programming, rather than very narrow issues that will only be interesting to specific users (such as advanced statistical models, large-scale Shiny apps, etc.);
* All can be read for free on a dedicated website—but of course, buying a physical copy is the best way to thank their authors if you found the contents useful (which you'll most likely do!).

![Advanced R books](https://raw.githubusercontent.com/edomt/edomt.github.io/master/images/bookshelf.png)

### [_Advanced R_, by Hadley Wickham](http://adv-r.had.co.nz/)

I feel like this almost shouldn't be listed here, since it hardly fits my definition of material "less frequently mentioned by the community"! Hadley Wickham's book is the main reference on advanced R programming. It takes you all the way back to the fundamentals, teaching you the intricacies of variable assignment, vectors and matrices—not because you don't know what they are, but because you don't _entirely_ know what they are. Contents also cover object-oriented programming, debugging, performance/profiling, and a highly-useful style guide.

### [_Efficient R programming_, by Colin Gillespie & Robin Lovelace](https://csgillespie.github.io/efficientR/)

This book seems to be somewhat less known in the R community (I found it through a random Google search), but it is the perfect resource if you feel like you know how to get things done in R, but want to learn how to get things done "properly" and efficiently. The concept of efficiency has a broad definition here, and includes obvious aspects such as code optimisation and profiling, but also workflow, data input/output, collaboration, learning, and many others. Highly recommended!

### [_Data Visualization: A practical introduction_, by Kieran Healy](http://socviz.co/)

This circulated a lot on Twitter last year when it was published online, and I read the whole thing before it was subsequently published as a book. This holds extremely valuable information for anybody producing data visualizations for their projects. I found it to have the perfect balance between theoretical aspects (principles of perception, data representation, ease of understanding) and practical learning on how to implement things in ggplot2. Note that Part 2 (_"Get started"_) can be skipped almost entirely if you're already an experienced R user.

### [_R packages_, by Hadley Wickham](http://r-pkgs.had.co.nz/)

I haven't read _R packages_ as thoroughly as the other books above, but it is the main reference book on how (and why) to write R packages. Many people equate packages with CRAN; and while it is of course very useful to make your code available to other R users around the world, packages can also simply be a way to better organise your projects, and to make sure that your entire workflow is very tidy and fully reproducible.

---

## Courses

Online courses are usually much more expensive than the one-off price of a book, but of course they offer a lot more interactivity. If you know you're the kind of person who will read through a book but won't have the motivation to re-type the examples and do the exercises, you might want to check out those resources.

### [Mastering Software Development in R Specialization, by Johns Hopkins University on Coursera.org](https://www.coursera.org/specializations/r)

**Cost:** Free for 7 days, then ~$40/£28/32€ per month

**Duration:** 3 to 6 months

This series of courses aims at teaching users how to _"design software for data tooling, distribute R packages, and build custom visualizations"_. The first course ("The R Programming Environment") probably won't be needed for intermediate R users, but subsequent courses ("Advanced R Programming", "Building R Packages", and "Building Data Visualization Tools") should be a great way to extend your knowledge. Note that I haven't tested this new version of the specialization, but the former version (already taught by Roger Peng) was the main way I learned R a few years ago.

### [R courses on Datacamp.com](https://www.datacamp.com/courses/tech:r)

**Cost:** ~$29/£20/23€ per month

**Duration:** each course takes between 3 and 6 hours

Another well-known resource in the R community, Datacamp provides one of the best platforms for beginners to learn R, but also a great way to dig deeper and widen your skillset. Intermediate and advanced courses include "Writing Functions" (taught by Hadley Wickham), "Building Web Applications with Shiny" (Mine Cetinkaya-Rundel), "Data Analysis, the data.table Way" (Matt Dowle), "Working with Web Data" (Charlotte Wickham), "Object-Oriented Programming" (Richie Cotton), "Writing Efficient Code" (Colin Gillespie), and "Scalable Data Processing" (Michael Kane).

### [Code Clinic: R, by Mark Niemann-Ross on Lynda.com](https://www.lynda.com/R-tutorials/Code-Clinic-R/372541-2.html)

**Cost:** Free for 1 month, then ~$30/£21/24€ per month

**Duration:** 3 hours of video + a few more hours to go through the problems

This course is very different from everything else mentioned on this list. The idea of "code clinics" on Lynda.com is to solve a series of general computer science problems by using a specific programming language. This means that those problems are very different from those in typical data-related R tutorials: you'll learn about image processing, chess simulations, and even how to interact with your computer peripherals to produce sound when you move your mouse.

### [Posit webinars](https://posit.co/resources/videos/)

**Cost:** Free

**Duration:** around 40 minutes to 1 hour

Posit (ex-RStudio) runs regular webinars, i.e. live teaching videos covering a very specific topic in R programming... so specific that you might not see any possible use in some of them. But I highly recommend going through their list of past webinars and watching whatever seems relevant to your particular job/role.

---

## What else?

If you've been through all the material above, it's probably time to delve into more specific subtopics. I find [this Quora answer by Benjamin Paul Rollert](https://www.quora.com/How-do-I-become-an-expert-in-R-if-I%E2%80%99m-an-intermediate-now-Any-good-books-lectures-or-blogs/answer/Benjamin-Paul-Rollert) to be quite complete. More generally, you can search for ["advanced R courses"](https://www.google.com/search?q=advanced+r+course) being taught in universities or elsewhere. The topics covered by the course are often listed on the booking page, so that's another great way to find new areas to explore.


text:
## System Services
Systemd is the new init system for modern Linux distributions replacing the old init based on ``/etc/init.d/script``. It provides many powerful features for starting, stopping and managing processes. Here is an example to create a MineCraft service for systemd. MainCraft is a Java based game from Mojang.

First, install the game and its envinronment.
```
# yum install java-1.8.0-openjdk.x86_64
# which java
/bin/java
# mkdir /root/Minecraft
# cd /root/Minecraft
# wget -O minecraft_server.jar https://s3.amazonaws.com/Minecraft.Download/versions/1.8.6/minecraft_server.1.8.6.jar
# ls -lrt
-rw-r--r--. 1 root root 9780573 May 25 11:47 minecraft_server.jar
-rw-r--r--. 1 root root       2 Jun  1 11:48 whitelist.json
-rw-r--r--. 1 root root     180 Jun  1 12:01 eula.txt
drwxr-xr-x. 2 root root    4096 Jun  1 16:09 logs
-rw-r--r--. 1 root root     785 Jun  1 16:09 server.properties
-rw-r--r--. 1 root root       2 Jun  1 16:09 banned-players.json
-rw-r--r--. 1 root root       2 Jun  1 16:09 banned-ips.json
-rw-r--r--. 1 root root       2 Jun  1 16:09 ops.json
-rw-r--r--. 1 root root     109 Jun  1 16:10 usercache.json
drwxr-xr-x. 8 root root    4096 Jun  1 16:37 world
```

The MineCraft server can be started at command line, by issuing the following command
```
# java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
```

Alternately, a systemd configuration file can be created to start, stop, and check the status of the server as a standard system service by using the ``systemctl`` utility
```
# vi /lib/systemd/system/minecraftd.service
[Unit]
Description=Minecraft Server
After=syslog.target network.target

[Service]
Type=simple
WorkingDirectory=/root/Minecraft
ExecStart=/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
SuccessExitStatus=143
Restart=on-failure

[Install]
WantedBy=multi-user.target

# systemctl start minecraftd
# systemctl status minecraftd
minecraftd.service - Minecraft Server
   Loaded: loaded (/usr/lib/systemd/system/minecraftd.service; disabled)
   Active: active (running) since Mon 2015-06-01 16:00:12 UTC; 18s ago
 Main PID: 20975 (java)
   CGroup: /system.slice/minecraftd.service
           └─20975 /bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

# systemctl stop minecraftd
```
Note: the ``SuccessExitStatus=143`` is required when a process does not handle the exit signal properly. This is almost always due to programming errors, and is pretty common with Java applications of all types. To avoid a failed status of the MainCraft when stopping the service, the exit code 143 needs to be added into the unit file as a "success" exit status.

The ``systemctl`` utility can be used to enable/disable the service at startup
```
# systemctl enable minecraftd
ln -s '/usr/lib/systemd/system/minecraftd.service' '/etc/systemd/system/multi-user.target.wants/minecraftd.service'
# systemctl is-enabled minecraftd
enabled
# systemctl disable minecraftd
```

Here another example
```
# cat /etc/systemd/system/redmined.service
[Unit]
Description=Redmine Server
After=syslog.target network.target

[Service]
Type=simple
PermissionsStartOnly=true
WorkingDirectory=/home/redmine/redmine
ExecStartPre=/usr/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
ExecStart=/usr/bin/ruby bin/rails server -b <IP_ADDRESS> -p 8080 webrick -e production
User=redmine
Group=redmine
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=redmined
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

```


text:
Laravel Vue Single Page Application

## Install Laravel Vue (SPA)

1. Create .env file
2. Update composer
3. Change API_URL & DB config
4. Run php artisan serve
5. Run npm install
6. Run npm run watch

Enjoy!!!

## License

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

gha_language: PHP


text:
# tf-lambda-api-gateway-example
example of using `terraform` to deploy a `node.js` lambda function behind an `AWS API Gateway`

## Installing
Prereqs:
- node v8+

```shell
# clone this repository
$ git clone https://github.com/cludden/tf-lambda-api-gateway.git

# install dependencies
$ cd tf-lambda-api-gateway && npm install
```

## Testing
Prereqs:
- node v8+

```shell
# run the test suite
$ npm run test
```

## Building
*Note: this project uses features from from Node 8, and as such requires a build step*

Prereqs:
- node v8+

```shell
# run webpack which runs transpilation/minification and generates an
# artifact for each lambda function in the ./dist directory
$ npm run build
```

## Deploying
Prereqs:
- Terraform v0.12+
- AWS account with high degree of privileges and credentials available in the environment

```shell
# change into the terraform directory
$ cd terraform

# create a new terraform environment
$ terraform env new dev

# install any missing plugins
$ terraform init

# run a plan
$ terraform plan -var env=dev
...
Plan: 13 to add, 0 to change, 0 to destroy.

# apply
$ terraform apply -var env=dev
...
Apply complete! Resources: 13 added, 0 changed, 0 destroyed.

Outputs:

url = https://<api_id>.execute-api.us-west-2.amazonaws.com/example_lambda_dev

# destroy when finished
$ terraform destroy -var env=dev
```

*Note: it can take a few minutes before the integrations become active*

## License
Copyright (c) 2017 Chris Ludden
Licensed under the [MIT License](LICENSE.md)


text:
---
title: "Array and String"
subtitle: ""
layout: post
author: "blueskyson"
header-style: text
mathjax: true
tags:
  - en
  - c++
---

## What is an Array

An array is a data format that store several value of the same type. For example, an array can store 12 integers indicating day number of every month.

[![array](https://raw.githubusercontent.com/blueskyson/image-host/master/array.jpg)](https://raw.githubusercontent.com/blueskyson/image-host/master/array.jpg)

>Compiler won't check if the index is valid. If we write a statement `month[100] = 0`, the code may be compiled successfully. However this statement will break other data in the program or even stop the program when it's running.

## Array Initialization

The most common form of array initializer is a list of constant expressions enclosed in braces and separated by commas:

`int arr[6] = {1, 2, 3, 4, 5, 6};`
`// initialize value of arr is {1, 2, 3, 4, 5, 6}`

`int arr[6] = {1, 2}`
`// initialize value of arr is {1, 2, 0, 0, 0, 0}`S

Using this feature, we can use {0} to initialize an array to all zeros:

`int arr[6] = {0}`
`// initialize value of arr is {0, 0, 0, 0, 0, 0}`

`int arr[6] = {1}`
`// initialize value of arr is {1, 0, 0, 0, 0, 0}`

For `char` array, it's better to put null character ('\0') into the last element. So that IO functions like `cout`, `printf` can process it normally. Characters after the first null character will be ignored by `cout` and `printf`.

`char str1[6] = {'h', 'e', 'l', 'l', 'o', '!'};`
`// cout << str1; may cause unpredictable behavior since it has no '\0' at the end`

`char str2[7] = {'h', 'e', 'l', 'l', 'o', '!', '\0'};`
`// a string with null character at the end`

`char str3[10] = "hello"`
`// initialize value of arr is {'h', 'e', 'l', 'l', 'o', '!', '\0', '\0', '\0', '\0'}`

## Use sizeof() with Arrays

```cpp
#include<iostream>
using namespace std;
int main() {
  int arr[21];
  cout << sizeof(arr) << endl;
  /* get the size of entire array*/
  cout << sizeof(arr[0]) << endl;
  /* get the size of one element in the array*/
  return 0;
}
```

```non
84
4
```

## Multidimensional Arrays

C++ stores arrays in row-major order shown as below:

[![array-2](https://raw.githubusercontent.com/blueskyson/image-host/master/array-2.jpg)](https://raw.githubusercontent.com/blueskyson/image-host/master/array-2.jpg)

## Multidimensional Array Initialization

`int arr[3][4] = { {1, 2, 3, 4}, {4, 3, 2, 1}, {5, 6, 7, 8} };`

Higher dimensional arrays are constructed similarly.

## String Object

In ISO/ANSI C++98, `string` is added in C++ library. Though `string` is quite simple to manipulate, it is not a basic type but an object wrapped in `class`, the later will be explained in another post. Here are some comparisons of string and char array.

* String use tha same initialize statement as char array
`string str1 = "string";`
`char ch1[20] = "char";`

* String can be assigned to another string, but char array not
`string str2 = str1;`
`//valid assignment, the value of str2 becomes "string"`
`char ch2[20];`
`ch2 = ch1; //invalid, no array assignment`

* Two strings can be connected by operator `+` and `+=`
`string str3 = str1 + str2;`
`//valid operation, the value of str3 becomes "stringstring"`
`char ch3[40] = ch1 + ch2 //invalid`
`str1 += "hello"`
`//valid operation, the value of str1 becomes "stringhello"`

* String use both `[]` operator and `at()` method to get char in specific index
`cout << str1[3]; //this statement shows 'i'`
`cout << str1.at(3) //this also shows 'i'`

> Notice that `[]` operator checks if the index is out of the range of string, `at()` method not. So we should use `at()` carefully.

## Some Useful String Methods

`str1.size();`
`//return the length of string (no '\0' at the end)`
`//in this case it returns 11`

`str1.erase(5,3);`
`//erase some words from some index`
`//in this case, it erases 3 chars from index str1[5]`
`//so str1 becomes "strinllo"`

`string str4 = str3.substr(6,6);`
`//return a new string storing some words from some index`
`//in this case, it copies 6 chars from index str3[6]`
`//so str4 becomes "string"`

There are still many more methods. [cplusplus.com](http://www.cplusplus.com/reference/string/string/) has more explanations about string. Make good use of it : )


text:
Ex3
================

``` r
setwd("C:\\Users\\Ben\\Documents\\R\\Ex3")
```

### Twitter API

This is R code to get twitter data using their API

``` r
#install.packages("devtools")
#devtools::install_github("mkearney/rtweet")
library(rtweet)
```

    ## Welcome to rtweet v0.4.1!

``` r
appname <- "AppName"
consumerKey <- "myKey"
consumerSecret <- "mySecretKey"
#twitter_token <- create_token(
#    app = appname,
#    consumer_key = consumerKey,
#    consumer_secret = consumerSecret)
mk <- as.data.frame(read.csv("mk_id.csv",colClasses = 'character'))
mk_follow <- NA
j <-0
for(i in mk$id){
  follows <- get_friends(i,parse = T)
  mk_follow[j+1] <- follows
  j <- j+1
}
```

We used python to get our data here is code: <https://github.com/BenEfrati/ex1/blob/master/network%20analysis/init.py>

The id is the twitter user id of MKs (Members of Knesset) The edges in the graph are friends of each user and the vertices are the MKs.

``` r
library(igraph)
```

    ##
    ## Attaching package: 'igraph'

    ## The following object is masked from 'package:rtweet':
    ##
    ##     %>%

    ## The following objects are masked from 'package:stats':
    ##
    ##     decompose, spectrum

    ## The following object is masked from 'package:base':
    ##
    ##     union

``` r
md_name <- as.data.frame(read.csv('mk_id.csv',colClasses = 'character'))
data_mk <- as.data.frame(read.csv('friends.csv',colClasses = 'character'))
new <- data_mk
new[] <- md_name$name[match(unlist(data_mk), md_name$id)]
new <- na.omit(new)
twitterg <- graph.data.frame(new, directed = F)
degr.score <- degree(twitterg)
V(twitterg)$size <- degr.score/15
V(twitterg)$name <- ifelse(V(twitterg)$size>10,V(twitterg)$name,NA)
#twitterg$layout <- layout.fruchterman.reingold(twitterg, niter=5000)
plot( twitterg, layout = layout.reingold.tilford,
      edge.width = 1,
      edge.arrow.width = 0.3,
      vertex.size = 5,
      edge.arrow.size = 0.5,
      vertex.size2 = 3,
      vertex.label.cex = 1,
      asp = 0.35,
      margin = -0.1)
```

![](twitter_files/figure-markdown_github/unnamed-chunk-3-1.png)

``` r
plot(twitterg,layout=layout.circle)
```

![](twitter_files/figure-markdown_github/unnamed-chunk-3-2.png)

``` r
igraph.options(plot.layout=layout.graphopt, vertex.size=7)

plot(twitterg, asp=0)
```

![](twitter_files/figure-markdown_github/unnamed-chunk-3-3.png)

on this graph you can see that there is connection almost between all the members, the few white areas shows on the missing connections but you can see by that graph that almost everyone connected

``` r
#restore names and sizes
twitterg <- graph.data.frame(new, directed = F)
```

three plots for the same graph, in first one is divided to three groups and the second plot is graphopt which try to optimize the view. the third is a circle. As we can see, all the Mks are connected so the edges overrides each other \#\#Centrality

### Compute betweenes

``` r
library(igraph)
between <- betweenness(twitterg)
maxBetweenes <- which.max(between)
cat("The actor with the maximum betweenes is:\n")
```

    ## The actor with the maximum betweenes is:

``` r
maxBetweenes
```

    ## Dov Khenin
    ##         14

### Compute Closeness

``` r
library(igraph)
close <- closeness(twitterg)
maxCloseness <- which.max(close)
cat("The actor with the maximum closeness is:\n")
```

    ## The actor with the maximum closeness is:

``` r
maxCloseness
```

    ## Nava Boker
    ##         50

### Compute Closeness

``` r
library(igraph)
eigen <- eigen_centrality(twitterg, directed = F)
maxEigen <- which.max(eigen$vector)
cat("The actor with the maximum eigenvector is:\n")
```

    ## The actor with the maximum eigenvector is:

``` r
maxEigen
```

    ## Dov Khenin
    ##         14

Communities
-----------

### First algorithm

cluster\_edge\_betweenness performs this algorithm by calculating the edge betweenness of the graph, removing the edge with the highest edge betweenness score, then recalculating edge betweenness of the edges and again removing the one with the highest score, etc.

``` r
set.seed(123)
tgc <- cluster_edge_betweenness(twitterg,directed = F)
print("Number of communities:")
```

    ## [1] "Number of communities:"

``` r
print(length(tgc))
```

    ## [1] 1

``` r
print("Size of communities:")
```

    ## [1] "Size of communities:"

``` r
print(sizes(tgc))
```

    ## Community sizes
    ##  1
    ## 73

``` r
print("Modularity is:")
```

    ## [1] "Modularity is:"

``` r
print(modularity(tgc))
```

    ## [1] 0

``` r
plot(tgc,twitterg)
```

![](twitter_files/figure-markdown_github/unnamed-chunk-8-1.png)

### Second algorithm

``` r
set.seed(123)
tgreedy <- cluster_leading_eigen(twitterg)
print("Number of communities:")
```

    ## [1] "Number of communities:"

``` r
print(length(tgreedy))
```

    ## [1] 2

``` r
print("Size of communities:")
```

    ## [1] "Size of communities:"

``` r
print(sizes(tgreedy))
```

    ## Community sizes
    ##  1  2
    ## 39 34

``` r
print("Modularity is:")
```

    ## [1] "Modularity is:"

``` r
print(modularity(tgreedy))
```

    ## [1] 0.1003118

``` r
plot(tgreedy,twitterg)
```

![](twitter_files/figure-markdown_github/unnamed-chunk-9-1.png)

path: /network analysis/twitter.md


text:
---
title: AEM Modernization Tools
seo-title: AEM Modernization Tools
description: AEM Modernization Tools help you convert your legacy AEM features to the latest technology
seo-description: AEM Modernization Tools help you easily convert your legacy AEM features to the latest technology
contentOwner: Chris Bohnert
products: SG_EXPERIENCEMANAGER/6.5/SITES
exl-id: 8865a641-fdac-43ab-b1c3-722f120cd749
---
# AEM Modernization Tools {#modernization-tools}

[AEM Modernization Tools](https://opensource.adobe.com/aem-modernize-tools/) allow for the easy conversion of:

* [Static templates](page-templates-static.md) to [editable templates](page-templates-editable.md)
* [Design configurations](page-templates-static.md) to [policies](page-templates-editable.md)
* [Foundation Components](/help/sites-authoring/default-components-foundation.md) to [Core Components](https://experienceleague.adobe.com/docs/experience-manager-core-components/using/introduction.html)
* [Classic UI](website.md) to [Touch-Enabled UI](touch-ui-concepts.md)

For further information about the usage of these tools, [see their documentation](https://opensource.adobe.com/aem-modernize-tools/).

>[!NOTE]
>
>AEM Modernize Tools are a community effort and are not supported or warrantied by Adobe.

gha_language: Groovy


text:
# What does this test App do?

**TestDisabledMetricsLogger** verifies when *MetricsLogger plugin* is disabled using the flag
`grails.plugin.metricslogger.disable = true` in *Config.groovy*
it doesn't intercept methods and no log entries are written to *metric.log* file.

# How to run the tests?

From the root directory of the test application(`...MetricsLogger/test/projects/TestDisabledMetricsLogger`) run these commands:

```
 grails clean
 grails compile
 grails test-app
```

repository: TutteRamson/MetricsLogger

repo_name: TutteRamson/MetricsLogger


text:
# Benchmarking simulation-based inference

This repository contains the results as well as the scripts that generated them for the [manuscript "Benchmarking simulation-based inference"](http://proceedings.mlr.press/v130/lueckmann21a.html).

The results were generated using our benchmark framework, `sbibm`, which can be found at: https://github.com/sbi-benchmark/sbibm.

## Results as dataframes

The subfolder `results/` contains csv files with results for the manuscript *Benchmarking simulation-based inference*. They can, for example, be read with [`pandas`](https://pandas.pydata.org) as dataframes for comparisons and further analyses.

| **Filename**                                  | **Description**                                     |
| --------------------------------------------- | --------------------------------------------------- |
| `main_paper.csv`                              | All results for main part of the manuscript         |
| `supplement_rf_abc.csv`                       | RF-ABC results, as in Appendix F                    |
| `supplement_sl.csv`                           | Synthetic Likelihood (SL) results, as in Appendix F |
| `supplement_hyperparameters_rej_abc.csv`      | Hyperparameters for REJ-ABC, as in Appendix H       |
| `supplement_hyperparameters_smc_abc_pyabc.csv`      | Hyperparameters for SMC-ABC (with `pyabc`)          |
| `supplement_hyperparameters_smc_abc_ours.csv` | Hyperparameters for SMC-ABC (our implementation)    |
| `supplement_hyperparameters_snle.csv`         | Hyperparameters for (S)NLE                          |
| `supplement_hyperparameters_snpe.csv`         | Hyperparameters for (S)NPE                          |
| `supplement_hyperparameters_snre.csv`         | Hyperparameters for (S)NRE                          |

## Raw results for each run

Raw results for each single run from which these dataframes were compiled—including samples from all approximate posteriors—are also available. For space reasons, they are hosted in a separately using LFS:

> https://github.com/mackelab/benchmarking_sbi_runs

## Reproducing results

If you want to reproduce the experiments of the benchmark, or want to adapt our code to run your own experiments using the same analysis pipeline, start by cloning this repository:

```commandline
$ git clone git@github.com:mackelab/benchmarking_sbi.git
```

Next, install the neccessary dependencies via:

```commandline
$ pip install -r requirements.txt
```

Besides the [benchmark framework `sbibm`](https://github.com/sbi-benchmark/sbibm), this will install [Hydra](https://hydra.cc) and [Ansible](https://www.ansible.com). In order to run each algorithm on different tasks, observations and simulation budgets while potentially exploring different hyperparameters, we used [Hydra, a framework for elegantly configuring complex applications](https://hydra.cc) including plugins which we contributed to parallelize workloads ([Joblib launcher](https://hydra.cc/docs/plugins/joblib_launcher) and [RQ launcher](https://hydra.cc/docs/plugins/rq_launcher), to parallize on a single and multiple machines, respectively). Most runs for the benchmark were run on [AWS C5-instances](https://aws.amazon.com/en/ec2/instance-types/): In order to deploy this infrastructure, we used [Ansible](https://www.ansible.com).

The main script for running algorithms is in `run.py`, and configuration files are in `config/`. The following command would run REJ-ABC on `gaussian_linear`, for the first of ten observations, using a budget of 10k simulations:

```commandline
$ python run.py task=gaussian_linear task.num_simulations=10000 algorithm=rej-abc
```

The configuration for this run is the composition of the default configs in `config/config.yaml`, `config/task/gaussian_linear.yaml`, and `config/algorithm/rej-abc.yaml` and the overrides provided in the commandline call. Here, an override `task.num_simulation=10000` is used, which would have been `1000` by default, as defined in `config/task/gaussian_linear.yaml`. This composition is managed by Hydra: To better understand how Hydra works, we would recommend taking a moment to read the [Getting started guide of Hydra](https://hydra.cc/docs/intro), and possibly even the full tutorial at a later point. All other algorithms/tasks/simulation budgets can be launched by modifying the command above.

Results will be stored in a subfolder in `outputs/`. Similar to the raw results included in the repository, you will find the full config, posterior and posterior predictive samples and metrics (along with any additional artefacts the run produced).

It is also possible to launch multiple runs with a single command, when using `--multirun`:

```bash
$ python experiments/run.py --multirun task=gaussian_linear task.num_observation=1,2,3 task.num_simulations=1000,10000 algorithm=rej-abc,smc-abc
```

The above command would run Rejection ABC and SMC-ABC for the three observations, for 1k, and 10k simulations each. The 6 simulations would be launched sequentially, which is inefficient given that most workstation have multiple CPUs/GPUs available. We wrote two Hydra plugins to parallelize the workload:

1. Joblib launcher: The Joblib launcher parallelises runs on a single machine. Per default, it uses all available cores. To use it, simply add `hydra/launcher=joblib` to the command. [You can find more information about the plugin here](https://hydra.cc/docs/plugins/joblib_launcher).
2. Redis Queue launcher: [Redis Queue (RQ)](https://python-rq.org) is a "simple Python library for queueing jobs and processing them in the background with workers". The advantage over Joblib is that workloads can be distributed across multiple machines. [You can find more information about the plugin here](https://hydra.cc/docs/plugins/rq_launcher).

As explained in the plugin documentation, you will need to setup a [Redis server](https://redis.io) managing the queue in order to use this plugin. We used [Ansible](https://www.ansible.com) to set up headnode, worker instances and enqueuing runs when running the benchmark. Additional information including the Ansible playbooks used can be found in the `ansible/` subfolder of this repository.

We used the script `results.py` to compile the dataframes from raw results of runs. If you are adopting this code to run your own experiments, the following snippet will create a dataframe for raw results in subfolders:

```python
from utils import compile_df
df = compile_df(basepath="/path/to/raw/results/")
```

One useful and quick way to explore the results of runs is using [HiPlot](https://github.com/facebookresearch/hiplot). To use it, simply pass the analysis dataframe as obtained above in a notebook session:

```python
import hiplot as hip
hip.Experiment.from_dataframe(df).display()
```

## Citation

The manuscript is [available through PMLR](http://proceedings.mlr.press/v130/lueckmann21a.html):

```bibtex
@InProceedings{lueckmann2021benchmarking,
  title     = {Benchmarking Simulation-Based Inference},
  author    = {Lueckmann, Jan-Matthis and Boelts, Jan and Greenberg, David and Goncalves, Pedro and Macke, Jakob},
  booktitle = {Proceedings of The 24th International Conference on Artificial Intelligence and Statistics},
  pages     = {343--351},
  year      = {2021},
  editor    = {Banerjee, Arindam and Fukumizu, Kenji},
  volume    = {130},
  series    = {Proceedings of Machine Learning Research},
  month     = {13--15 Apr},
  publisher = {PMLR}
}
```

## License

MIT

repository: janfb/results

repo_name: janfb/results


text:
### Acapela

This TTS is based on the [Acapela engine](http://www.acapela-group.com/)

| Parameters | Required | Default | Choices                                                                   | Comment                                                                     |
|------------|----------|---------|---------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| voice      | YES      |         | 34 languages (https://acapela-box.com/AcaBox/index.php), example: "manon" | Check available voices on the web site                                      |
| spd        | NO       | 180     | Min: 120, Max: 240                                                        | Speech rate                                                                 |
| vct        | NO       | 100     | Min: 85, Max: 115                                                         | Voice shaping                                                               |
| cache      | No       | TRUE    | True / False                                                              | True if you want to use the cache with this TTS                             |

#### Notes

The voice name is attached to a specific language.
To test and get the name of a voice, please refer to [this website(https://acapela-box.com/AcaBox/index.php].

The generated file is mp3.


text:
# grunt-liquibase

> Simple integration of liquibase with grunt - specifically for postgresql (the postgresql jdbc driver is bundled as part of the module - if you want to add more support then feel free to fork)

## Getting Started
This plugin requires Grunt `~0.4.2`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-liquibase --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-liquibase');
```

## The "liquibase" task

### Overview
In your project's Gruntfile, add a section named `liquibase` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
	liquibase : {
		options: {
			username : 'DB_USERNAME',
			password : 'DB_PASSWORD',
			url : 'jdbc:postgresql://DB_HOST:DB_PORT/DB_NAME'
		},
		update: {
			command: 'update'
		},
		dropAll: {
			command: 'dropAll'
		},
		version : {
			command: 'version'
		}
	},
});
```

### Options

#### options.username
Type: `String`
Default value: `NONE - required`

Database user - passed into the `--username` argument to liquibase.

#### options.password
Type: `String`
Default value: `NONE - required`

Database password - passed into the `--password` argument to liquibase.

#### options.url
Type: `String`
Default value: `NONE - required`

JDBC url - passed into the `--url` argument to liquibase.

#### options.changeLogFile
Type: `String`
Default value: `changelog.xml`

Path to the changelog file for liquibase.

#### options.classpath
Type: `String`
Default value: `postgresql-9.3-1100.jdbc41.jar`

Path to the jar file containing the jdbc driver. The module contains this jar file so you don't need it if you are talking to a postgresql database. Passed into the `--classpath` argument to liquibase.

#### options.driver
Type: `String`
Default value: `org.postgresql.Driver`

JDBC driver class. Passed into the `--driver` argument to liquibase.

### Usage Examples

#### Default Options
In this example, the default options are used to update a postgresql database called test_db running on localhost at port 5432 using the user dbuser with password passwd with the contents of changelog.xml

```js
grunt.initConfig({
  liquibase: {
    options: {
    	username : 'dbuser',
		password : 'passwd',
		url : 'jdbc:postgresql://localhost:5432/test_db'
    },
    command: 'update'
  },
});
```

#### Custom Options
In this example, the location of the changelog file is modified.

```js
grunt.initConfig({
  liquibase: {
    options: {
    	username : 'dbuser',
		password : 'passwd',
		url : 'jdbc:postgresql://localhost:5432/test_db',
		changelog : 'src/database/dbchangelog.xml'
    },
    command: 'update'
  },
});
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).


text:
# WhitekitSlider

This is a Slider for [WhiteKit](https://github.com/whiteskull/whitekit)

## Installation

Add this line (or uncomment) to your WhiteKit's  Gemfile:

```ruby
gem 'whitekit_slider'
```

And then execute:

```bash
$ bundle install
````

Then run

```bash
$ rails g whitekit_slider
````

And then

```bash
$ rake db:migrate
```

## Component slider

This gem component of slider. You can add it in to the block. The component of slider takes some params.

Example default

```text
theme: 'standart'
effect: 'random'
slices: 15
boxCols: 8
boxRows: 4
animSpeed: 500
pauseTime: 3000
startSlide: 0
directionNav: true
controlNav: true
controlNavThumbs: false
pauseOnHover: true
manualAdvance: false
prevText: 'Prev'
nextText: 'Next'
randomStart: false
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
---
###############
# DO NOT EDIT
layout: publication
###############

###############
# TO EDIT
# pub title
title: "Blind People Interacting with Large Touch Surfaces: Strategies for One-handed and Two-handed Exploration"

# publication image
image:
 name: 2015_its.png
 alt-text: "A blind user exploring the table top with one finger on each hand. The tabletop has a frame above holding a Kinect sensor that is detecting the user's fingers."

description: "We report on a user study with 14 blind participants performing common touchscreen interactions using one and two-hand exploration. We investigate the exploration strategies applied by blind users when interacting with a tabletop. We identified six basic strategies that were commonly adopted and should be considered in future designs. We finish with implications for the design of accessible large touch interfaces."

 # authors of the publication
authors: "Tiago Guerreiro, Kyle Montague, João Guerreiro, Rafael Nunes, Hugo Nicolau, Daniel Gonçalves"

# link to the pdf
pdf: http://www.di.fc.ul.pt/~tjvg/amc/tabletop_its.pdf
award: Best Paper Award

external-links:
  - name: DOI
    url: https://dl.acm.org/doi/10.1145/2817721.2817743
  - name: Dataset
    url: https://www.dropbox.com/sh/03kc3og0nfxthe5/AAAlTWYhBq6pqbnTVqAwEYx1a?dl=0

venue: "ACM International Conference on Interactive Tabletops and Surfaces, Madeira, Portugal, November, 2015"
year: 2015
conference-name: ITS
#projects:
# - text_entry

# people associated with the publication
people:
 - tjvg

# area for filter purpose
area: access
###############
---

gha_language: HTML


text:
## Visitor Pattern
* Used to add new functionality to pre-existing data structures without cjamging their code.
* 2 Hierarchies. One for the visitor:

The other for the visitable:

## Structure and Participants

## Implementation
* Create a Visitor class hierarchy that defines a pure virtual visit() method in the abstract base class for each concrete derived class in the aggregate node hierarchy. Each visit() method accepts a single argument - a pointer or reference to an original Element derived class.
* Each operation to be supported is modelled with a concrete derived class of the Visitor hierarchy. The visit() methods declared in the Visitor base class are now defined in each derived subclass by allocating the "type query and cast" code in the original implementation to the appropriate overloaded visit() method.
* Add a single pure virtual accept() method to the base class of the Element hierarchy. accept() is defined to receive a single argument - a pointer or reference to the abstract base class of the Visitor hierarchy.
* Each concrete derived class of the Element hierarchy implements the accept() method by simply calling the visit() method on the concrete derived instance of the Visitor hierarchy that it was passed, passing its "this" pointer as the sole argument.
## Example
Visitor Interface:
~~~java
public interface Visitor {
    /** Visit a @a LeafNode. */
    void visit(LeafNode node);

    /** Visit a @a CompositeNegateNode. */
    void visit(CompositeNegateNode node);

    /** Visit a @a CompositeAddNode. */
    void visit(CompositeAddNode node);

    /** Visit a @a CompositeSubtractNode. */
    void visit(CompositeSubtractNode node);
    // ...
}
~~~
Visitor Implementation
~~~java
public class PrintVisitor implements Visitor {
    /** Ctor */
    public PrintVisitor() {
    }

    /** Visits a @a LeafNode and prints it contents. */
    public void visit(LeafNode node) {
        Platform.instance().addString(node.item() + " ");
    }

    /** Visit a @a CompositeNegateNode and prints its contents. */
    public void visit(CompositeNegateNode node) {
        Platform.instance().addString("-");
    }

    /** Visit a @a CompositeAddNode and prints its contents. */
    public void visit(CompositeAddNode node) {
        Platform.instance().addString("+ ");
    }

    /** Visit a @a CompositeSubtractNode and prints its contents. */
    public void visit(CompositeSubtractNode node) {
        Platform.instance().addString("- ");
    }
    // ...
 }
~~~
## Consequences
* Flexibility: Visitor algorithms and object structure are independent.
* Separation of Concerns: Localized functionality of visitor subclass.

## Double Dispatch

## Static Polymorphism

## References
* [SafariOnline](https://www.safaribooksonline.com/library/view/design-patterns-in/9780133489989/5_8.html)
* [Wiki](https://en.wikipedia.org/wiki/Visitor_pattern#Java_example)
* [SourceMaking](https://sourcemaking.com/design_patterns/visitor)

repository: spinaki/design-patterns

repo_name: spinaki/design-patterns