text:
# Slack bot starter

This provides a slack bot starter with a web server.

The bot will be coded using [botkit](https://github.com/howdyai/botkit).

The webserver is using [express](http://expressjs.com/) with [jade](http://jade-lang.com/) as the template engine and [sass](http://sass-lang.com/) as the stylesheet engine.

The database is [postgresql](http://www.postgresql.org/) using [knex](http://knexjs.org/) for interfacing with postgresql.

# Installation

Git clone this repo

    $> git clone git@github.com:kyle-ilantzis/slack-bot-starter.git my-bot

Copy [.env.example](.env.example) to the **.env** file

    $> cp .env.example .env

Edit the **.env** file with your slack api token and postgres credentials

    SLACK_API_TOKEN=xoxb-00000000000-ABCDEFGHIJKLMNOP
    POSTGRES_URL=postgres://username:password@host:port/mybot

Install dependencies

    $> npm install

Create the database tables

    $> npm install -g knex
    $> knex migrate:latest

Run the app

    $> node app.js

If all goes well you should have a bot connected to slack and a webserver running.

This starter kit starts with the most basic todo application. A webserver at localhost:3000 lists all todos and lets you add todos.

The bot can be told "todos" and then lists all todos on slack.

** Web server **

![todo-webserver](todo-webserver.png)

** Slack bot **

![todo-slackbot](todo-slackbot.png)

# How to

Below is a list of notes on how the starter kit was perceived.

## Global variables

To get you started faster some global variables are setup for you in [app.js](app.js).

* **ROOT**: the path to the project directory.
* **lodash**: as _ in the code, everyone likes lodash.
* **async**: help you with your async needs.
* **i18n**: help you with your localization needs.
* **database**: to be used by both the bot and web server.
* **bot**: to be used by the web server.

You would use these variables as follows:

    i18n.__('Todos');

    ...

    database.getTodos( (err, todos ) => ... );

No require statements needed.

## Database

Knex describes [migrations](http://knexjs.org/#Migrations-CLI) very well.
That is how you should be creating your database schema.

To add functions on the 'database' global variable view the files
[database/database.js](database/database.js)
and
[database/todos/todos.js](database/todos/todos.js)
for how the approach is done.

## Bot

Botkit describes very well [here](https://github.com/howdyai/botkit)
the api to program your bot.

To add functions on your bot view
[bot/bot.js](bot/bot.js)
and
[bot/todos/todos.js](bot/todos/todos.js)
for how the approach is done.

## Web server

The express web server is setup in [web/web.js](web/web.js).

To add controllers to your web server see [web/routes.js](web/routes.js) and
[web/controllers/todos.js](web/controllers/todos.js)

Views live in the [web/views](web/views) folder. Your controllers
use req.render( 'path/to/view', ... ) with "path/to/view" being relative to the web/views folder.

When the server boots all sass stylesheets are compiled to css that our placed beside its sass equivalent.

## Requires

For reasons of being consistent the starter kit favors fully qualified require statements. The ROOT global variable is used to define paths relative to the project's directory.

Requires then look like this:

    require(ROOT + '/database/todos/todos.js')(knex,database);

# LICENSE

MIT

repository: AlyssaBk/slack-bot-starter

repo_name: AlyssaBk/slack-bot-starter


text:
# Puccinia inflorescenticola Pole-Evans SPECIES

#### Status
ACCEPTED

#### According to
Index Fungorum

#### Published in
Trans. Roy. Soc. South Africa 5: 646 (1916)

#### Original name
Puccinia inflorescenticola Pole-Evans

### Remarks
null

repository: mdoering/backbone

branch_name: refs/heads/master

extension: md

license_type: permissive

repo_name: mdoering/backbone


text:
---
date: '2004-12-08T09:57:00-05:00'
old:
  layout: post
  oldcategories:
  - meta
  status: published
  timestamp: 09:57 AM Wednesday, December 08, 2004 EST
  wordpress_id: '128'
slug: morelinkspammerfun
tags:
- meta
title: More on Banning Link Spammers
url: /weblog/2004/12/08/morelinkspammerfun/
---

Looking through my weblogs I saw that I also was getting a lot of hits
from
[http://www.xopy.com/friendslinks.php](http://visualintensity.com/adminshop-com),
at first I thought it was a nifty site like
[del.icio.us](http://del.icio.us/) that allowed you to see friends
links.  It turns out that they're part of a group called
[AdminShop](http://visualintensity.com/adminshop-com/), and they're
basically doing link spamming.  So I needed to add them to my block
list.

Now this seems to cut down on most of my link spamming.  However, it
still isn't ideal.  I guess in an ideal world I'd set up small little
CGI that I'd force them to.  Once they hit they CGI they'd get their
IP address logged and immediately sent to pf for banning of the
client.  I suppose I could whip something like that up pretty easily,
but I don't have time right now.  And no, that doesn't mean it will be
done by tonight, I've got plenty of other stuff to do before then.

Also, I switched many of my redirects from 302 (temporary) to 301
(permanent) yesterday, however [BlogLines](http://www.bloglines.com/)
doesn't seem to have taken the hint.  Any ideas on how you can force
BlogLines to recognize a 301 and update its database if its repeatedly
received?  Also, I'm wondering why the request from BlogLines don't
include the
[If-modified-since or the If-none-match headers](http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers)?
If they did it would save them bandwidth and the hassle of having to
parse thousands of feeds that aren't updated on a daily basis.


text:
# [Marathon](https://mesosphere.github.io/marathon/) [![Build Status](https://travis-ci.org/mesosphere/marathon.png?branch=master)](https://travis-ci.org/mesosphere/marathon)

Marathon is an [Apache Mesos][Mesos] framework for long-running applications. Given that
you have Mesos running as the kernel for your datacenter, Marathon is the
[`init`][init] or [`upstart`][upstart] daemon.

Marathon provides a
[REST API](https://mesosphere.github.io/marathon/docs/rest-api.html) for
starting, stopping, and scaling applications. Marathon is written in Scala and
can run in highly-available mode by running multiple copies. The
state of running tasks gets stored in the Mesos state abstraction.

Try Marathon now on AWS with [Elastic Mesos](http://elastic.mesosphere.io) or with [Mesosphere for Google Compute Platform](http://google.mesosphere.io) and learn how
to use it in Mesosphere's interactive
[Marathon tutorial](http://mesosphere.com/learn/run-services-with-marathon/)
that can be personalized for your cluster.

Marathon is a *meta framework*: you can start other Mesos frameworks such as
Chronos or [Storm][Storm] with it to ensure they survive machine failures.
It can launch anything that can be launched in a standard shell. In fact, you
can even start other Marathon instances via Marathon.

Using Marathon versions 0.7.0+ and Mesos 0.20.0+, you can [deploy, run and scale Docker containers](https://mesosphere.github.io/marathon/docs/native-docker.html) with ease.

Documentation for installing and configuring the full Mesosphere stack with Mesos + Marathon is
available on the [Mesosphere website](http://mesosphere.com/docs/).

## Features

* *HA* -- run any number of Marathon schedulers, but only one gets elected as
    leader; if you access a non-leader, your request gets proxied to the
    current leader
* *[Constraints](https://mesosphere.github.io/marathon/docs/constraints.html)* - e.g., only one instance of an application per rack, node, etc.
* *[Service Discovery & Load Balancing](https://mesosphere.github.io/marathon/docs/service-discovery-load-balancing.html)* via HAProxy or the events API (see below).
* *[Health Checks](https://mesosphere.github.io/marathon/docs/health-checks.html)*: check your application's health via HTTP or TCP checks.
* *[Event Subscription](https://mesosphere.github.io/marathon/docs/rest-api.html#event-subscriptions)* lets you supply an HTTP endpoint to receive notifications, for example to integrate with an external load balancer.
* *Web UI*
* *[JSON/REST API](https://mesosphere.github.io/marathon/docs/rest-api.html)* for easy integration and scriptability
* *Basic Auth* and *SSL*
* *Metrics*: available at `/metrics` in JSON format

## Setting Up And Running Marathon

### Installation

#### Install Mesos

Marathon requires Mesos installed on the same machine in order to use a shared library.
One easy way is via your system's package manager.
Current builds for major Linux distributions are available
from on the Mesosphere [downloads page](http://mesosphere.com/downloads/)
or from Mesosphere's [repositories](http://mesosphere.com/2014/07/17/mesosphere-package-repositories/).

If building from source, see the
Mesos [Getting Started](http://mesos.apache.org/gettingstarted/) page or the
[Mesosphere tutorial](http://mesosphere.com/2013/08/01/distributed-fault-tolerant-framework-apache-mesos/)
for details. Running `make install` will install Mesos in `/usr/local` in
the same way as these packages do.

#### Install Marathon

Full instructions on how to install prepackaged releases are available [in the Marathon docs](https://mesosphere.github.io/marathon/docs/). Alternatively, you can build Marathon from source.

##### Building from Source

1.  To build Marathon from source, check out this repo and use sbt to build a JAR:

        git clone https://github.com/mesosphere/marathon.git
        cd marathon
        sbt assembly

1.  Run `./bin/build-distribution` to package Marathon as an
    [executable JAR](http://mesosphere.com/2013/12/07/executable-jars/)
    (optional).

### Running in Development Mode

Mesos local mode allows you to run Marathon without launching a full Mesos
cluster. It is meant for experimentation and not recommended for production
use. Note that you still need to run ZooKeeper for storing state. The following
command launches Marathon on Mesos in *local mode*. Point your web browser to
`http://localhost:8080` to see the Marathon UI.

    ./bin/start --master local --zk zk://localhost:2181/marathon

For more information on how to run Marathon in production and configuration
options, see [the Marathon docs](https://mesosphere.github.io/marathon/docs/).

## Developing Marathon

The [Marathon Project Wiki](https://github.com/mesosphere/marathon/wiki)
contains documentation on simplifying local development and testing of Marathon
including how to run a Mesos environment inside a preconfigured virtual machine
and a list of recipes for launching applications that test specific Marathon
features.

### Running the development Docker

Build tip:

    docker build -t marathon-tip .

Run it:

    docker run marathon-tip --master local --zk zk://localhost:2181/marathon

If you want to inspect the contents of the Docker:

    docker run -i -t --entrypoint=/bin/bash marathon-tip -s

## Marathon Clients

* [Ruby gem and command line client](https://rubygems.org/gems/marathon_client)

    Running Chronos with the Ruby Marathon Client:

        marathon start -i chronos -u https://s3.amazonaws.com/mesosphere-binaries-public/chronos/chronos.tgz \
            -C "./chronos/bin/demo ./chronos/config/nomail.yml \
            ./chronos/target/chronos-1.0-SNAPSHOT.jar" -c 1.0 -m 1024 -H http://foo.bar:8080
* [Scala client](https://github.com/guidewire/marathon-client), developed at Guidewire
* [Java client](https://github.com/mohitsoni/marathon-client) by Mohit Soni
* [Python client](https://github.com/thefactory/marathon-python), developed at [The Factory](http://www.thefactory.com)
* [Python client](https://github.com/Wizcorp/marathon-client.py), developed at [Wizcorp](http://www.wizcorp.jp)
* [Go client](https://github.com/jbdalido/gomarathon) by Jean-Baptiste Dalido
* [Node client](https://github.com/silas/node-mesos) by Silas Sewell

## Companies using Marathon

* [Airbnb](https://www.airbnb.com/)
* [Daemon](http://www.daemon.com.au/)
* [Disqus](https://www.disqus.com/)
* [eBay](http://www.ebay.com/)
* [The Factory](https://github.com/thefactory/)
* [Guidewire](http://www.guidewire.com/)
* [iQIYI](http://www.iqiyi.com/)
* [OpenTable](http://www.opentable.com/)
* [PayPal](https://www.paypal.com)
* [Sailthru](http://www.sailthru.com/)
* [Viadeo](http://www.viadeo.com)
* [WooRank](http://www.woorank.com)

Not in the list? Open a pull request and add yourself!

## Help

If you have questions, please post on the
[Marathon Framework Group](https://groups.google.com/forum/?hl=en#!forum/marathon-framework)
email list. You can find Mesos support in the `#mesos` channel on
[freenode][freenode] (IRC). The team at [Mesosphere][Mesosphere] is also happy
to answer any questions.

## Authors

Marathon was created by [Tobias Knaup](https://github.com/guenter) and
[Florian Leibert](https://github.com/florianleibert) and continues to be
developed by the team at Mesosphere and by many contributors from
the community.

[![githalytics.com alpha](https://cruel-carlota.gopagoda.com/678b61f70ab36917caf159d22ba55f76 "githalytics.com")](http://githalytics.com/mesosphere/marathon)

[Chronos]: https://github.com/airbnb/chronos "Airbnb's Chronos"
[Mesos]: https://mesos.apache.org/ "Apache Mesos"
[Zookeeper]: https://zookeeper.apache.org/ "Apache Zookeeper"
[Storm]: http://storm-project.net/ "distributed realtime computation"
[freenode]: https://freenode.net/ "IRC channels"
[upstart]: http://upstart.ubuntu.com/ "Ubuntu's event-based daemons"
[init]: https://en.wikipedia.org/wiki/Init "init"
[Mesosphere]: http://mesosphere.com/ "Mesosphere"

repository: airbnb/marathon

branch_name: refs/heads/production

gha_language: JavaScript

repo_name: airbnb/marathon


text:
# Comment Service

![Travis CI](https://travis-ci.org/unmade/discuss-project.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/unmade/discuss-project/badge.svg?branch=master)](https://coveralls.io/github/unmade/discuss-project?branch=master)

Simple comment service to externally hosts comments posted by users.

It features:
- threaded comments
- comment history
- user comment history
- export to `xml`
- real-time notification system

## Table of contents

* [QuickStart](#quickstart)
* [API](#api)
* [Development](#development)
  * [Testing](#testing)
  * [Extending available export formats](#extending-available-export-formats)
* [Benchmark](#benchmark)

## QuickStart

Clone repo and run:
```
docker-compose up --build
```

## API

Learn more about [API](docs/API.md)

## Development

Set up `.env` file with settings suitable for local development, for example:

```
DJANGO_DEBUG=True
DJANGO_SETTINGS_MODULE=discuss.settings.local
```

Start docker containers:
```
docker-compose -f docker-compose.yml -f docker-compose.local.yml up --build
```

### Testing

To run test:
```
docker-compose -f docker-compose.yml -f docker-compose.test.yml run test
```

### Extending available export formats

By default only export available only in `xml` format.

You could easily add more formats.
All you need to do is to modify `discuss.comment.outputters.CommentOutputter`:

```python
# comment.outputters

class CommentOutputter(Outputter):

    def __init__(self):
        super().__init__()
        # register formats here
        self.add_outputter('xml', 'text/xml', self.to_xml)
        self.add_outputter('csv', 'text/csv', self.to_csv)

    def to_xml(self, items):
        ...

    def to_csv(self, items):
        yield 'id,parent_id,content,created_at_str,author_email,author_username\n'
        for item in items:
            yield (
                f'{item["id"]},'
                f'{item["parent_id"]},'
                f'{item["content"]},'
                f'{item["created_at_str"]},'
                f'{item["author__email"]},'
                f'{item["author__username"]}\n'
            )

```

As you can see, you should define generator which yields chunks of data.

### Real-Time Notifications

To test real-time notifications simply run:
```
$ python3 discuss/notifier.py

Connected {'client_id': 'c8c96c8e-1a2b-488b-a444-46800799d54d'}
History: []
```

After that you could create/update/delete comment and see real-time notifications:
```
Connected {'client_id': 'c8c96c8e-1a2b-488b-a444-46800799d54d'}
History: []
Message: {'uid': 'Nh1NDMpn1Ihu640wlF379o', 'channel': 'thread:1_1', 'data': {'comment': {'id': 100167, 'content_type_id': 1, 'object_id': 1, 'content': '12345', 'parent': None, 'created_at': '2017-12-18T22:44:39.635045Z', 'author': {'username': 'fdooch', 'email'<EMAIL_ADDRESS>'user': {'username': 'fdooch', 'email'<EMAIL_ADDRESS>'action': 0}}
```

## Benchmark

For benchmarking was used this [dump](https://yadi.sk/d/4CGWoVL23QjaoR)

> To load dump download it and run:
> ```
> docker-compose up db
> docker exec -i {DB_CONTAINER_ID} psql -U discuss -c 'CREATE DATABASE discuss_benchmark'
> cat discuss_dump | docker exec -i {DB_CONTAINER_ID} psql -U postgres -d discuss_benchmark
> ```
> Don't forget to switch to this DB in your settings

Test database contains `100166` comments.
Depth of a tree of the most commented comment is `101` and number of descendants is `11409`

See benchmark [results](docs/BENCHMARK.md)

license: MIT

repository: unmade/discuss-project

gha_license_id: MIT

repo_name: unmade/discuss-project


text:
## react-native-segment-analytics

### Install

```
$ npm install react-native-segment-analytics --save
```

### IOS (CocoaPods)

```
pod 'Analytics'
pod 'React', :path => '../node_modules/react-native'
pod 'SegmentAnalytics', :path => '../node_modules/react-native-segment-analytics/ios'
```

#### Install the Cocoapods dependencies:

```
$ pod install
```

##### Headsup

Make sure that you have `libAnalytics.a` and `libSegmentAnalytics.a` in your *Linked Frameworks and Libraries*
You may have to import them manually.

![image](https://cloud.githubusercontent.com/assets/1058646/16497002/71f1f6ce-3eba-11e6-9a0d-6e2900d1afc2.png)

### Android

#### Add in android/settings.gradle

```
include ':react-native-segment-analytics'
project(':react-native-segment-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-segment-analytics/android')
```

#### Add in android/app/build.gradle

```
dependencies {
    ......
    compile project(':react-native-segment-analytics')

}
```

**If you're on RN > 29 apply these changes in `MainApplication.java`, otherwise in `MainActivity.java`**

```java
import com.charlires.segmentanalytics;
...
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new SegmentAnalyticsPackage() // <----- Register the module
    );
}
```

### Usage

#### Import the module
```
import RNSegmentIO from 'react-native-segment-analytics';
```

#### Set it up just ones inside your project

```
RNSegmentIO.setup("YOUR-SEGMENT-KEY");
```

#### Use it

```
RNSegmentIO.setup(configKey: string)

RNSegmentIO.identify(userId: string, traits: Object)

RNSegmentIO.track(trackText: string, properties: Object)

RNSegmentIO.screen(screenName: string, properties: Object)
```

> **Note:** remember to import it in every file you are going to use it.


text:
# A Game-Based Learning Approach to Teaching Interactive Computer Graphics

![screenshots/screenshot-hub.png](screenshots/screenshot-hub.png "The game's graphics evolve by completing stages and implementing missing features")

A majority of modern end-user applications in entertainment and productive domains utilize interactive computer graphics. Yet, the education of its underlying concepts and programming skills remain challenging to educators and students alike. The research field of game-based learning aims to exploit the favorable effects of play to motivate students and provide interactive learning environments. It thereby presents a potential solution to educational problems. This work introduces a concrete game-based approach to teaching computer graphics with an implemented extensible learning game. Overall, the application's development proved the game aspect to introduce new challenges to the development such as requiring the detailed balancing of assignment and game design. However, both the concept and final product have received majorly affirmatory sentiments from the focus group participants.

## Requirements

- Node.js to start the server

- Web browser to play the game

## Instructions
- Install dependencies:
`npm install`

- Generate documentation:
`bash ./generate_docs`

- Start web server:
`npm start`

## Notes
- Physics meshes must be convex, faces must have CCW (right hand rule) winding order and coplanar faces must not exist (must be merged into one).
- Physics object's center of mass is at the origin (0, 0, 0) of meshes in object coordinates.
- Graphical mesh faces must have CCW (right hand rule) winding order (for back-face culling) and must be triangulated (coplanar faces may exist).
- Blender .ply export settings to use: Format: ASCII, Forward: -Z, Up: Y, Geometry: Normals

repository: YouRik/GBL-ICG

repo_name: YouRik/GBL-ICG


text:
# Producers

In the world of stores, producers create data.
Whenever new data is available, the producer will emit a state change and update the state of the store it implements with the new value.

## fromInterval

*Lazy producer*

Emits incrementally increasing numbers at a regular interval while subscribed to.
As it is a lazy producer, the incremental increase is stopped when the store is in a deactivated state.

*Example*

```typescript
import * as Stuffit from 'stuffit';

// Once subscribed to, this store will emit increasing numbers every 5 seconds.
// The initial state is 0; the subsequent state changes will produce the values 1, 2, 3...
const intervalStore = Stuffit.Producers.fromInterval(5000);
```

## fromPromise

*Eager producer*

Takes a promise and transforms the state and data from the promise into an object.
Initially the state of this store will be a **pending** state.
Then, after the promise resolves, the store will change to a **fulfilled** state containing the resolved value.
Otherwise, if the promise rejects, the store will change to a **rejected** state containing the rejected error.

*Example*

```typescript
import * as Stuffit from 'stuffit';

// Create a store from a promise:
const fetchStore = Stuffit.Producers.fromPromise(fetch('http://example.org'));
// Initially the state will be "pending".
// Then the state either becomes "fulfilled" or "rejected" depending on the result of the promise.
fetchStore.subscribe((promiseResult) => {
    if (promiseResult.status === 'pending') {
        // Render a progress bar...
    } else if (promiseResult.status === 'rejected') {
        // Render an error message with `promiseResult.error`
    } else {
        // Do something with the result in `promiseResult.result`
    }
});
```

## fromValue

*Lazy producer*

A simple producer which only accepts some initial state and stays at that state indefinitely.
It doesn't do much, but can be useful in some situations.

*Example*

```typescript
import * as Stuffit from 'stuffit';

const valueStore = Stuffit.Producers.fromValue(42);
// The store's initial state is 42 and it will never emit a state change.
```

repository: woutervh-/stuffit

gha_language: TypeScript

repo_name: woutervh-/stuffit


text:
---
layout: post
title: Spotify Public Queue - for Parties, Car Rides, and Strangers
date: 2018-07-01
permalink: spotify-public-queue
---

> Spotify public queue is what you'll find LIVE over **[here]({{site.url}}/queue)** - add a song or two!
>
> Have you checked out **[Part 1]({{site.url}}/spotify-now-playing)** of this write-up yet? Do that first!

Intro

I love discovering new music.

Whether that be through Spotify's daily playlists, or through suggestions from a friend,  I really enjoy
discovering, diving into, and experiencing new music.

I've had this idea for a while - how can I make it dead-simple to add songs to a queue. With this post, i've taken it one
step further, letting *anyone* add to my queue.

Well ok...not *exactly* my queue. Song get added instead to a [playlist called "Josh's Public Queue"](https://open.spotify.com/user/joshspicer37/playlist/0OBq0h6EjCmaPXjeCB4IlM?si=6ZeWyAiRR0u51UJK-7Hb_g). You can follow and listen to that
playlist, and of course add song recommendations through this site.

Guide

Make sure you first go through the **[Spotify "now playing" post]({{site.url}}/spotify-now-playing)**. That post will
give you the background necessary in getting a Spotify client ID, as well as setting up AWS DynamoDB, API Gateway, and Lambda.
This guide is an extension of that post.

(The rest of the writeup will arrive shortly. [Add a song or two]({{site.url}}/queue) in the meantime....)


text:
# Welcome

A key tool used throughout the MSc in Health Data Science is the Python language.  Students taking the MSc are expected to be proficient in the fundamentals of python and must pass a short coding proficiency test before being accepted.

The materials presented here aim to support your preparation for the Python entry test for the MSc in Health Data Science.

```{note}
The materials here are not intended to be exhaustive.  In addition to the lectures and practicals included in this book we also recommend that you practice using

* Python for healthcare: https://pythonhealthcare.org/
* HackerRank:  https://www.hackerrank.com/
* Project Euler: https://projecteuler.net/
```

Good luck.

repository: health-data-science-OR/basic-python

branch_name: refs/heads/main

repo_name: health-data-science-OR/basic-python


text:
---
layout: page
title: Large data management using data.table
categories: [manipulation]
tags: [R, data.table]
fullview: false
comments: false
---

A walkthrough of various techniques that can be followed in order to perform efficient data manipulation of environmental data using the `data.table` package.

Before we start you need to setup your working directory by following this [link](https://github.com/mammask/EarthBiAs2017/blob/master/setupR.md).

Understanding the data structure
================================

The dataset of the precipitation records consists of 5 columns:

-   **STAID**: Station identifier
-   **SOUID**: Source identifier
-   **DATE** : Date YYYYMMDD
-   **RR** : Precipitation amount in 0.1 mm
-   **Q\_RR** : quality code for RR (0='valid'; 1='suspect'; 9='missing')

The dataset with the available meteorological stations consists of 9 columns:

-   **STAID**: Station identifier
-   **STABANE**: Station name
-   **CN**: Country name
-   **LAT**: Latitude
-   **LONG**: Longitude
-   **HGHT**: Station height
-   **latUpd**: Updated format of station latitude
-   **longUpd**: Updated format of station longitude
-   **LatLong**: Combined format of latitude and longitude

Data import
-----------

``` r
# Load libraries
library(data.table)
# Set working directory
setwd("~/Documents/EarthBiAs2017/")
# Read precipitation data
envDat <- readRDS("./data/spanishPrecipRecords.RDS")
# Convert dataset to DT
setDT(envDat)
# Obtain first six rows
head(envDat)
```

    ##    STAID SOUID     DATE  RR Q_RR
    ## 1:<PHONE_NUMBER>0101  35    0
    ## 2:<PHONE_NUMBER>0102 194    0
    ## 3:<PHONE_NUMBER>0103   0    0
    ## 4:<PHONE_NUMBER>0104 168    0
    ## 5:<PHONE_NUMBER>0105  61    0
    ## 6:<PHONE_NUMBER>0106   0    0

``` r
# Obtain column formats
str(envDat)
```

    ## Classes 'data.table' and 'data.frame':   3351644 obs. of  5 variables:
    ##  $ STAID: int  229 229 229 229 229 229 229 229 229 229 ...
    ##  $ SOUID: int  709 709 709 709 709 709 709 709 709 709 ...
    ##  $ DATE : int  19550101 19550102 19550103 19550104 19550105 19550106 19550107 19550108 19550109 19550110 ...
    ##  $ RR   : int  35 194 0 168 61 0 0 82 72 0 ...
    ##  $ Q_RR : int  0 0 0 0 0 0 0 0 0 0 ...
    ##  - attr(*, ".internal.selfref")=<externalptr>

``` r
# Read stations data
stationsData <- readRDS("./data/precipStations.RDS")
# Convert dataset to DT
setDT(stationsData)
```

Create new variables
--------------------

In `data.table` it is easy to create new variables or update existing ones using `:=` symbol:

``` r
# Create a new column with the max rainfall per station
envDat[Q_RR != 9, maxRainfall := max(RR, na.rm = T), by = STAID]
head(envDat)
```

    ##    STAID SOUID     DATE  RR Q_RR maxRainfall
    ## 1:<PHONE_NUMBER>0101  35    0        1191
    ## 2:<PHONE_NUMBER>0102 194    0        1191
    ## 3:<PHONE_NUMBER>0103   0    0        1191
    ## 4:<PHONE_NUMBER>0104 168    0        1191
    ## 5:<PHONE_NUMBER>0105  61    0        1191
    ## 6:<PHONE_NUMBER>0106   0    0        1191

You can easily delete a variable:

``` r
envDat[, maxRainfall := NULL]
```

Managing formats
----------------

In the previous section we used the `str` function to obtain the dataset formats and it seems that the `DATE` column is a vector of integers. The following script converts `DATE` in date format (`as.Date`):

``` r
envDat[,DATE:=as.Date(as.character(DATE), format("%Y%m%d"))]
```

`:=` is used in order to create a new column or update an existing one.

Subsetting
----------

In this section, we describe how to select specific rows and columns of a dataset and also make computations based on the subsets:

``` r
# Select the first 3 columns
envDat[, .(STAID, SOUID, DATE)]
```

    ##          STAID SOUID       DATE
    ##       1:<PHONE_NUMBER>-01-01
    ##       2:<PHONE_NUMBER>-01-02
    ##       3:<PHONE_NUMBER>-01-03
    ##       4:<PHONE_NUMBER>-01-04
    ##       5:<PHONE_NUMBER>-01-05
    ##      ---
    ## 3351640: 11383 56288 2017-02-24
    ## 3351641: 11383 56288 2017-02-25
    ## 3351642: 11383 56288 2017-02-26
    ## 3351643: 11383 56288 2017-02-27
    ## 3351644: 11383 56288 2017-02-28

``` r
# Select records where precipitation amount is equal to zero
envDat[RR == 0]
```

    ##          STAID SOUID       DATE RR Q_RR
    ##       1:<PHONE_NUMBER>-01-03  0    0
    ##       2:<PHONE_NUMBER>-01-06  0    0
    ##       3:<PHONE_NUMBER>-01-07  0    0
    ##       4:<PHONE_NUMBER>-01-10  0    0
    ##       5:<PHONE_NUMBER>-01-12  0    0
    ##      ---
    ## 2293354: 11383 75568 2016-12-27  0    0
    ## 2293355: 11383 75568 2016-12-28  0    0
    ## 2293356: 11383 75568 2016-12-29  0    0
    ## 2293357: 11383 75568 2016-12-30  0    0
    ## 2293358: 11383 75568 2016-12-31  0    0

``` r
# Compute number of rows where precipitation amount is equal to zero
envDat[RR == 0, .N]
```

    ## [1] 2293358

``` r
# Select specific rows and columns
envDat[RR == 0, .(STAID, SOUID, DATE)]
```

    ##          STAID SOUID       DATE
    ##       1:<PHONE_NUMBER>-01-03
    ##       2:<PHONE_NUMBER>-01-06
    ##       3:<PHONE_NUMBER>-01-07
    ##       4:<PHONE_NUMBER>-01-10
    ##       5:<PHONE_NUMBER>-01-12
    ##      ---
    ## 2293354: 11383 75568 2016-12-27
    ## 2293355: 11383 75568 2016-12-28
    ## 2293356: 11383 75568 2016-12-29
    ## 2293357: 11383 75568 2016-12-30
    ## 2293358: 11383 75568 2016-12-31

``` r
# Find number of records where Q_RR is equal to 9
envDat[Q_RR == 9, .N]
```

    ## [1] 260169

``` r
# Find number of records where Q_RR is equal to 0 or 1 and RR > 0
envDat[Q_RR != 9 & RR >=0, .N]
```

    ## [1] 3091475

``` r
# Find number of stations with at least one missing record
envDat[Q_RR == 9, uniqueN(STAID)]
```

    ## [1] 172

Group by
--------

``` r
# Count the number of records by station
envDat[, .N, by = STAID]
```

    ##      STAID     N
    ##   1:   229 22736
    ##   2:   230 35520
    ##   3:   231 27484
    ##   4:   232 26023
    ##   5:   233 26388
    ##  ---
    ## 196: 11346   425
    ## 197: 11347   425
    ## 198: 11348   425
    ## 199: 11382  3347
    ## 200: 11383  3347

``` r
# Count the number of records where precipitation amount is greater than 100 mm
# by station
envDat[RR >100, .N, by = STAID]
```

    ##      STAID    N
    ##   1:   229  956
    ##   2:   230 1236
    ##   3:   231 1206
    ##   4:   232 2979
    ##   5:   233  676
    ##  ---
    ## 196: 11346   23
    ## 197: 11347   17
    ## 198: 11348   14
    ## 199: 11382  268
    ## 200: 11383  170

``` r
# Count the number of records where precipitation amount is greater than 100 mm
# by station and available year
envDat[RR >100, .N, by = list(STAID,year(DATE))]
```

    ##       STAID year  N
    ##    1:   229 1955 19
    ##    2:   229 1956 14
    ##    3:   229 1957 10
    ##    4:   229 1958 16
    ##    5:   229 1959 16
    ##   ---
    ## 8631: 11383 2012 14
    ## 8632: 11383 2013 23
    ## 8633: 11383 2014 23
    ## 8634: 11383 2015 19
    ## 8635: 11383 2016 18

``` r
# Find the annual precipitation amount by station where missing records are omitted
envDat[Q_RR !=9, list(N = sum(RR)), by = list(STAID,year(DATE))]
```

    ##       STAID year    N
    ##    1:   229 1955 5735
    ##    2:   229 1956 5274
    ##    3:   229 1957 4121
    ##    4:   229 1958 4666
    ##    5:   229 1959 4552
    ##   ---
    ## 8687: 11383 2012 4024
    ## 8688: 11383 2013 7336
    ## 8689: 11383 2014 7615
    ## 8690: 11383 2015 5092
    ## 8691: 11383 2016 5911

``` r
# Perform more than one computations
envDat[Q_RR !=9, list(Total = sum(RR), Mean  = mean(RR)), by = list(STAID,year(DATE))]
```

    ##       STAID year Total     Mean
    ##    1:   229 1955  5735 15.71233
    ##    2:   229 1956  5274 14.40984
    ##    3:   229 1957  4121 11.29041
    ##    4:   229 1958  4666 12.78356
    ##    5:   229 1959  4552 12.47123
    ##   ---
    ## 8687: 11383 2012  4024 10.99454
    ## 8688: 11383 2013  7336 20.09863
    ## 8689: 11383 2014  7615 20.86301
    ## 8690: 11383 2015  5092 13.95068
    ## 8691: 11383 2016  5911 16.15027

Working with `shift`
--------------------

You can obtain the next or the previous rainfall record by using the `shift` function:

``` r
# Order rainfall records by station and date
envDat <- envDat[order(STAID,DATE)]
# Obtain DATE lag(1) for each station and fill missing values with -9999
envDat[, shift(x = DATE, fill = NA, n = 1, type = "lag"), by = STAID]
# Obtain RR lag(1) for each station and fill missing values with -9999
envDat[, shift(x = RR, fill = -9999, n = 1, type = "lag"), by = STAID]
# Obtain RR lag(2) for each station and fill missing values with -9999
envDat[, shift(x = RR, fill = -9999, n = 2, type = "lag"), by = STAID]
# Create new columns of lag(1,2) for each station and fill onobserved values
# with -9999
envDat[,`:=` (lag1 = shift(x = RR, fill = -9999, n = 1, type = "lag"),
              lag2 = shift(x = RR, fill = -9999, n = 2, type = "lag")),
       by = STAID]
```

Creating temporary variables
----------------------------

With `data.table` you can create temporary variables and based on their values you can further compute variables in just one step. In the following example, we create a lag(1) of the daily precipitation record per station and then we compute the mean and minimum precipitation by omitting missing records:

``` r
# Create a temporary variable of lag1 and compute the mean/min of lag1
envDat[Q_RR !=9, { lag1 =  shift(x = RR, fill = NA, n = 1, type = "lag")
                   list( MeanLag1 = mean(lag1, na.rm = T),
                         MinLag1  = min(lag1, na.rm = T))},
       by = STAID]
```

    ##      STAID MeanLag1 MinLag1
    ##   1:   229 12.98324       0
    ##   2:   230 11.92158       0
    ##   3:   231 14.87026       0
    ##   4:   232 36.25256       0
    ##   5:   233 10.39550       0
    ##  ---
    ## 196: 11346 20.47945       0
    ## 197: 11347 18.57419       0
    ## 198: 11348 14.28493       0
    ## 199: 11382 26.30940       0
    ## 200: 11383 16.11104       0

Special Symbols
---------------

### `SD`

`SD` is one of `data.table`'s special symbols and contains a subset of columns.

``` r
# Return all columns and all rows
envDat[, .SD]
```

    ##          STAID SOUID       DATE    RR Q_RR
    ##       1:<PHONE_NUMBER>-01-01    35    0
    ##       2:<PHONE_NUMBER>-01-02   194    0
    ##       3:<PHONE_NUMBER>-01-03     0    0
    ##       4:<PHONE_NUMBER>-01-04   168    0
    ##       5:<PHONE_NUMBER>-01-05    61    0
    ##      ---
    ## 3351640: 11383 56288 2017-02-24 -9999    9
    ## 3351641: 11383 56288 2017-02-25 -9999    9
    ## 3351642: 11383 56288 2017-02-26 -9999    9
    ## 3351643: 11383 56288 2017-02-27 -9999    9
    ## 3351644: 11383 56288 2017-02-28 -9999    9

``` r
# Return all columns and first row
envDat[, .SD[1]]
```

    ##    STAID SOUID       DATE RR Q_RR
    ## 1:<PHONE_NUMBER>-01-01 35    0

``` r
# Return all columns and the first record of each meteorological station
envDat[, .SD[1], by = STAID]
```

    ##      STAID SOUID       DATE    RR Q_RR
    ##   1:<PHONE_NUMBER>-01-01    35    0
    ##   2:<PHONE_NUMBER>-01-01     0    0
    ##   3:<PHONE_NUMBER>-01-01 -9999    9
    ##   4:<PHONE_NUMBER>-01-01    10    0
    ##   5:<PHONE_NUMBER>-01-01     0    0
    ##  ---
    ## 196: 11346 73105 2016-01-01     0    0
    ## 197: 11347 73114 2016-01-01 -9999    9
    ## 198: 11348 73123 2016-01-01     0    0
    ## 199: 11382 56405 2008-01-01     0    0
    ## 200: 11383 56288 2008-01-01     0    0

``` r
# Return all columns and the first non-missing record of each meteorological station
envDat[Q_RR != 9, .SD[1], by = STAID]
```

    ##      STAID SOUID       DATE RR Q_RR
    ##   1:<PHONE_NUMBER>-01-01 35    0
    ##   2:<PHONE_NUMBER>-01-01  0    0
    ##   3:<PHONE_NUMBER>-05-01  9    0
    ##   4:<PHONE_NUMBER>-01-01 10    0
    ##   5:<PHONE_NUMBER>-01-01  0    0
    ##  ---
    ## 196: 11346 73105 2016-01-01  0    0
    ## 197: 11347 73114 2016-01-04  2    0
    ## 198: 11348 73123 2016-01-01  0    0
    ## 199: 11382 56405 2008-01-01  0    0
    ## 200: 11383 56288 2008-01-01  0    0

``` r
# Return specific columns (station id, date and rainfall record)
envDat[,.SD, .SDcols = c("STAID","DATE", "RR")]
```

    ##          STAID       DATE    RR
    ##       1:   229 1955-01-01    35
    ##       2:   229 1955-01-02   194
    ##       3:   229 1955-01-03     0
    ##       4:   229 1955-01-04   168
    ##       5:   229 1955-01-05    61
    ##      ---
    ## 3351640: 11383 2017-02-24 -9999
    ## 3351641: 11383 2017-02-25 -9999
    ## 3351642: 11383 2017-02-26 -9999
    ## 3351643: 11383 2017-02-27 -9999
    ## 3351644: 11383 2017-02-28 -9999

It is very convenient to perform dynamic computations across many variables:

``` r
# Perform dynamic computations accross variables
envDat[, lapply(.SD, min), .SDcols = c("RR")]
```

    ##       RR
    ## 1: -9999

``` r
# Perform dynamic computations accross variables and by station
envDat[, lapply(.SD, min), .SDcols = c("RR"), by = "STAID"]
```

    ##      STAID    RR
    ##   1:   229     0
    ##   2:   230 -9999
    ##   3:   231 -9999
    ##   4:   232     0
    ##   5:   233     0
    ##  ---
    ## 196: 11346 -9999
    ## 197: 11347 -9999
    ## 198: 11348 -9999
    ## 199: 11382 -9999
    ## 200: 11383 -9999

``` r
# Perform dynamic computations accross variables and by station
# where rainfall records are non missing
envDat[Q_RR !=9, lapply(.SD, min), .SDcols = c("RR"), by = "STAID"]
```

    ##      STAID RR
    ##   1:   229  0
    ##   2:   230  0
    ##   3:   231  0
    ##   4:   232  0
    ##   5:   233  0
    ##  ---
    ## 196: 11346  0
    ## 197: 11347  0
    ## 198: 11348  0
    ## 199: 11382  0
    ## 200: 11383  0

``` r
# More variables can be added in SD
envDat[Q_RR !=9, lapply(.SD, min), .SDcols = c("RR", "Q_RR"), by = "STAID"]
```

    ##      STAID RR Q_RR
    ##   1:   229  0    0
    ##   2:   230  0    0
    ##   3:   231  0    0
    ##   4:   232  0    0
    ##   5:   233  0    0
    ##  ---
    ## 196: 11346  0    0
    ## 197: 11347  0    0
    ## 198: 11348  0    0
    ## 199: 11382  0    0
    ## 200: 11383  0    0

### `.N`

`.N` is a special in-built variable that holds the number of observations in the current group. When we group by`origin`, `.N` returns the number of rows of the dataset:

``` r
# Return the number of records per station
envDat[, .N, by = "STAID"]
# Create a counter variable per station
envDat[, c(1:.N), by = "STAID"]
```

`SD` can be combined with `.N` to access specific rows of the dataset:

``` r
# Return last record of each one of the three variables
envDat[,.SD[.N], .SDcols = c("STAID","DATE", "RR")]
# Return all but the last record for the selected columns
envDat[,.SD[1:(.N-1)], .SDcols = c("STAID","DATE", "RR")]
# Return all but the last record for the selected columns by station
envDat[,.SD[1:(.N-1)], .SDcols = c("STAID","DATE", "RR"), by = "STAID"]
```

### Exercise 1: Summary statistics

As a first task you will have to pick randomly 10 meteorological stations and compute the following metrics:

-   Mean, Min, Max, Median and Total rainfall amount (missing records are omitted)
-   Compute the number of missing records per station
-   Which is the month with the highest number of missing values per station?

`Join` using `data.table`
-------------------------

Before we provide examples about how to merge using the `data.table` approach please go through the following examples:

-   Joining data in R using `data.table` ([link](https://rstudio-pubs-static.s3.amazonaws.com/52230_5ae0d25125b544caab32f75f0360e775.html)).

In the following example we will compute the number of records per station and obtain the station name:

``` r
# Count the number of records per station
recsPerStat <- envDat[, .N, by = STAID]
# Define key for both datasets
setkey(recsPerStat, STAID)
setkey(stationsData, STAID)
# Obtain the station name from the stations table
recsPerStat[stationsData[, list(STAID, STANAME)], nomatch = 0L]
```

    ##      STAID     N                                  STANAME
    ##   1:   229 22736 BADAJOZ/TALAVERA LA REAL
    ##   2:   230 35520 MADRID - RETIRO
    ##   3:   231 27484 MALAGA AEROPUERTO
    ##   4:   232 26023 NAVACERRADA
    ##   5:   233 26388 SALAMANCA AEROPUERTO
    ##  ---
    ## 196: 11346   425 PANTA DE DARNIUS - BOADELLA
    ## 197: 11347   425 PUIGCERDA
    ## 198: 11348   425 TIVISSA
    ## 199: 11382  3347 OLOT
    ## 200: 11383  3347 LA POBLA DE SEGUR

``` r
# Obtain station with the most rainfall records - inner join
recsPerStat[stationsData[, list(STAID, STANAME)], nomatch = 0L][order(N, decreasing = T)]
```

    ##      STAID     N                                  STANAME
    ##   1:  3920 43980 GIRONA-NOU INSTITUT
    ##   2:  3930 43980 GIRONA (ANTIC INSTITUT)
    ##   3: 11040 43980 GIRONA
    ##   4:   336 42459 ALBACETE LOS LLANOS
    ##   5:   236 40998 TORTOSA - OBSERVATORIO DEL EBRO
    ##  ---
    ## 196: 11078  1704 SOLSONA
    ## 197: 11025   790 CASTELLNOU DE SEANA
    ## 198: 11346   425 PANTA DE DARNIUS - BOADELLA
    ## 199: 11347   425 PUIGCERDA
    ## 200: 11348   425 TIVISSA

In the next lecture we will find metrics for various stations and based on the stations' location we will create maps.

Environmental indices with `data.table`
---------------------------------------

### Number of days with "extreme" rainfall events

Extreme rainfall event is defined as a daily rainfall record exceeding a specific rainfall amount. In this case, we calculate the probability distribution of the daily rainfall series and we define extreme records those which exceed the 90% of the values.

``` r
# Calculate extreme rainfall events
# - Calculate the 90% of the values of the probability
#   distribution of daily rainfall
# - Find the records who exceed this threshold
# - Count the records who exceed this threshold
# - Make this computation for each station and each available year
envDat[Q_RR != 9, {extrVal     = quantile(RR, probs = 0.9)[[1]]
                   ExtrEv      = RR[RR > extrVal]
                   list(N = length(ExtrEv))
                   },
       by = list(STAID, year(DATE))]
```

    ##       STAID year  N
    ##    1:   229 1955 36
    ##    2:   229 1956 36
    ##    3:   229 1957 37
    ##    4:   229 1958 36
    ##    5:   229 1959 36
    ##   ---
    ## 8687: 11383 2012 35
    ## 8688: 11383 2013 37
    ## 8689: 11383 2014 37
    ## 8690: 11383 2015 37
    ## 8691: 11383 2016 36

In the previous example we included also the days with no rainfall amount. We can calculate the 90% of the probability distribution for the days with rainfall amount greater than zero:

``` r
# Calculate extreme rainfall events
# - Calculate the 90% of the values of the probability
#   distribution of daily rainfall
# - Find the records who exceed this threshold
# - Count the records who exceed this threshold
# - Make this computation for each station and each available year
envDat[Q_RR != 9, {extrVal     = quantile(RR[RR>0], probs = 0.9)[[1]]
                   ExtrEv      = RR[RR > extrVal]
                   list(N = length(ExtrEv))
                   },
       by = list(STAID, year(DATE))]
```

    ##       STAID year  N
    ##    1:   229 1955  9
    ##    2:   229 1956  7
    ##    3:   229 1957  8
    ##    4:   229 1958  9
    ##    5:   229 1959  9
    ##   ---
    ## 8687: 11383 2012  9
    ## 8688: 11383 2013 12
    ## 8689: 11383 2014 13
    ## 8690: 11383 2015  9
    ## 8691: 11383 2016 10

### Maximum number of consecutive rainfall events

In the following example, we compute the maximum number of consecutive rainfall days for each station and available year.

``` r
# Compute maximum number of consecutive daily rainfall events per station
# Temporary variables: idx        - indexing days with rainfall
#                      diff       - find if the current day and the next day are days with rainfall
#                      lagdiff    - shift series on position
#                      startPoint - create a starting point
envDat[, {idx        = 1*(RR>0);
          diff       = shift(x = idx, fill = 0, type = "lead", n=1) - idx;
          lagdiff    = c(0,diff[-.N])
          startPoint = 1*(lagdiff<0)
          list(DATE  = DATE,
               RR    = RR,
               group =cumsum(startPoint))},
          by = list(STAID, year(DATE))
      ][RR != 0, .N, by = list(STAID, year, group)][, list(Max = max(N)),
                                                                by = list(STAID, year)]
```

    ##       STAID year Max
    ##    1:   229 1955  10
    ##    2:   229 1956   9
    ##    3:   229 1957   6
    ##    4:   229 1958  13
    ##    5:   229 1959   6
    ##   ---
    ## 9367: 11383 2013  10
    ## 9368: 11383 2014   7
    ## 9369: 11383 2015   5
    ## 9370: 11383 2016   6
    ## 9371: 11383 2017  59

This example can be easily extended so as to compute the number of consecutive days per station, year and month.

``` r
# Compute maximum number of consecutive daily rainfall events per station
# Temporary variables: idx        - indexing days with rainfall
#                      diff       - find if the current day and the next day are days with rainfall
#                      lagdiff    - shift series one position
#                      startPoint - create a starting point
envDat[, {idx        = 1*(RR>0);
          diff       = shift(x = idx, fill = 0, type = "lead", n=1) - idx;
          lagdiff    = c(0,diff[-.N])
          startPoint = 1*(lagdiff<0)
          list(DATE  = DATE,
               RR    = RR,
               group =cumsum(startPoint))},
          by = list(STAID, year(DATE), month(DATE))
      ][RR > 0, .N, by = list(STAID, year, month, group)][, list(Max = max(N)),
                                                                by = list(STAID, year, month)]
```

    ##        STAID year month Max
    ##     1:   229 1955     1   6
    ##     2:   229 1955     2   5
    ##     3:   229 1955     3   3
    ##     4:   229 1955     4   1
    ##     5:   229 1955     5   4
    ##    ---
    ## 95194: 11383 2016     8   1
    ## 95195: 11383 2016     9   2
    ## 95196: 11383 2016    10   2
    ## 95197: 11383 2016    11   6
    ## 95198: 11383 2016    12   1

Also, this example can be easily extended in order to compute the maximum number of consecutive drought days.

### Exercise 2: Compute the maximum number of extreme consecutive rainfall events

You will need to count the maximum number of consecutive extreme rainfall events by station and by year considering that an extreme rainfall event is a record with value greater than the 90% of the distribution of daily rainfall of each station and year.

Visualization of environmental rainfall series
==============================================

Visualization of rainfall series - Annual rainfall amount
---------------------------------------------------------

In the following example we compute the annual rainfall amount for a specific meteorological station:

``` r
# Load dygraphs
library(dygraphs)
statID    <- envDat[,unique(STAID)][1]
annualSer <- envDat[STAID == statID & Q_RR != 9, list(N = sum(RR)), by = year(DATE)]
# Produce interactive plot of annual rainfall series
p <- dygraph(annualSer, main = paste0("Annual rainfall series of station: ",statID)) %>%
     dyAxis("y", label = "Rainfall amount (mm)") %>% dyAxis("x", label = "Year")
# p
```

We can add more features in the previous plot:

``` r
# Produce interactive plot of annual rainfall series
p <- dygraph(annualSer, main = paste0("Annual rainfall series of station: ",statID)) %>%
     dyAxis("y", label = "Rainfall amount (mm)") %>% dyAxis("x", label = "Year") %>%
     dyRangeSelector() %>% dyOptions(fillGraph = TRUE, fillAlpha = 0.4)
# p
```

In the following example we will compute a chart for each meteorological station using `data.table`:

``` r
# Function to produce plot of annual rainfall based on the station ID, year and rainfall amount
annualPlot <- function(year, N, ID){

  # function name: annualPlot
  #       purpose: to create annual rainfall series plots for each meteorological station
  #        inputs: year   - a vector with the available years
  #                N      - a vector with the annual rainfall series
  #                ID     - the station ID
metDat <- data.table(year, N)
p <- dygraph(metDat, main = paste0("Annual rainfall series of station: ",ID)) %>%
     dyAxis("y", label = "Rainfall amount (mm)") %>% dyAxis("x", label = "Year") %>%
     dyRangeSelector() %>% dyOptions(fillGraph = TRUE, fillAlpha = 0.4)

  return(p)
}

# Produce annual rainfall series
anRainfall <- envDat[Q_RR != 9, list(N = sum(RR)), by = list(STAID, year(DATE))]
# Produce all the available plots
plotList <- anRainfall[, list(Plot = list(annualPlot(year, N, STAID))), by = STAID]
# plotList
```

How can we access a specific plot?

### Exercise 3: - Produce plots for other summary statistics

-   Produce plots of the maximum number of consecutive rainfall events for each meteorological station and available year.

-   Can you replace the station ID by the station name at the title of the plots?

Calculation of annual rainfall trends for a specific station
------------------------------------------------------------

``` r
trendDat <- annualSer[, { trendModel = lm(data = data.table(year, N), formula = "N~1+year")
                          trendline  = coef(trendModel)[[2]] * year + coef(trendModel)[[1]]
                          list(year = year, N = N, trend = trendline)
                         }
          ]
head(trendDat)
```

    ##    year    N    trend
    ## 1: 1955 5735 5391.373
    ## 2: 1956 5274 5368.597
    ## 3: 1957 4121 5345.820
    ## 4: 1958 4666 5323.044
    ## 5: 1959 4552 5300.267
    ## 6: 1960 7180 5277.491

### Plot of annual rainfall trends for a specific station

``` r
p <- dygraph(trendDat, main = paste0("Annual rainfall series - Station: ", statID)) %>%
     dyAxis("y", label = "N") %>% dyAxis("x", label = "year") %>%
     dySeries("trend", stepPlot = FALSE, fillGraph = FALSE) %>%
     dyRangeSelector() %>% dyOptions(fillGraph = FALSE, fillAlpha = 0.4)
# p
```

Calculation of annual rainfall trends for all the available rainfall stations
-----------------------------------------------------------------------------

In the following example we compute the annual rainfall amount for each meteorological station and then annual rainfall trend per station is calculated:

``` r
# Calculate annual rainfall per station
annualSer <- envDat[Q_RR != 9, list(N = sum(RR)), by = list(STAID, year(DATE))]
# Calculate annual rainfall trend for each station
trendDat  <- annualSer[, { trendModel = lm(data = data.table(year, N), formula = "N~1+year")
                           trendline  = coef(trendModel)[[2]] * year + coef(trendModel)[[1]]
                           list(year = year, N = N, trend = trendline)
                         },
                       by = STAID
          ]
head(trendDat)
```

    ##    STAID year    N    trend
    ## 1:   229 1955 5735 5391.373
    ## 2:   229 1956 5274 5368.597
    ## 3:   229 1957 4121 5345.820
    ## 4:   229 1958 4666 5323.044
    ## 5:   229 1959 4552 5300.267
    ## 6:   229 1960 7180 5277.491

<!-- ## Spatial visualization -->
<!-- In this section we provide visualization outputs using the `leaflet` package. The following script provides the location of the meteorological station of Rhodes: -->
<!-- ```{r Spatial visualization - part 1, eval = TRUE, warning=FALSE, fig.width=9.5, fig.height=4} -->
<!-- # Load leaflet library -->
<!-- library(leaflet) -->
<!-- # Obtain information about Rhodes meteorological station -->
<!-- statInfo <- stationsData[STANAME == "RHODOS"] -->
<!-- # Create leaflet map using the station coordinates -->
<!-- m <- leaflet() %>% setView(lng =statInfo[,longUpd],  lat = statInfo[,latUpd], zoom = 7) -->
<!-- m %>% addTiles()  %>% addMarkers(lng =statInfo[,longUpd],  lat = statInfo[,latUpd],  -->
<!--                                  popup="Rhodes Meteorological Station") -->
<!-- ``` -->
<!-- <br> -->
<!-- Following the same logic we can produce maps of all the available meteorological stations in Greece: -->
<!-- ```{r  Spatial visualization - part 2, eval = TRUE, warning=FALSE, fig.width=9.5, fig.height=4} -->
<!-- greekStations <- stationsData[CN=="GR"] -->
<!-- # Create leaflet map using the stations coordinates -->
<!-- m <- leaflet() %>% setView(lng =greekStations[,mean(longUpd)],  lat = greekStations[,mean(latUpd)], zoom = 6) -->
<!-- m %>% addTiles()  %>% addMarkers(lng = greekStations[,longUpd],  lat = greekStations[,latUpd],  -->
<!--                                  popup = greekStations[,STANAME]) -->
<!-- ``` -->
<!-- <br> -->
<!-- In the following example we will incorporate information about the height of each meteorological station at each popup: -->
<!-- ```{r  Spatial visualization - part 3, eval = TRUE, fig.width=9.5, fig.height=4, message=FALSE, warning=FALSE, results='hide'} -->
<!-- # Load library stringr -->
<!-- library(stringr) -->
<!-- greekStations <- stationsData[CN=="GR"] -->
<!-- greekStations[, Description:= paste0("Station: ",str_to_title(STANAME), "<br> Height: ", HGHT, " m")] -->
<!-- ``` -->
<!-- ```{r  Spatial visualization - part 4, eval = TRUE, warning=FALSE, fig.width=9.5, fig.height=4} -->
<!-- # Create leaflet map using the stations coordinates -->
<!-- m <- leaflet() %>% setView(lng =greekStations[,mean(longUpd)],  lat = greekStations[,mean(latUpd)], zoom = 6) -->
<!-- m %>% addTiles()  %>% addMarkers(lng = greekStations[,longUpd],  lat = greekStations[,latUpd],  -->
<!--                                  popup = greekStations[,Description]) -->
<!-- ``` -->
<!-- ### Exercise 4: Develop a spatial map -->
<!-- + Create a map of all the Spanish meteorological stations including the height of each station. -->


text:
---
title: "Connecting Datasource to Widget"
id: "connecting-datasource-to-widget"
---
---

Follow this series of video tutorials to build a simple employee directory app in about less than 5 minutes using WaveMaker Studio.

### 3. Connect imported database with widgets (1:17 seconds

<iframe width="700" height="394" src="https://www.youtube-nocookie.com/embed/sdC_4yv-D7Q?rel=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media" allowfullscreen></iframe>

## Coming up next

---

### [4. How to preview and test your app (00:48 seconds)](/learn/tutorials/build-app-in-5-minutes/preview-test-app)

repository: wavemaker/docs

repo_name: wavemaker/docs


text:
# Bayesian Logistic Regression

![CI](https://github.com/Elsa-Health/bayesian-logistic-regressor/workflows/ci-test-coverage/badge.svg?branch=dev)
[![Coverage Status](https://coveralls.io/repos/github/Elsa-Health/bayesian-logistic-regressor/badge.svg?branch=test/init-workflow)](https://coveralls.io/github/Elsa-Health/bayesian-logistic-regressor?branch=test/init-workflow)

According to Wikipedia:

> In statistics, the logistic model (or logit model) is used to model the probability of a certain class or event existing such as pass/fail, win/lose, alive/dead or healthy/sick. This can be extended to model several classes of events such as determining whether an image contains a cat, dog, lion, etc. Each object being detected in the image would be assigned a probability between 0 and 1, with a sum of one.

For more information please [see this page](https://en.wikipedia.org/wiki/Logistic_regression#:~:text=Logistic%20regression%20is%20a%20statistical,a%20form%20of%20binary%20regression).)

This repository makes the logistic regression model more bayesian by accounting for uncertainities in the coefficients.

To install:
_Yarn_
`yarn add bayesian-logistic-regressor`

_npm_
`npm install --save bayesian-logistic-regressor`

**Example:**

Below is an examble of using Bayesian logistic regression to classify the risk of non adherence for HIV patients using Anti Retroviral Therapy Medication

```typescript
const intercept = normal(0.6508878758727246, 0.2264982936096282);
const age = normal(-0.21962766469973202, 0.03269431515510608);
const edu_lev = normal(-0.5272945932107651, 0.05905121110792727);
const share_drugs = normal(1.2688017000378393, 0.8698750752572072);
const occupation = normal(-0.3442870769761993, 0.03766084731176981);
const side_effect = normal(0.954476056820323, 0.25315211689704664);
const understand_reg = normal(1.1073743170216346, 0.4689712444172365);
const alc_drinks = normal(0.297833433932746, 0.2612879518029633);
const sex = normal(0.1267616891927831, 0.11690499307270034);

const coefficients = [
  occupation,
  age,
  share_drugs,
  understand_reg,
  side_effect,
  edu_lev,
  alc_drinks,
  sex,
];

const patients = [[0.0, -1.0636597901584577, 0.0, 0.0, 2.0, 2.0, 0.0, 1.0]];

const terms = patients.map(patient =>
  patient.map((val, idx) => [val, coefficients[idx]])
)[0];

const answer = logitRegressor(500, ...terms, intercept);
```

Welcoming any contributions! Please see our [Contribution Guides](CONTRIBUTION.md) for more information.

#### TODOs

- [x] Support normally (gaussian) distributed coefficients
- [x] Add base tests for each distribution
- [ ] Improved sampling perfomance
- [ ] Add support for more distributions
  - [ ] Bernoulli
  - [ ] Cauchy
  - [ ] Poisson
- [ ] Improved DLS support

repository: Elsa-Health/bayesian-logistic-regressor

repo_name: Elsa-Health/bayesian-logistic-regressor


text:
```@meta
EditURL = "https://github.com/TRAVIS_REPO_SLUG/blob/master/"
```

# HOMEWORK: Packages

[![](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TRAVIS_REPO_SLUG/gh-pages?filepath=TRAVIS_TAG/notebooks/08_Packages_Homework.ipynb)
[![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](https://nbviewer.jupyter.org/github/TRAVIS_REPO_SLUG/blob/gh-pages/TRAVIS_TAG/notebooks/08_Packages_Homework.ipynb)

Modules and packages are a nice way to organize code. You can read about how
to deal with packages from the Julia manual
[Modules](https://pkg.julialang.org/docs/julia/THl1k/1.1.0/manual/modules.html)
and [Pkg](https://pkg.julialang.org/docs/julia/THl1k/1.1.0/stdlib/Pkg.html#Pkg-1)
sections and from the
[package manager documentation.](https://julialang.github.io/Pkg.jl/v1/)

## PkgTemplates

The quickest and simplest way to create a package is using
[PkgTemplates](https://github.com/invenia/PkgTemplates.jl). For example,
this Julia package was generated using the `interactive_template` and
`generate` functions of `PkgTemplates`.

Also, this package website/documentation and jupyter notebooks are generated
using [Documenter](https://github.com/JuliaDocs/Documenter.jl)
and [Literate](https://github.com/fredrikekre/Literate.jl).

#### Homework

Use *PkgTemplates* to create a small *PersonalUtils.jl* package. Include your
function to read fasta files from the previous homework in your package module
and add unit tests for it.

*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*

repository: diegozea/JuliaForBioinformatics

repo_name: diegozea/JuliaForBioinformatics


text:
---
layout: post
share: true
comments: true
can-subscribe: true
title: "Should you freelance while starting a company?"
---

Most of the time, no, you should not freelance while starting a company.  I learned this lesson in the last week, from my own experiences plus several friends telling me the same.

# Freelancing is a slippery slope back to employment

My buddy Dustin Oliver shared a story with me today.  He has two friends who attempted to start a company together.  Let's call them Eddie and Christine.  Eddie is a bright designer/front-end guy, and Christine is a bright front-end/back-end girl.  That's a solidly technical founding team.

They both quit their jobs to work on their startup attempt full-time.  But, to pay bills, they did consulting while also launching their company.

The most lucrative consulting gigs were with the biggest clients.  So they took contracts with the biggest clients.  However, bigger clients have not just deeper pockets, but also bigger demands.

Both Eddie and Christine ended up spending all their time consulting.  None of their work went into their own business.

Five months later, Eddie and Christine ended up throwing in the towel.  They went their separate ways and got full-time jobs at separate companies.  Their startup attempt reduced to just a lengthy transition between jobs.

# Freelancing is not the correct method to receive money

If you want to create a business, you probably want to decouple the relationship between your time spent working and your income.  You probably want to make money by selling products, not by working for an hourly wage or an annualized salary.

Freelancing is just more of the thing you're avoiding:  trading off your time directly for money.

# The cool kids avoid freelancing

Earlier today, I was chatting with Spencer Walden about our respective startup attempts.  Spencer and I have very similar startup goals.  He mentioned that he would avoid freelancing as long as possible.

I'm joining Spencer.  I'm also avoiding freelancing as long as possible.

Be like me and Spencer.  Be a cool kid.  Succumb to my friendly peer pressure and avoid freelancing.    At that point, maybe I'll be openminded to full-time employment again, and maybe I'll just get a normal job.

That's all a future possibility.  In the present, I want to focus all my energy on my own goals.

# My part-time consulting gig

Last week, I did some part-time consulting work.  This week, my client and I both realized that it wasn't going to work out any longer.  On my end, I felt like I committed too much time to consulting.

I learned a lot from my client, and I'm grateful for the experience.  I learned about how to be a good freelancer, and I especially learned that freelancing is a bad idea for me.

Sometimes the only way to learn these lessons is the hard way.

repository: dillonforrest/startup

branch_name: HEAD

repo_name: dillonforrest/startup


text:
# 9arm Button

![Doctor Arm](public/img/9arm.JPG)

Let's blow your ear with some doctor sound!

## Disclaimer

Code in this website is copy from these two repositories.
- [Aom's Prophet Button](https://github.com/SaltyAom/prophet-button)
- [Hololive button](https://github.com/HelloYeew/hololive-button)

## Live Website

[![Netlify Status](https://api.netlify.com/api/v1/badges/960c3574-645a-41e2-8f96-ec21a9cc2b68/deploy-status)](https://app.netlify.com/sites/9arm-button/deploys)

[https://9arm-button.netlify.app/](https://9arm-button.netlify.app/)

## For Development

clone this repo and then

```shell
npm install
or
yarn install
```

and to run live preview with snowpack

```shell
npm start

```

or to build a website use this command

```shell
npm run build
```

# Contribution

You can fork, add some new epic doctor sound and send a pull request to merge to a main website.


text:
## Office Clerk

[![Join the chat at https://gitter.im/rubyclerks/office_clerk](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rubyclerks/office_clerk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/rubyclerks/office_clerk.svg?branch=master)](https://travis-ci.org/rubyclerks/office_clerk)
[![Gem Version](https://badge.fury.io/rb/office_clerk.svg)](http://badge.fury.io/rb/office_clerk)
[![Code Climate](https://codeclimate.com/github/rubyclerks/office_clerk/badges/gpa.svg)](https://codeclimate.com/github/rubyclerks/office_clerk)
[![Test Coverage](https://codeclimate.com/github/rubyclerks/office_clerk/badges/coverage.svg) 300+](https://codeclimate.com/github/rubyclerks/office_clerk)

Office Clerk is the back office helper, your accountant, storage manager, secretary and more. It is the heart of the [RubyClerks team](http://rubyclerks.org) , the manager as it were.

####  Status

In production for 2 sites. Work continues on refinements. That could qualify for 1.0 but i'll wait a few months.

### Other clerks

The original plan (as per web-site) is being implemented: several extension "clerk" will be optional. Some are ready (one not)

### AccountantClerk

This currenly does graphical sales reports. Purchase order creation is planned.

### Print Clerk

A invoice generator. Also barcode generation and receipt printing (for POS use).

### Sales Clerk

We have a shop [online](http://auringostaitaan.fi/), the best way to get started is to clone [it](https://github.com/rubyclerks/sales_clerk).

### Getting Started

The easy way (tryout or new project):

- clone sales_clerk
- bundle and migrate it
- change the git/config
- start editing

The longer route, adding to existing project

- add office_clerk  to Gemfile (gem or git)
- build your public pages
- possibly copy ShopController from sales_clerk as a starting point

### Further

If you got this far and still have question , mail me, or mail the [list](https://groups.google.com/forum/#!forum/rubyclerks)

Check the [User Guide](http://rubyclerks.org/user_guide/01_index.html),
then the [Developer Guide](http://rubyclerks.org/developer_guide/01_index.html).

Fill issues if you find, or discuss with me for ideas.

### Similar Projects

 * "Spree":http:spreecommerce.com , the grandfather of the rails ecommerce has grown big and mighty
 * "Ror-e":http://ror-e.com/ has some nice purchase features, and did great work to standardise rails usage
 * "MarketStreet":https://github.com/alex-nexus/market_street/ has taken the ball from ror-e and is running strong with an impressive list of goals
 * "TryShoppe":http://tryshoppe.com/ is new and lightweight. Very nice looking interface.

gha_language: Ruby


text:
# JSON File DAO implementation

This module implements the AnimalDao using the Jackson library to serialise jsva objects as Json files.

If you build the dao-json module, you will see that the tests persist the list of animals as a file in the target directory

```
/target/testDaoFile.json

{
  "animals" : [ {
    "id" : 1,
    "name" : "name_1",
    "address" : "address_1",
    "animalType" : {
      "sound" : "woof",
      "type" : "Dog"
    }
  }, {
    "id" : 2,
    "name" : "name_2",
    "address" : "address_2",
    "animalType" : {
      "sound" : "meow",
      "type" : "Cat"
    }
  }, {
    "id" : 3,
    "name" : "name_3",
    "address" : "address_3",
    "animalType" : {
      "sound" : "moo",
      "type" : "Cow"
    }
  } ],
  "currentMaxId" : 3
}
```

The Jackson project is documented here https://github.com/FasterXML/jackson-docs

For a simple tutorial on Jackson see https://www.baeldung.com/jackson-object-mapper-tutorial

gha_language: Java


text:
# Basics: 1. Game Objects and Scripts

[https://catlikecoding.com/unity/tutorials/basics/game-objects-and-scripts/](https://catlikecoding.com/unity/tutorials/basics/game-objects-and-scripts/)


text:
# alfn

[![GoDoc](https://godoc.org/github.com/bep/alfn?status.svg)](https://godoc.org/github.com/bep/alfn)

**alfn** (Aggregated Latest Filtered News) is a great little tool to create your own RSS feed about only the stuff you´re really interested in! Just configure it with the feeds to watch and what to watch for, and just sit back and wait for the updates. Oh, and it supports hotreloading configuration changes!

[![Build Status](https://travis-ci.org/bep/alfn.svg)](https://travis-ci.org/bep/alfn)

## Install

The easiest way to install the binary is via `go get`:

``` bash
go get github.com/bep/alfn
```

Then run it with the `-h` flag to see the options available:

```
alfn -h
```

## Configure

`alfn` looks, by default, for configuration named either `config.toml`,  `config.yaml` or  `config.json` in either `$HOME/.alfn` or `/etc/alfn/`. The config file to use can also be set in the `--config` flag.

Below is an imaginary `liverpool-feed.toml` -- a feed about the Premier League football club Liverpool:

```
feeds = [
 	"http://www.telegraph.co.uk/sport/football/teams/liverpool/rss",
	"http://feeds.bbci.co.uk/sport/0/football/premier-league/rss.xml",
	"http://www.theguardian.com/football/premierleague/rss"
]

[[matchers]]
# If it doesn't contain any of these, stop looking.
# Note: The search also includes the RSS URL
pattern="football|premier-?\\s?league"
matchBreaker=true

[[matchers]]
# Beatles was from Liverpool, but have little to do with the football team, so skip those.
pattern="Beatles"
matchBreaker=true
negate=true

# The matcher(s) below decide what to include. Any article matching any of the
# regular expressions will be added to the feed.
# Add more matchers sections as needed.
[[matchers]]
pattern="Liverpool|J(u|ü)rgen (Norbert)? Klopp"

[[matchers]]
pattern="Joe Gomez|Philippe Coutinho|Simon Mignolet"

[feed]
title="My Feed About Liverpool FC"
description="An RSS feed about the great football team!"
link="" # Defaults to the http://<server>:<port>
languageCode="EN-us"
copyright="2015 @ yourname"
maxItems=20
[feed.author]
name="Your Name"
<EMAIL_ADDRESS>```

Then start your server pointing to the config file above:

```bash
alfn --config=/path/to/config/liverpool-feed.toml

Using config file: /path/to/config/liverpool-feed.toml

Starting server on http://<IP_ADDRESS>:1926 ...

2 filtered item(s) in http://feeds.bbci.co.uk/sport/0/football/premier-league/rss.xml
1 filtered item(s) in http://www.theguardian.com/football/premierleague/rss
17 filtered item(s) in http://www.telegraph.co.uk/sport/football/teams/liverpool/rss

```

## Credits

The best open source projects lean lazily on the great work of others:

* [go-pkg-rss](https://github.com/jteeuwen/go-pkg-rss)
* [Graceful](https://github.com/tylerb/graceful)
* [Cobra](https://github.com/spf13/cobra)
* [Viper](https://github.com/spf13/viper)

repository: bep/alfn

repo_name: bep/alfn


text:
# Chat App using python

## Using async programming

### Referring [blockchain-book repsitory](https://github.com/dvf/blockchain-book/tree/main/chapters/chapter_5) by [Daniel van Flymen](https://github.com/dvf)

## Run the app

#### Start the Server

```
$ python terminal/server.py
```

#### In Another Terminal

```
nc localhost 8888
```

#### In A Third Terminal

```
nc localhost 8888
```

#### A sample code on coroutines:

[coroutines.py](/coroutines.py)


text:
## Cycling Teams

| Team | ShrtNm | Nation | Level | Focus |
|-------|-------|---------|-------|-----|
| Nova Sports Equipment | NSE | [[Fruinia]] | Pro | [[Hilly]]
| Excelvelo Bikes | EXB | [[Hetvesia]] | Pro | [[HillyMountain]]
| Kraken Big Data | KBD | [[Gasmea]] | Pro | [[FlatHilly]]
| Coldman Socks Finance | CSF | [[Gasmea]] | Pro | [[Cobble]]
| Telecom Archana | TEL | [[Archana]] | Pro | [[TT]]Hilly
| Dalluha Deep Oil Inc. | DDO | [[Dalluha]] | Pro | [[Flat]]
| Bank of Hetvesia | BOH | [[Hetvesia]] | Pro | [[Mountain]]
| Giga Cola Sport | GCS | [[Fruinia]] | Pro | [[FlatHilly]]
| Meadow Meister Milk | MMM | [[Hetvesia]] | Pro | [[Hilly]]
| Bick Bank Team | BIC | [[Gasmea]] | Pro | [[HillyMountain]]
| Ultimate Sportsware | USW | [[Fruinia]] | Pro | [[HillyMountain]]
| Five Mountains Clothing | FMC | [[Hetvesia]] | Pro | [[Mountain]]
| Noble & Young Investment | NYI | [[Gasmea]] | Pro | [[Cobble]]
| Ultraboost Energy Drink | UED | [[Archana]] | Pro | [[HillyMountain]]
| Dalluhan Airways | DAW | [[Dalluha]] | Pro | [[FlatHilly]]
| Archana Tourism | ART | [[Archana]] | Pro | [[TT]][[Flat]]
| Dicky's Raiders | DIK | [[Gasmea]] | Pro | [[FlatHilly]]
| Hydrovein Power Inc. | POW | [[Hetvesia]] | Amateur | [[Hilly]]
| Brainbender Analysis LLC | BAN | [[Gasmea]] | Pro | [[Cobble]]
| Fastroad Deliveries | FDL | [[Dalluha]] | Amateur | [[Flat]]
| Kirkstad Heritage Racing | KHR | [[Gasmea]] | Pro | [[Cobble]]
| Sala & Bianco Insurances | SBI | [[Fruinia]] | Pro | [[TTHilly]]
| Vista Watches Team | VWT | [[Hetvesia]] | Amateur | [[TT]][[Mountain]]
| Tailgate Communications | TCO | [[Gasmea]] | Amateur | [[Flat]]
| Adscope Targeting Ltd. | ADS | [[Fruinia]] | Amateur | [[FlatHilly]]
| Discovery Travels | DCT | [[Hetvesia]] | Amateur | [[Hilly]]
| Doriana Velo Tours | DVT | [[Fruinia]] | Amateur | [[Flat]]
| Crafton Steelworks & Co | CSW | [[Gasmea]] | Amateur | [[Cobble]]
| Xenatek Computing Team | XEN | [[Gasmea]] | Amateur | [[Cobble]]
| Vianta Health Foundation | VHF | [[Gasmea]] | Amateur | [[Hilly]]
| Rail'n Road Transports | RRT | [[Archana]] | Amateur | [[FlatHilly]]
| Wholesome TV Entertainment | WTV | [[Hetvesia]] | Amateur | [[TT]][[Hilly]]
| Hinterlands Adventures | HAD | [[Archana]] | Amateur | [[Hilly]]
| Basara Real Estate | BRE | [[Dalluha]] | Amateur | [[FlatHilly]]
| BAM Racing Team | BAM | [[Gasmea]] | Amateur | [[FlatHilly]]
| Tierso University Team | TUT | [[Fruinia]] | Amateur | [[Hilly]]
| Lannen Sports Academy | LAN | [[Gasmea]] | Amateur | [[Mountain]]
| Harford Road Services | HRS | [[Gasmea]] | Amateur | [[Cobble]]
| Archon Fitness Racing | ARC | [[Archana]] | Amateur | [[TT]][[Flat]]
| Channel 69 Cycling | CHC | [[Archana]] | Amateur | [[Flat]]
| Enrico Chivaldori Racing | ECR | [[Fruinia]] | Amateur | [[Cobble]]
| Automation Cycling Team  | ACT | [[Gasmea]] | Amateur | [[Flat]]
| Hector Morales Cycling | HMC | [[Archana]] | Amateur | [[HillyMountain]]
| Dubious Monk Racing | [[DMR]] | [[Hetvesia]] | Amateur | [[HillyMountain]]

repository: jju/bike

repo_name: jju/bike


text:
# Docker Base Images from Sunny Bear
(credit to Brandon Mitchell)

These base images include:

- /etc/entrypoint.d for all entrypoint scripts
- `wait-for-it.sh` from https://github.com/vishnubob/wait-for-it
- `fix-perms` to match uid/gid of user inside container to a mounted volume
- `gosu` to run commands as a non-root user after setup in the entrypoint
- Secrets imported into environment variables
- `save-volume` and `load-volume` to cache and initialize volume data from the
  image in scenarios where docker would not normally do this
- `stop-on-trigger` which can stop the container on a condition

## Platform specific additions

Debian base image includes:

- `apt-install`: runs apt update and install with non-interactive options and
  performs a cleanup

Alpine base image includes:

- `apk-install`: runs an `apk add` with options to avoid caching
- The "shadow" package is required for useradd, usermod, and groupmod

## Using /etc/entrypoint.d/

- Files named `*.env` will be sourced if readable and may contain environment
  variables
- Files named `*.sh` will be executed if executable
- Files will be processed in order

## Using /etc/healthcheck.d/

- This mirrors entrypoint.d functionality, first sourcing any `*.env` files,
  and then running all `*.sh` scripts. If any script fails, the healtcheck
  will fail.

## Environment variables

- `ORIG_ENTRYPOINT`: If set to a non-empty value, this is prepended to the
  command being run
- `USE_INIT`: If set to any non-empty value, tini will be used to run the
  command, providing repaing of zombie processes
- `RUN_AS`: If set to any non-empty value, gosu will be used to drop privledges
  from root to the requested user (see potential issues writing to /dev/stdout
  below)

## Converting Secrets to Environment Variables

Environment variables with the value `{DOCKER_SECRET:xyz}` will be replaced
with the contents of `/run/secrets/xyz`. This also works for a substring,
e.g. `USERPASS=root@{DOCKER_SECRET:root_login}` would lookup root_login
and replace it with something like `USERPASS=root@passw0rd`.

Note that environment variables are inherently less secure than the secret file
since they may be read by other processes with access to /proc, and often get
written to debugging logs. Be sure to understand the risks of using these
variables before adding them to your application architecture.

## Using scratch

The scratch image is designed to for extending other images, e.g.:

```
FROM your_base_image
COPY --from=sunnybear/base:scratch / /
```

If you extend an alpine image, the shadow package needs to be installed for
the fix-perms script. If you use volume caching with the `-d` option, rsync
needs to be installed.

## Volume Caching

Volume caching scripts are useful for the following scenarios:

- When docker does not initialize host volumes for you.
- When using a tmpfs volume and need the content to be initialized.
- When using a pre-initialized volume that needs to be updated on every startup
  with data from the image.

Caching is a two step process:

1. Calling `RUN save-volume /path/to/dir` in your Dockerfile for any directory
   to cache in the image. This directory will be moved into cache storage,
   so make it the last step on this directory that you run during your build.
2. Calling `load-volume /path/to/dir`, or use the `entrypointd.sh` which loads
   all volumes you have previously saved with the flags passed to `save-volume`.

The `save-volume` and `load-volume` scripts have the following options:

- `-d`: delete files from the mounted volume, this uses/depends on `rsync`.
- `-u`: update a volume even if it already exists. This overwrites any changes
  in the volume, but does not delete or modify files that were not previously
  cached.

The `load-volume` script will:

- Create a symlink if there is no volume mount to update.
- If the `-d` flag was used, run `rsync` to reset the volume to the cached
  state.
- If the volume mount is empty or `-u` was used, run a `cp -a` to initialize
  the volume.

Note: caching a volume with the above steps results in the directory being
moved which will double the size of the directory in the docker layers when
performed as a separate build step. When possible, merge the `save-volume`
step with any other commands used to create the volume folder. If copying
files between stages in a multi-stage build, include `/.volume-cache`.

## Stop On Trigger

The `stop-on-trigger` script can be used to stop a container on a condition.
This would be launched as a background process in an entrypoint script. When
the condition is met, all processes are sent a SIGTERM, followed by a delay,
and then a SIGKILL. However, pid 1 will not receive this signal inside of the
container so you need to use `tini` to run your app as a child pid. This is
done by setting `ENV USE_INIT=1` in the image when using entrypointd.sh. A
sample entrypointd script would look like:

```
#!/bin/sh
stop-on-trigger -m /etc/certs/host.pem &
```

Which would stop the container when the file is modified, and any container
restart policy would result in a new container running, using that new
certificate file.

## Certificates

Additional certificate authorities (CA) can be configured by adding the
certificate file to `/etc/certs.d/` as either a `*.pem` or `*.crt` file.
This requires the "ca-certificates" package to be installed in the image,
or at least the `/etc/ssl/certs/ca-certificates.crt` file to be installed.
The image must also be started by the root user.

## Examples

The nginx example shows:

- Extending the nginx image with the scratch base image
- Running the application as uid 5000 inside the container
- Volume caching to automatically populate host and tmpfs volumes
- Entrypoint to automatically fix the uid to match the developer volume mount
- Using curl for a healthcheck

## Errors Writing to /dev/stdout

There are scenarios where writing to /dev/stdout and /dev/stderr may fail with
permission problems when the container starts as root and changes to another
user. Should you encounter this, try to add the user to the tty group and
configure the container with a tty. See the following issue for more details:
https://github.com/moby/moby/issues/31243#issuecomment-406879017

repository: sun-bear/docker-base

repo_name: sun-bear/docker-base


text:
# kaligo-test
Kaligo Assignment

## The task
https://jsfiddle.net/caop7j5z/31/

1. Display this json response into a list of hotels, dipslay its name, rating, trustyou overall score (if the hotel has it)
2. Create a Filter select box to filter the hotel by:
     - rating
     - trustyou overall score
3. Create a text field to filter hotel by name
4. Create a select box to Sort by name / rating / imageCount

## Install

### npm

```shell
npm start
```

repository: naqiyahredzwan/kaligo-test

repo_name: naqiyahredzwan/kaligo-test


text:
# hast-util-to-text

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[hast][] utility to get the plain-text value of a node.

## Contents

*   [What is this?](#what-is-this)
*   [When should I use this?](#when-should-i-use-this)
*   [Install](#install)
*   [Use](#use)
*   [API](#api)
    *   [`toText(tree[, options])`](#totexttree-options)
    *   [`Options`](#options)
    *   [`Whitespace`](#whitespace)
*   [Types](#types)
*   [Compatibility](#compatibility)
*   [Security](#security)
*   [Related](#related)
*   [Contribute](#contribute)
*   [License](#license)

## What is this?

This package is a utility that takes a [hast][] node and gets its plain-text
value.
It is like the DOMs `Node#innerText`, which is a bit nicer than
`Node#textContent`, because this turns `<br>` elements into line breaks and
uses `'\t'` (tabs) between table cells.

There are some small deviations from the spec, because the DOM has knowledge of
associated CSS, and can take into account that elements have `display: none` or
`text-transform` association with them, and this utility can’t do that.

## When should I use this?

This is a small utility that is useful when you want a plain-text version of a
node that is close to how it’s “visible” to users.

This utility is similar to [`hast-util-to-string`][hast-util-to-string], which
is simpler, and more like the `Node#textContent` algorithm discussed above.

There is also a package [`hast-util-from-text`][hast-util-from-text], which sort
of does the inverse: it takes a string, sets that as text on the node, while
turning line endings into `<br>`s

## Install

This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:

```sh
npm install hast-util-to-text
```

In Deno with [`esm.sh`][esmsh]:

```js
import {toText} from 'https://esm.sh/hast-util-to-text@4'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
  import {toText} from 'https://esm.sh/hast-util-to-text@4?bundle'
</script>
```

## Use

```js
import {h} from 'hastscript'
import {toText} from 'hast-util-to-text'

const tree = h('div', [
  h('h1', {hidden: true}, 'Alpha.'),
  h('article', [
    h('p', ['Bravo', h('br'), 'charlie.']),
    h('p', 'Delta echo \t foxtrot.')
  ])
])

console.log(toText(tree))
```

Yields:

```txt
Bravo
charlie.

Delta echo foxtrot.
```

## API

This package exports the identifier [`toText`][api-to-text].
There is no default export.

### `toText(tree[, options])`

Get the plain-text value of a node.

###### Parameters

*   `tree` ([`Node`][node])
    — tree to turn into text
*   `options` ([`Options`][api-options], optional)
    — configuration

###### Returns

Serialized `tree` (`string`).

###### Algorithm

*   if `tree` is a [comment][], returns its `value`
*   if `tree` is a [text][], applies normal whitespace collapsing to its
    `value`, as defined by the [CSS Text][css] spec
*   if `tree` is a [root][] or [element][], applies an algorithm similar to the
    `innerText` getter as defined by [HTML][]

###### Notes

> 👉 **Note**: the algorithm acts as if `tree` is being rendered, and as if
> we’re a CSS-supporting user agent, with scripting enabled.

*   if `tree` is an element that is not displayed (such as a `head`), we’ll
    still use the `innerText` algorithm instead of switching to `textContent`
*   if descendants of `tree` are elements that are not displayed, they are
    ignored
*   CSS is not considered, except for the default user agent style sheet
*   a line feed is collapsed instead of ignored in cases where Fullwidth, Wide,
    or Halfwidth East Asian Width characters are used, the same goes for a case
    with Chinese, Japanese, or Yi writing systems
*   replaced elements (such as `audio`) are treated like non-replaced elements

### `Options`

Configuration (TypeScript type).

##### Fields

*   `whitespace` ([`Whitespace`][api-whitespace], default: `'normal'`)
    — default whitespace setting to use

### `Whitespace`

Valid and useful whitespace values (from [CSS][]) (TypeScript type).

##### Type

```ts
type Whitespace = 'normal' | 'nowrap' | 'pre' | 'pre-wrap'
```

## Types

This package is fully typed with [TypeScript][].
It exports the additional types [`Options`][api-options] and
[`Whitespace`][api-whitespace].

## Compatibility

Projects maintained by the unified collective are compatible with maintained
versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `hast-util-to-text@^4`,
compatible with Node.js 16.

## Security

`hast-util-to-text` does not change the syntax tree so there are no
openings for [cross-site scripting (XSS)][xss] attacks.

## Related

*   [`hast-util-to-string`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-to-string)
    — get the plain-text value (`textContent`)
*   [`hast-util-from-text`](https://github.com/syntax-tree/hast-util-from-text)
    — set the plain-text value (`innerText`)
*   [`hast-util-from-string`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-from-string)
    — set the plain-text value (`textContent`)

## Contribute

See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## License

[MIT][license] © [Titus Wormer][author]

<!-- Definitions -->

[build-badge]: https://github.com/syntax-tree/hast-util-to-text/workflows/main/badge.svg

[build]: https://github.com/syntax-tree/hast-util-to-text/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-text.svg

[coverage]: https://codecov.io/github/syntax-tree/hast-util-to-text

[downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-text.svg

[downloads]: https://www.npmjs.com/package/hast-util-to-text

[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-to-text

[size]: https://bundlejs.com/?q=hast-util-to-text

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[collective]: https://opencollective.com/unified

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[chat]: https://github.com/syntax-tree/unist/discussions

[npm]: https://docs.npmjs.com/cli/install

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[typescript]: https://www.typescriptlang.org

[license]: license

[author]: https://wooorm.com

[health]: https://github.com/syntax-tree/.github

[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md

[support]: https://github.com/syntax-tree/.github/blob/main/support.md

[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md

[html]: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute

[css]: https://drafts.csswg.org/css-text/#white-space-phase-1

[hast-util-to-string]: https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-to-string

[hast-util-from-text]: https://github.com/syntax-tree/hast-util-from-text

[hast]: https://github.com/syntax-tree/hast

[node]: https://github.com/syntax-tree/hast#nodes

[root]: https://github.com/syntax-tree/hast#root

[comment]: https://github.com/syntax-tree/hast#comment

[text]: https://github.com/syntax-tree/hast#text

[element]: https://github.com/syntax-tree/hast#element

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting

[api-to-text]: #totexttree-options

[api-options]: #options

[api-whitespace]: #whitespace

repository: syntax-tree/hast-util-to-text

repo_name: syntax-tree/hast-util-to-text


text:
# Proviso

Ruby gem to make requests to Bankstatements.com.au service. Website: [https://www.bankstatements.com.au/](https://www.bankstatements.com.au/)

## Installation

Add this line to your application's Gemfile:

    gem 'proviso'

And then execute:

    $ bundle

Then run install generator:

	rails g proviso:install

Then run migrations:

    rake db:migrate

## Usage

### Request

    request = Proviso::Query.create(...)

Attributes for access_hash:

    {
        :url => config["url"],
        :api_key => config["api_key"]
    }

#### Instance Methods: (Needs to be updated)

    request.access - Access Hash
    request.json - JSON body request

## Contributing

1. Fork it ( http://github.com/easylodge/proviso/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. See dev.rb file in root
4.  Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request

repository: easylodge/proviso

repo_name: easylodge/proviso


text:
# Dozer Autohide
Add autohide funtion to Dozer (by [Mortennn](https://github.com/Mortennn/Dozer)).

# How To
Use applescript to run dozer after starup and send key code to hide the menu items.

1. Download and install Dozer.

2. Open Scrpit Editor and add this into file:

```applescript
tell application "Dozer" to activate
tell application "System Events" to key code 43 using {control down}
```

You need to replace (43 using {control down}) with your shortcut, and should setup the same shortcut in Dozer in order to work.
[Complete list of AppleScript key codes](https://eastmanreference.com/complete-list-of-applescript-key-codes)

You may encounter a system warning says that "Script Editor is not allow to send key code", you need to go to `System Preference > Security & Privacy > Privacy tab > Accessibility` and check Script Editor.

3. Save as Application. You can put this file anywhere you like.

4. Got to `Dozer Autohide > right click > Show package content > Contents > Info.plist` , open the file and add:
```
	<key>LSUIElement</key>
	<true/>
```
This will hide the Dozer Autohide icon from the dock when launched

You may encounter a system warning says that "Dozer Autohide is not allow to send key code", you need to go to `System Preference > Security & Privacy > Privacy tab > Accessibility` and check Dozer Autohide.

5. Got to `System Preference > Users & Groups > Login items` and add the Dozer Autohide app file into list.

6. Done!


text:
---
layout: post
title: Using LSTM to Generate a Story
tags: [lstm]
---

之前简单介绍过 LSTM，[网址](https://hlthu.github.io/2017/05/30/understand-lstm.html)，本文将利用 LSTM 构建一个故事生成的模型。

# 数据及其预处理

## 数据源

我们使用的数据是 [Aesop’s Fables](http://www.taleswithmorals.com/) 里的一部分内容，如下：

> long ago , the mice had a general council to consider what measures they could take to outwit their common enemy , the cat . some said this , and some said that but at last a young mouse got up and said he had a proposal to make , which he thought would meet the case . you will all agree , said he , that our chief danger consists in the sly and treacherous manner in which the enemy approaches us . now , if we could receive some signal of her approach , we could easily escape from her . i venture , therefore , to propose that a small bell be procured , and attached by a ribbon round the neck of the cat . by this means we should always know when she was about , and could easily retire while she was in the neighbourhood . this proposal met with general applause , until an old mouse got up and said that is all very well , but who is to bell the cat ? the mice looked at one another and nobody spoke . then the old mouse said it is easy to propose impossible remedies .

## 数据读取

我们将改段文字保存在 `story.txt` 中，使用下面的代码读取，代码中有注释，不再解释。

```python
## 读取训练数据
fname = './story.txt'
with open(fname) as f:                                # 读取所有行
	words = f.readlines()
words = [x.strip() for x in words]                    # 删除前导和后缀字符
words = [words[i].split() for i in range(len(words))] # 将句子分割成词， 以空格、TAB、回车等为分隔符
words = np.array(words)                               # 转成向量表示
words = np.reshape(words, [-1, ])
```

## 建立词到数字的映射

```python
## 建立“词典”，实现词到数字的转换
def build_dict(words):
	cnt = collections.Counter(words).most_common() # 计算每个词出现的次数并排序
	dictionary = dict()
	for word, _ in cnt:
		dictionary[word] = len(dictionary)         # 字典的key是词，value是依次增加的序号。
	dictionary_reverse = dict(zip(dictionary.values(), dictionary.keys()))
	return dictionary, dictionary_reverse
## 构建训练数据的字典
dictionary, dictionary_reverse = build_dict(words)
num_words = len(dictionary)
```

# 神经网络定义

## 定义流图输入

```python
## Tensorflow日志与流图输入
log_dir = '/tmp/tf_log'
writer = tf.summary.FileWriter(log_dir)
x = tf.placeholder('float', [None, n_input, 1])
y = tf.placeholder('float', [None, num_words])

weights = {
    'out': tf.Variable(tf.random_normal([n_hidden, num_words]))
}
biases = {
    'out': tf.Variable(tf.random_normal([num_words]))
}
```

## 定义 RNN

```python
def RNN(x, weights, biases):
	x = tf.reshape(x, [-1, n_input])
	x = tf.split(x, n_input, 1)
	rnn_cell = rnn.MultiRNNCell([rnn.BasicLSTMCell(n_hidden),rnn.BasicLSTMCell(n_hidden)])
	outputs, states = rnn.static_rnn(rnn_cell, x, dtype=tf.float32)
	return tf.matmul(outputs[-1], weights['out']) + biases['out']
```

## RNN 前向计算和优化

```python
# RNN前向计算
pred = RNN(x, weights, biases)

# 定义loss(交叉熵)和优化器
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=pred, labels=y))
optimizer = tf.train.RMSPropOptimizer(learning_rate=lr).minimize(cost)

# 定义正确率
acc_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1))
acc_rate = tf.reduce_mean(tf.cast(acc_pred, tf.float32))

# 初始化变量
init = tf.global_variables_initializer()
```

# LSTM 训练与测试

```python
## LSTM训练的相关参数
lr = 0.001
train_iters = 50000
display_step = 1000
n_input = 3
n_hidden = 512
# 启动流图
with tf.Session() as session:
	session.run(init)
	# 定义初始的参数
	step = 0
	offset = random.randint(0, n_input+1)
	end_offset = n_input + 1
	acc_total = 0
	loss_total = 0
	writer.add_graph(session.graph)

	# 循环迭代
	while step < train_iters:
		if offset > (len(words) - end_offset):
			offset = random.randint(0, n_input+1)
		# 获取输入的三个单词对应的数字
		symbols_in_keys = [ [dictionary[str(words[i])]] for i in range(offset, offset+n_input) ]
		symbols_in_keys = np.reshape(np.array(symbols_in_keys), [-1, n_input, 1])
		# 获取输出对应的单词数字，同时将LSTM概率输出对应的位置置为1
		symbols_out_onehot = np.zeros([num_words], dtype=float)
		symbols_out_onehot[dictionary[str(words[offset+n_input])]] = 1.0
		symbols_out_onehot = np.reshape(symbols_out_onehot,[1,-1])
		# 神经网络前向计算与反向回传
		_ , acc, loss, onehot_pred = session.run([optimizer, acc_rate, cost, pred], feed_dict={x: symbols_in_keys, y: symbols_out_onehot})
		# loss 和 acc 累加
		loss_total += loss
		acc_total += acc
		# 每隔 display_step 打印一次 loss 和 acc
		if (step+1) % display_step == 0:
			print("Iter= " + str(step+1) + ", Average Loss= " + \
                  "{:.6f}".format(loss_total/display_step) + ", Average Accuracy= " + \
                  "{:.2f}%".format(100*acc_total/display_step))
			# 打印当前输入与预测输出，预测输出是概率最大的那一个
			symbols_in = [words[i] for i in range(offset, offset+n_input)]
			symbols_out = words[offset+n_input]
			symbols_out_pred = dictionary_reverse[int(tf.argmax(onehot_pred, 1).eval())]
			print("%s - [%s] vs [%s]" % (symbols_in,symbols_out,symbols_out_pred))
			# 将 loss 重新置为 0
			acc_total = 0
			loss_total = 0
		step += 1
		offset += (n_input+1)

	# 测试给定输入求出的32个输出
	while True:
		# 获取输入并处理，和之前读文件类似
		prompt = "%s words: " % n_input
		sentence = input(prompt)
		sentence = sentence.strip()
		sentence = sentence.split()
		sentence = np.array(sentence)
		sentence = np.reshape(sentence, [-1, ])
		if len(sentence) != n_input:
			continue
		try:
			symbols_in_keys = [dictionary[str(sentence[i])] for i in range(len(sentence))]
			for i in range(32):
				keys = np.reshape(np.array(symbols_in_keys), [-1, n_input, 1])
				# 进行一次前向计算，求出预测
				onehot_pred = session.run(pred, feed_dict={x: keys})
				onehot_pred_index = int(tf.argmax(onehot_pred, 1).eval())
				sentence = "%s %s" % (sentence,dictionary_reverse[onehot_pred_index])
				# 将预测结果加到末尾，重新循环预测
				symbols_in_keys = symbols_in_keys[1:]
				symbols_in_keys.append(onehot_pred_index)
			print(sentence)
		except:
			print("Word not in dictionary")
```

# 运行结果

![](https://raw.githubusercontent.com/hlthu/lstm/master/01-story_generation/1.PNG)

gha_language: HTML


text:
# atom-refactoring-tools package

Refactoring tools for [Atom](http://atom.io).

Eventually, this package will contain a complete suite of refactoring tools, although I'm also writing it simply to figure out how to write an Atom plugin.

## Currently implemented refactorings

| Refactoring      | CoffeeScript | JavaScript | Ruby | ... |
|:-----------------|:------------:|:----------:|:----:|:----|
| [Extract Method] |              |            |  ✓   |     |
| ...              |              |            |      |     |

[Extract Method]: http://refactoring.com/catalog/extractMethod.html

## To do

* [ ] Screenshot. Because it's an Atom package. :D
* [ ] Multiple language support
  * [ ] Deduce language from buffer
  * [ ] Allow other packages to provide refactorings for particular languages
* As many refactorings as possible
* Autodetection of duplication etc.?

 Just make sure they have sufficient tests.

repository: jankeconsulting/atom-refactoring-tools

repo_name: jankeconsulting/atom-refactoring-tools


text:
# Beacon

Beacon is a full text indexing and search tool for the Haiku OS. Beacon uses CLucene as it's IR back end.

To build Beacon from source, you must have the CLucene OptionalPackage installed. Currently, the OptionalPackage is available for the GCC4 build of Haiku.

repository: korli/Beacon

repo_name: korli/Beacon