text:
---
title: "React vs Vue: Which is growing faster?"
date: 2018-10-04
description: Which is better, React or Vue? We need to look at the numbers to see not what people think, but what people are doing. The metrics we'll be looking at are Hacker News popularity, NPM downloads, Github stars, Google Trends, and Reddit subscribers.
---

It's the age old -- or maybe year old -- question.

**Which is better, React or Vue?**

A large part of the Javascript community has become obsessed over this. Each person picks their side, and like sports fans we cheer on our team to "victory".

![](https://media.giphy.com/media/3oEjHY2dCdoXcTsHDi/giphy.gif?cid=3640f6095bae5a695331536759327b69)

Although it's good to discuss the differences between the frameworks, to compare the finer details of which is more performant, easier to pick up, or more productive (whatever that means), many of these comparisons are nothing more than speculation based on a few weeks of experience.

**We need cold, hard, data.**

We need to look at the numbers to see not what people think, but what people are doing.

But first I have something really awesome to share with you...

## Giving back to my 13,000+ monthly readers
Every day I'm astonished that so many of you are reading what I put on here. It's truly humbling, and you are the reason I am so motivated to keep writing.

So I wanted to thank you!

I have written a **144 page book** on solving some of the most common (and frustrating) problems that you'll encounter when writing Vue apps.

It covers everything from handling reactivity problems to understanding confusing errors.

Plus, you'll get to see how to implement some common behaviours (the right way), like changing classes dynamically.

The best part?

Even though I could charge money for this book, I'm giving it away to you for free!

  <form
    action="https://michaelnthiessen.us7.list-manage.com/subscribe/post?u=aac07b28d06210ba964471dcf&id=a98572f937"
    method="post"
    id="mc-embedded-subscribe-form"
    name="mc-embedded-subscribe-form"
    class="validate"
    target="_blank"
    noValidate
  >

        Email Address
        <input
          type="email"
          name="EMAIL"
          class="required email"
          id="mce-EMAIL"
        />

        <input type="text" name="b_aac07b28d06210ba964471dcf_a98572f937" tabIndex="-1" value=""/>

        <input type="submit" value="Download my FREE book now!" name="subscribe" id="mc-embedded-subscribe" class="button subscribe" />

  </form>

## The Data
I've looked at several different metrics here, but **take these numbers with a grain of salt**.

Each of these metrics has their flaws, some of them providing more of a signal than others. The hope is that in aggregate, these metrics will provide at least *some* insight, and that we may better **understand how React and Vue are growing in relation to one another**, and what exactly that might mean.

The metrics we'll be looking at are:
- Hacker News popularity
- NPM downloads
- Github stars
- Google Trends
- Reddit subscribers

## Hacker news trends
Hacker News may not be a representative sample of the broader software development community, but for our purposes it's a fairly good proxy.

It's very popular, and the articles posted there are fairly diverse in subject matter. It seems plausible that the popularity of any technology on HN would at least be indicative of it's true popularity.

![](./hn-trends.png)

Using [a chart from HN Trends](https://www.hntrends.com/2018/aug-summer-hiring-heats-up-react-fire.html?compare=React&compare=Vue) we can see that both React and Vue have been growing a lot in popularity over the last few years.

About the data:
- Starts in 2011, well before either framework was created
- Y axis shows the percentage of all articles that are on that topic

At first glance it appears that React is a rocket, with Vue steadily plodding along. However, although React is much more popular in absolute terms, Vue is the real rocket ship here.

### The Numbers
We'll compare an average of the months June, July, and August of 2017 with those same months in 2018 to get our growth rates. I'm taking this moving average to try and reduce some of the volatility in the numbers.

First, React:
```
React

June, July, August of 2017
(19.79 + 18.49 + 23.23) / 3 = 20.5%

2018
(28.02 + 27.74 + 26.94) / 3 = 27.57%
```

In 2017 **20.5%** of HN articles were about React, and in 2018 **27.57%** were. This gives us a growth rate of:
```
(27.57 - 20.5) / 20.5 = 0.345 = 34.5%
```

Or, **34.5% growth year over year**.

Now we'll look at Vue:
```
Vue

2017
(1.03 + 0.87 + 1.16) / 3 = 1.02%

2018
(3.14 + 3.23 + 3.71) / 3 = 3.36%
```

This gives us **1.02%** of articles in 2017 that were focused on Vue, and then up to **3.36%** in our 2018 sample. This gives us a growth rate of:
```
(3.36 - 1.02) / 1.02 = 2.294 = 229.4%
```

We get a **229% growth year over year for Vue**.

### Comparison
The numbers speak for themselves. In terms of HN posts, **Vue is growing at 229% versus React's 34.5%**.

This means that **Vue is growing 6.6 times faster than React** is -- at least on Hacker News.

But we have several other metrics to compare.

How does Vue stack up against React on something like package downloads?

## NPM downloads
![](npm-trends.png)

The [number of downloads](https://www.npmtrends.com/react-vs-vue) that each framework is getting is probably the most reliable indicator of usage.

The other indicators could simple express people's growing interest. But if you're downloading the package, you're likely using it as well.

Tracking downloads from NPM isn't perfect though.

You'll typically download a framework once, and it will be cached locally. Lots of companies will run their own NPM server and cache it there. And many times assets will be bundled up and stored in a Docker container (yet another type of caching).

However, it's pretty fair to assume that caching affects React and Vue equally, so comparing their downloads should be okay.

### The Numbers
We'll do a similar moving average to reduce volatility, but this time over a period of 3 weeks.

For 2017 we average downloads for the weeks of August 27, September 3, and September 10. For 2018 we use the weeks of August 26, September 2, and September 9.

React has a very impressive number of downloads per week:
```
React

2017 (Aug 27, Sept 3, Sept 10):
(1,157,501 + 1,156,048 + 1,206,494) / 3 = 1,173,348

2018 (Aug 26, Sept 2, Sept 9):
(2,762,018 + 2,217,924 + 2,730,522) / 3 = 2,570,155
```

From 1.2 million downloads per week to 2.6 million, that's a pretty significant growth rate:
```
(2,570,155 - 1,173,348) / 1,173,348 = 1.19
```

React's downloads have grown **119%** in the last year!

But let's take a look at what Vue has done in that same time frame:
```
Vue

2017:
(163,034 + 155,984 + 164,172) / 3 = 161,063

2018:
(490,816 + 403,662 + 503,945) / 3 = 466,141
```

Where React has grown 119% in downloads per week, **Vue has grown 189%!**

This means that Vue has grown **59% faster** than React in terms of downloads.

But wait a second.

Vue's growth in Hacker News posts versus React was 564%, but here it is only 59%. That's almost a 10x difference!

I wonder which is closest in terms of the true trend?

### The mysterious June 3rd
![](npm-june-3rd.png)

Also, did anyone else notice this huge dip on June 3rd?

I have zero ideas what happened here, and researching it turned nothing up. Perhaps NPM was down briefly?

If anyone knows what caused this, I'd love to know!

## Github Stars
![](github-stars.png)

If you've been following Vue or React for any amount of time, I'm sure you've seen this one.

Earlier this summer Vue surpassed React in number of [stars on Github](http://www.timqian.com/star-history/#facebook/react&vuejs/vue), and [Dan Abramov captured](https://twitter.com/dan_abramov/status/1007439168400654336) this "historic" moment on Twitter.

![](https://media.giphy.com/media/xT0xehQFGlcqlKOKcM/giphy.gif)

But we all know that Github stars don't really matter -- right?

Well, they do matter.

 Instead they look for social proof in the form of Github stars, and simply choose the library that has the most.

If we're honest with ourselves, we know that we often take this approach. Sometimes when we know we shouldn't.

To be fair, humans use social proof all of the time because otherwise we would never be able to make all of the decisions we need to. In many cases simply choosing the most popular is a valid strategy.

Because of this, having a lot of Github stars provides a very strong signal that the library is considered by the community to be valuable and useful. This is the entire reason Github has this feature in place.

For those interested, there is some [interesting discussion](https://opensource.stackexchange.com/questions/5110/github-stars-is-a-very-useful-metric-but-for-what) on Stack Overflow about how useful this metric is for research.

### The Numbers
I got my trend data [here](http://www.timqian.com/star-history/#facebook/react&vuejs/vue), but the tooltips were really finnicky so I couldn't get data on the exact dates I wanted 🤷♂.

For the last metrics I was tracking year over year growth, but I could only grab data 2 years apart. So here I will calculate growth over the last 2 years, and from that get the average year over year growth. It will be slightly less than the actual growth over the last year, but it should still be fine for comparing relative growth between Vue and React.

Again, we start with data for React:
```
React

September 29, 2016: 39,960
September 10, 2018: 111,004
```

Calculating growth over the last 2 years of:
```
(111,004 - 39,960) / 39,960 = 1.78
```

React's Github stars have grown **178** over the last two years, which gives us roughly **89% growth over the last year**.

As you can tell from the graph, Vue is growing pretty quick too:
```
Vue

September 29, 2016: 26,610
September 10, 2018: 113,625
```

To get our growth rate:
```
(113,625 - 26,610) / 26,610 = 3.27
```

So we get a growth rate of 327% or **163.5% per year**.

Vue is gaining Github stars **92.4% faster than React**!

Yet another solid win for Vue.

But how long can this streak continue?

## Google trends
![](google-trends.png)

Not very long, it turns out.

The number of searches people do on Google every day is staggering, and provides us with a lot of really good data into what people are interested in.

[Google Trends](https://trends.google.com/trends/explore?geo=US&q=reactjs,vuejs) unfortunately gives us nothing very interesting at all. This graph is completely sideways and doesn't really tell us anything.

The terms I used for this were `reactjs` and `vuejs`, which don't exactly capture all of the search terms that are related to either of these frameworks.

However, Google does understand that React is a Javascript framework, which would make this data a lot better.

![](google-trends-react.png)

But it doesn't understand Vue as a Javascript framework, so it wouldn't be a valid comparison.

![](google-trends-vue.png)

Perhaps once Vue becomes more popular Google will have enough data to recognize it as a Javascript framework, and we'll be able to make this comparison a lot better.

## Reddit subscribers
![](./reddit-subscribers.png)

The last metric -- however loose you define that word -- is growth in Reddit subscribers.

Each subreddit is it's own community, so I'm not sure how much value knowing the number of subscribers gets us. What's really important here is what goes on in each subreddit.

A healthy community will have more discussion, with less spammy links being posted. People will share ideas and great articles, and it will be a great place to go to learn new things.

Taking a cursory look at [/r/vuejs](https://www.reddit.com/r/vuejs) and [/r/reactjs/](https://www.reddit.com/r/reactjs/), it seems like the React community on Reddit is much healthier.

But what do the numbers say?

### The Numbers
We'll use [reddit metrics](http://redditmetrics.com/r/vuejs#compare=reactjs) to get our data. For some reason it doesn't provide data for Vue beyond January 2018, so we'll have to compare year over year growth between January 2017 and January 2018.

As always, React will go first:
```
React

2017: 18,203
2018: 36,779

Growth: (36,779 - 18,203) / 18,203 = 1.02
```

The growth of /r/reactjs has been **102%** through 2017.

Now looking at Vue:
```
Vue

2017: 2,489
2018: 8,845

Growth: (8,845 - 2,489) / 2,489 = 2.55
```

We get a growth rate of **255%** for /r/vuejs.

From this we can see that /r/vuejs is gaining reddit subscribers 150% faster than /r/reactjs.

Now, what do all of these numbers mean?

## Why such growth and other interesting things

Most of these metrics, when taken in isolation, don't seem to be that great. But in aggregate they form a much sturdier foundation.

It's pretty clear from all of this that Vue is growing at a much faster pace than React is. Whether it's closer to 50% or 500% is harder to tell. That said, I'd be extremely surprised if it was growing more than 2x as fast, so **I would wager somewhere between 10% - 100%** if I had to make a very wild but somewhat educated guess.

I could speculate about why this is:
* Vue is less popular so fast growth is easier
* React is getting closer to saturating the frontend framework market
* China favours Vue over React, and are starting to build more web apps
* Vue is objectively 5x better than React don't @ me

**But does it really matter?**

## It's not a contest

As a community we need to stop caring about which framework "wins". It's a childish game and no one is better off for it (but everyone wins in a dog surfing contest).

![](https://media.giphy.com/media/qAbtO6dgm5bi0/giphy.gif)

Competing ideas are great, because it accelerates innovation and brings us better tools to do our jobs.

But at the end of the day, you need to choose the tool that does the job the best.

If React is better for your team or your product, use React. If Vue is the better choice, use Vue. They're so similar that in the end it doesn't matter so much which one you end up using.

Pick one, and learn it well. Then stop arguing about which is better on Twitter and spend more time learning it even better.

Then you can do your actual job better, and you can make better things, and more of them. This is what truly matters here.

The main takeaway for me is that *both* React and Vue are growing extremely fast, and that could mean many things for us as web developers:
* We're probably on the right track with this idea of components and stuff
* Web apps are in high demand and people are finding more and more use for them
* Developers (you and me), as the people who build these apps, are also increasingly in demand
* Technological adoption can happen at a staggering rate!

So please, stop bickering and write some code.


text:
:checkered_flag: picoCTF{A}

## Solve
If I told you your grade was 0x41 in hexadecimal, what would it be in ASCII?

## Solution
```
root@kali:~/Downloads# python3
Python 3.6.7 (default, Oct 21 2018, 08:08:16)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> chr(0x41)
'A'
```

license: MIT

repository: shoulderhu/wordpress

branch_name: refs/heads/master

extension: md

filename: General Warmup 1.md

license_type: permissive

repo_name: shoulderhu/wordpress


text:
# Circle animation pure css
 _A Pen created at CodePen.io. Original URL: [https://codepen.io/savant/pen/idbAh](https://codepen.io/savant/pen/idbAh).

 With Javascript the percentage can be set. In this case every percent is 3,6deg and 5,556ms. By Increasing the ms for the whole animation the number can be rounded. The circle will work without Javascript, but then a percentage has to be set.

extension: markdown


text:
# jesusprubio npm package

[![Build Status](https://travis-ci.org/jesusprubio/jesusprubio-npm.svg?branch=master)](https://travis-ci.org/jesusprubio/jesusprubio-npm)
[![stability-experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](https://github.com/emersion/stability-badges#experimental)

:joy_cat: My personal CLI (and library). Please, do not try to run or require it :bomb:.

		 :gift: Ping me on Twitter if you like this project

repository: jesusprubio/jesusprubio-npm

repo_name: jesusprubio/jesusprubio-npm


text:
## Data Lake

In this module, you'll create an [Amazon Kinesis Data Firehose][firehose] to
deliver data from the Amazon Kinesis stream created in the first module to
[Amazon Simple Storage Service (Amazon S3)][s3] in batches. You'll then use
[Amazon Athena][athena] to run queries against our raw data in place.

### Overview

The architecture for this module builds on the Amazon Kinesis stream you
created in the first module. You'll use Amazon Kinesis Data Firehose to batch
the data and deliver it to Amazon S3 to archive it. Using Amazon Athena, you'll
run ad-hoc queries against the raw data in the Amazon S3 bucket.

### Implementation

#### 1. Create an Amazon S3 bucket

Use the console or CLI to create an S3 bucket. Keep in mind, your bucket's name
must be globally unique. We recommend using a name such as
`wildrydes-data-yourname`.

**:white_check_mark: Step-by-step Instructions**

1. From the AWS Console click **Services** then select **S3** under Storage.

1. Click **+ Create bucket**

1. Provide a globally unique name for your bucket such as
   `wildrydes-data-yourname`.

1. Select the region you've been using for your bucket.

    ![](images/data-lake-create-bucket.png)

1. Click **Next** twice, and then click **Create bucket**.

#### 2. Create an Amazon Kinesis Data Firehose delivery stream

Create an Amazon Kinesis Data Firehose delivery stream named **wildrydes** that is
configured to source data from the **wildrydes** stream and deliver its contents
in batches to the S3 bucket created in the previous section.

**:white_check_mark: Step-by-step Instructions**

1. From the AWS Console click **Services** then select **Kinesis** under
   Analytics.

1. Click **Create delivery stream**.

1. Enter `wildrydes` into **Delivery stream name**.

1. Select **Kinesis stream** as **Source** and select **wildrydes** as the
   source stream.

1. Click **Next**.

1. Leave **Record transformation** and **Record format conversation** disabled
   and click **Next**.

1. Select **Amazon S3** from **Destination**.

1. Choose the bucket you created in the previous section (i.e.
   **wildrydes-data-johndoe**) from **S3 bucket**.

1. Click **Next**.

1. Enter `60` into **Buffer interval** under **S3 Buffer** to set the frequency
   of S3 deliveries to once per minute.

1. Scroll down to the bottom of the page and click **Create new or Choose**
   from **IAM role**. In the new tab, click **Allow**.

1. Click **Next**. Review the delivery stream details and click **Create
   delivery stream**.

    ![](images/data-lake-delivery-stream-details.png)

#### 3. Create an Amazon Athena table

Create an Amazon Athena table to query the raw data in place on Amazon S3 using
a JSON SerDe. Name the table **wildrydes** and include the attributes in the raw
data:

- _Name_ (string)
- _StatusTime_ (timestamp)
- _Latitude_ (float)
- _Longitude_ (float)
- _Distance_ (float)
- _MagicPoints_ (int)
- _HealthPoints_ (int)

**:white_check_mark: Step-by-step Instructions**

1. Click on **Services** then select **Athena** in the Analytics section.

1. If prompted, click **Get Started** and exit the first-run tutorial by hitting
   the **x** in the upper right hand corner of the modal dialog.

1. Copy and paste the following SQL statement to create the table. Replace the
   **YOUR_BUCKET_NAME_HERE** placeholder with your bucket name (e.g.
   wildrydes-data-johndoe) in the LOCATION clause:

    ```sql
    CREATE EXTERNAL TABLE IF NOT EXISTS wildrydes (
           Name string,
           StatusTime timestamp,
           Latitude float,
           Longitude float,
           Distance float,
           HealthPoints int,
           MagicPoints int
         )
         ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
         LOCATION 's3://YOUR_BUCKET_NAME_HERE/';
    ```
<button class="btn btn-outline-primary copy">Copy to Clipboard</button>

1. Click **Run Query**.

1. Verify the table **wildrydes** was created by ensuring it has been added to
   the list of tables in the left navigation.

#### 4. Explore the batched data files

Using the AWS Management Console, navigate to the S3 bucket that you used as
your Kinesis Data Firehose delivery target. Verify that Firehose is delivering
batched data files to the bucket. Download one of the files and open it in a
text editor to see the contents.

**:white_check_mark: Step-by-step Instructions**

1. Click on **Services** then select **S3** in the Storage section.

1. Enter the bucket name you create in the first section in the **Search for
   buckets** text input.

1. Click on the bucket name and navigate through the year, month, day, and hour
   folders to ensure that files are being populated in your bucket.

    ![](images/data-lake-object-list.png)

1. Click on one of the files and click **Download**. Open the file with a text
   editor and explore its contents.

#### 5. Query the data files

Query the Amazon Athena table to see all records that have been delivered via
Kinesis Data Firehose to S3.

**:white_check_mark: Step-by-step Instructions**

1. Click on **Services** then select **Athena** in the Analytics section.

1. Copy and paste the following SQL query:

    ```sql
    SELECT * FROM wildrydes
    ```
<button class="btn btn-outline-primary copy">Copy to Clipboard</button>

1. Click **Run Query**.

    ![](images/data-lake-query-results.png)

[firehose]: https://aws.amazon.com/kinesis/firehose/
[s3]: https://aws.amazon.com/s3
[athena]: https://aws.amazon.com/athena
[client-installation]: ../README.md#kinesis-command-line-clients
[shard-iterator-type-documentation]: http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html#Streams-GetShardIterator-request-ShardIteratorType

## :star: Recap

:key: Amazon Kinesis Data Firehose is a fully managed service for delivering
real-time streaming data to destinations such as Amazon S3. Amazon Athena allows
us to run ad-hoc queries against the raw data using standard SQL.

:wrench: In this module, you've created a Kinesis Data Firehose deliery stream
to deliver data from the Kinesis stream to an Amazon S3 bucket. Using Athena,
you ran queries against this data on S3.

## Next

:tada: You're finished! You've completed the workshop. **Thanks so much
for participating!** Please remember to give us feedback either in person, via
GitHub, or through the survey mailed after an event so we can improve the
materials.

:white_check_mark: Have some time? Take a whack at some [extra
credit][extra-credit] tasks.

:white_check_mark: Be sure to [clean up][cleanup] the resources from this
workshop to ensure you do not incur any additional costs.

[extra-credit]: extra-credit.html
[cleanup]: cleanup.html

repository: MechanicalRock/aws-serverless-workshops

gha_language: JavaScript

repo_name: MechanicalRock/aws-serverless-workshops


text:
# Nyssopsora clavellosa f. clavellosa (Berk.) Arthur, 1912 FORM

#### Status
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
N. Amer. Fl. (New York) 7: 180 (1912)

#### Original name
Triphragmium clavellosum Berk., 1857

### Remarks
null

repository: mdoering/backbone

path: /life/Fungi/Basidiomycota/Pucciniomycetes/Pucciniales/Raveneliaceae/Nyssopsora/Nyssopsora clavellosa/ Syn. Nyssopsora clavellosa clavellosa/README.md

repo_name: mdoering/backbone


text:
#PasswordVerifier

##Create a Password verifications class called “PasswordVerifier”.

1. Add the following verifications to a master function called “Verify()”

   1. - password should be larger than 8 chars
   2. - password should not be null
   3. - password should have one uppercase letter at least
   4. - password should have one lowercase letter at least
   5. - password should have one number at least

 ## Each one of these should throw an exception with a different message of your choosing

2. Add feature: Password is OK if at least three of the previous conditions is true
3. Add feature: password is never OK if item 1.4 is not true.
4. Assume Each verification takes 1 second to complete. How would you solve  items 2 and 3  so tests can run faster?

branch_name: refs/heads/main


text:
+++
date = "2017-04-03T10:41:36+01:00"
title = "About"
type = "page"
layout = "about"
menu = "main"
weight = 10
+++

Speckle started  out as research in **digital design collaboration**. What become evident was that there was no truly open digital infrastructure for design data sharing that people could actually use, or build on top of without getting locked in proprietary solutions. Therefore, this is what we've set up to build, from the internet up: a truly open, vendor-neutral platform that connects Architecture, Engineering and Construction.

    Speckle is open digital infrastructure for collaboratively designing, making and operating the built environment.

    &nbsp

It's an ambitious goal. The Speckle Ecosystem is developed in the open by like minded people, on [github](https://github.com/speckleworks). We are a welcoming community and do our best to help others join the effort. So far, all the code is released under the MIT License.

    Get in touch:  <a<EMAIL_ADDRESS>/  slack /  twitter

## Core Features

Fast Speckle tries very hard to be as fast as your internet connection. You do not upload files: design data - whatever objects you might have - get uploaded only if they were modified.

Responsive & Real Time Furthermore, speckle offers a customizable layer of real-time communications between clients.  This is used to propagate events in real time to everyone listening in. Let others now data has been updated, or even automate your whole design process.

Schema agnostic Speckle provides a low level object model and then gets out of the way. You can compose whatever object models you want, and we even support out of the box .NET defined object models.

Extensible and open The Speckle Specs (pun intended) are written in an OpenApi v2 doc. This allows you to profit from all the tooling around this industry standard, from scaffolding a new server implementation to base client generation.

## Frequently Asked Questions

#### Q: What's the difference with Flux/etc?

A: Flux is dead; Konstru is a proprietary centralized service. Speckle's as open source as they get, meaning no lock-in & no data centralisation and no standards monopoly: you own everything. This was a core design principle from the start that informed everything from how easy it is to deploy your own server to how you can extend speckle's schemas and create new types of clients.

#### Q: What will stop Speckle from dying off too, just like Flux?

A: Speckle is a community driven effort, built around the open source philosophy by which we believe in creating greater value globally at the expense of quick term gains. In short, you will.

#### Q: Why are you giving all this away for free?

A: Because software is a zero-cost machine and, to begin with, Speckle was a research project in design communication, enabled by EU public funding. It's not just a technical research problem, it's also a political and social experiment to see whether an open source effort can exist in AEC.

#### Q: How can I contribute?

A: This is actually not a frequently asked question. But since you're here, you can join us [on slack](https://slacker.speckle.works) and check out the [git repos and their issues](https://github.com/speckleworks).

#### Q: Can Speckle do *< insert request here >* ?
A: Usually yes. See above question how to get it done. Currently the API is scaffolded for:

- versioning & history
- project management
- reporting (querying)
- data visualisation

If you want to develop a plugin yourself, the [OpenApi v2 specification document is here](https://speckleworks.github.io/SpeckleSpecs/). We have a [.NET SDK](https://github.com/speckleworks/SpeckleCore) as well as examples of [frontend](https://github.com/speckleworks/SpeckleViewer) [plugins](https://github.com/speckleworks/SpeckleAdmin) that consume the API.

#### Q: I've got another question...
A: Ask on our [forum](https://discourse.speckle.works) or join the [slack channel](https://slacker.speckle.works).

**InnoChain Project partners:**
HENN, McNeel Europe, The Bartlett UCL, InnoChain & You

repository: speckleworks/speckleworks-website

gha_language: CSS

repo_name: speckleworks/speckleworks-website


text:
# Synthetic Data Approach for Gathering Requirements

The following items describe the steps needed to gather the Synthetic Data requirements for DataHub and DataHelix.

1. Synthetic Data Requirements Obtained and Available in DataHub GitHub

2. Understand user stories of the clients who need a synthetic data solution or have a synthetic data problem.

3. Establish where the documentation should live and the relationship between projects

4. Contact FINOS project teams and understand their Synthetic Data requirements. The first project being [Morphir](https://github.com/finos/morphir) and then [Alloy](https://github.com/finos/alloy).

5. Direct / Influence DataHub and DataHelix roadmap based on input from the team.

### Diagram Outlining Synthetic Data Team Approach

The following diagram was presented to the FINOS community on 10th September 2020 and outlines the approach taken above.

<img src="images/synthetic-data-requirements-gathering.png" width="650" />

repository: mcleo-d/datahub

repo_name: mcleo-d/datahub


text:
# CHANGELOG

The changelog for `Pai`. Also see the [releases](https://github.com/lkmfz/Pai/releases) on GitHub.

--------------------------------------

## Upcoming Releases

### [Pre-release 0.1.0](https://github.com/lkmfz/Ubud/releases/tag/0.1.0)

repository: mohsinalimat/Pai

repo_name: mohsinalimat/Pai


text:
Symmetric Encryption Sample
===========================

This web page with associated JavaScript allows a user to:

* Specify a 128 bit AES key, or generate a random one
* Encrypt local files with that key, and save the encrypted version
* Decrypt previously encrypted files with the same key, and save the decrypted version

This [example](https://infotechinc.github.io/symmetric-encryption-in-browser/) is provided to illustrate how to use the W3C
[Web Cryptography API](http://www.w3.org/TR/WebCryptoAPI/ "API Draft")
to perform symmetric encryption inside a web browser. It is based
on the [working draft](http://www.w3.org/TR/2014/WD-WebCryptoAPI-20140325/ "Dated Working Draft")
of the standard available when this example was created.

Using this example requires a web browser that implements a compatible version
of the Web Cryptography API. When the example was created, current versions of
the Google Chrome browser with the optional "Enable Experimental Web Platform
features" flag enabled and recent nightly builds of the Firefox browser could
run the example.

This example uses AES in CBC mode with 128 bit keys and the 16 byte random initialization
vector placed at the beginning of the encrypted file. Modifying it
to use different size keys or different AES modes would be simple for a developer.
**This is not intended to be a production tool.** Rather, it may
be helpful to developers who intend to create their own tools using
the Web Cryptography API.

Copyright (c) 2014 Info Tech, Inc.
Provided under the MIT license.
See LICENSE file for details.


text:
# didmap-client-back

Unofficial Python API client for https://mapasinteractivos.didactalia.net

The *Swagger* documentation of the API can be access in the following link: https://didmap-api.herokuapp.com/docs

## Intallation

In the root directory type the following command:
```
$ python -m setup.py install
```

Start a virtual environment (as it is explain in the [Hitchhiker's Guide to Python](https://docs.python-guide.org/dev/virtualenvs/))
```
$ pip install virtualenv
$ cd project_folder
$ virtualenv venv
$ source venv/Scripts/activate
```

Then, install the dependencies
```
& pip install -r requirements.txt
```

Use the following command to stop the virtual environment:
```
$ deactivate
```

## Local developement

You can start the *uvicorn* server with the following command:
```
$ start-dev
```

Runs the app in the development mode. Open http://localhost:8000 to view it in the browser.

repository: jblanper/didmap-client-back

repo_name: jblanper/didmap-client-back


text:
# elm-architecture-explain

In this README, ELM architecture is reviewed in the developer's way and explain the event flow sequence so that we can quickly align the business logic to the ELM event flow and architecture.

I try to compare with React.js in case of need so that the concept is explained more clearly if you are familiar with React.js framework.

## Overview

**ELM** is another web development framework like Facebook React and Google Angular but it is functional language like Haskell and super simple and pragmatic to the developers.

**ELM** is the result of the thesis of the genious young havard student **Evan Czaplicki**, which was published on 03/30/2012.

**ELM** offers you the best developer experience to enjoy concurrent FRP (Functional React Programming). If you like Mobx.js, you will love ELM.

**ELM** offers the developers the concurrent functional reactive programming (**FRP**) experience in the succinct and pragmatic way. The data immutability and virtual DOM strategy and two-tier codes optimiation make the compiled JS file super tiny in **size** and super speedy in **performance**.

## Arhcitecture

### ELM code compilation Dialgram

![Compiling Diagram](asset/compiler.png)

**ELM** language is very expressive. When compiling to Javascript, it take two steps.

First, it transforms ELM source codes into an intermediate codes. the purpose is to optimize the source codes and prepare the "Cleanup" codes for next layer compilation.

Second, it leverage HTML5 and web javascript available capability to further optimize and transform the intermediate codes into javascript.

For the detail, please reference to the Evan Czaplicki's thesis (2012) "Concurrent FRP"

![Runtime Diagram](asset/runtime.png)

**ELM** is a declarative programming language for Web UI development. **ELM** power web developers to describe UI layout, What interaction, **ELM** runtime does the heavy lifting to figure out how to render UI and carry out the UI interaction.

**ELM** is an **opinioned** web framework, which requires to have the following functions defined at the bootstrap elm file (e.x. Main.elm)

* main
* init
* update
* subscriptions
* view

#### main

This is bootstrap function, where you instruct ELM runtime to do the following:

* when initializing, call my init function
* when new events are dispatched, call my update function
* when your update or init has side effect, the runtime need to notify you by call your subscriptions.
* after updates and side effects are completed, the ELM runtime calls your view to get your view definiton (**what**) and render your layout defintion to the web browser.

If you want ELM runtime to render view inside that element. You need pass on that element node instance into init().

```elm
  main =
  Browser.element
    { init = init
    , view = view
    , update = update
    , subscriptions = subscriptions
    }
```

if you develop Single Page Application (SPA), you want the ELM runtime to render the whole page. Mightbe the page title and body are different for each page. In this case, you need to use Browser.application function.

```elm
main =
    Browser.application
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        , onUrlChange = OnWebUrlChange
        , onUrlRequest = OnWebUrlRequest
        }
```

In the following section "SPA", when and how to use Broswer.element and Browser.application are explained.

Here, **OnWebUrlChange** and **OnWebUrlRequest** are ELM message definition (they are function too).

For ELM web application, you want express the browser event in the human-readable way as shown blown:

```elm
type Msg
  = TransferMoney Int
  |  SaveProfile
```

* SaveProfile is a function () -> Msg
* TransferMoney is a function (Int) -> Msg

Let's say you have a button call "Save Profile" as shown here

```elm
view model =
  div [] [
    button [onClick SaveProfile] [text "Save Profile"]
  ]
```
when the users click this button, the ELM runtime will translate the button click event to SaveProfile message and call your update() function and pass in this message and your application **state**

#### init
You need to initialize your application **state** (In React, you will initialize root store during the bootstrap phase).

You might also call the backend API to preload data. (you might call this API in react component constructor).

The function always returns a tuple of (AppState, Cmd Msg). In ELM, we use **Model** as Application State, we define Custom Type **Msg** as Messges that we ask **ELM** runtime to do.

##### Browser.element
```elm
init: flags -> (Model, Cmd Msg)
```

#### Browser.application
```elm
init: url key -> (Model, Cmd Msg)
```

#### update
ELM calls update() when the runtime dispatches event messages. Here is update contract:

```elm
update: msg model -> (Model, Cmd Msg)
```

Inside your init() and update(), you can create/update Model Instance and define a batch of command messages and return it.

The pseudocodes are shown below:
```elm
update msg model =
  let
    updateModel
      = { model
        | someState1 = Loading
        , someState2 = Init }
  in
    (updatedModel, Cmd.batch( task1, task2, task3, ...))
```

**note** in subscriptions() definition, you can also instruct the ELM runtime to dispatch the messages to your update() when your interested things happen.

#### subscriptions
In this function, you tell ELM runtime what side effect and interest that your app want to know when certain things happen. In other words, any events that
are generates outside your program can be subscribed in this function, such as
window resize event.

For example, you can use elm/time package every() function to tell ELM runtime to call your update() every second with the predefined message TimeUp.

```elm
type Msg
  = TimeUp

subscriptions =
  Time.every 1000 TimeUp
```
Note that you can batch multiple subscriptions.

```elm
type Msg
  = TimeUp
  | TimeDown

subscriptions =
  Sub.batch
    ( Time.every 1000 TimeUp
    , Time.every 6000 TimeDown)

```

#### view
ELM calls view() after update() and subscriptions() are called.

```elm

view: Model -> Html msg | Document msg

```
for Brower.element, the view() needs return Html msg. for Browser.application and Browser.document, the view() needs return Document msg.

In view(), you design UX layout and declare user interactions through ELM HTML elements like (div, span, etc.)

## SPA

In ELM, there is not any router-specific package like **react-router**. Browser package exposes 3 functions that allow you to update browser without reloading.

* Browser.element
* Browser.document
* Browser.application

Browser.element and Browser.document does not provide browser navigation hook so that you can bind to them and take action based on the navigation event.

You can craft navigation logic with them or crack the source codes to see how it is implemented. Nothing is wrong with it but not recommended.

Browser.application exposes two browser history navigation related event to the developer.

* **onUrlRequest**: UrlRequest -> msg
* **onUrlChange**: Url -> msg

When a hyperlink ```<a href="/somepath">somepath</a>``` is clicked, ELM runtime will raise onUrlRequest event, Your hooked implementation is called with the pass-in parameter UrlRequest, like preRoute event.

You do whatever you want to do, like saving current page screen scroll position, calling web service API, validate current form, etc.

And then you need to call  Browser.Navigation pushUrl to add the url entry in browser.history object. It dispatches **onUrlChange** event message to the update().

Inside update(), you pattern-match your **onUrlChange** message to implement your next application logic based on the pass-in Url.

>It is nice to have router package implemented to add an abstract layer so that the developers are not directly calling this lower-level API for routing purpose.

## Some considations

### OOD vs Functional Design

From the **React.js** world, it is very easy to draw the boundary around UI layout. In addition, the highly encapsulated component model can store its' own **state**. The developers are happy with this simplicity but that might cause component out of sync or bug-prone.

The developers have to tackle the following issues:

* state out of sync.
* data mutability issue.
* component life of cycle related issue.
* javascript "this" reference issue.
* code base sizing and code splitting.
* concern too much at all level.

To solve aboved metioned issues, the developers has to turn 3rd party's libraries, such as

* Redux or MobX State Tree or Mobx
* React-Router
* React-Thunk or React-Saga (backend API integraiton)
* React-Immutable
* React-ReSelect to handle data set rendering
* Others,

The moment when you add up all those 3rd party's library, your codebase might hit 1.5MB very easily.

From the **ELM** world, the developer do not have these concerns due to the facts:

* One truth of source, the application state (**Model**) at the main entry level
* the state is immutable by nature
* time travelling is by default
* concern less. Only need to know **WHAT**
* code base super tiny. code split not needed although you can do it.

But we still have some concerns when using ELM:

* it is a learning curve. anything is function. it is not easy to simulate the real-world knowledge, in which OOD is better.

* It is message-driven centric.  In some way, the similarity is very high between ELM and Erlang/Elxir

* The popularity is not on top rank although the principle and concept of ELM are very superb, Alibaba **dva.js**, **Redux** and some others borrow most idea of it.

* The ELM 3rd party's libraris are not huge comparing with React.js, Angular, Vue.js. Thanks ELM core team to do the heavy lifting, we still can use the 3rd party JS libraries through ELM port. That is against of the ELM goal as declarative language.

## Tips and understanding

### Single custom type optimization

For the single custom type variant, the compiler will optimize it by trimming out the custom type name for example:

```elm
  type User =
    User {
      id : Int,
      name : String
    }
```
The compiler will compile it to {id : Int, name : String} without User

repository: zyzbroker/elm-revisit

repo_name: zyzbroker/elm-revisit


text:
# Example: Teams Hierarchy

We describe below how to load a structure from a JSON file. Let
consider the following UML class diagram that describe a hierarchy of
teams made of either persons or other teams.

![alt text](./_images/team_class_diagram.png)

## Type-checking

This says nothing on how the data could/should be serialized. We could
for instance, choose to use a YAML file as follows:

```yaml
team:
  name: My Team
  members:
   - given: John
     family: Doe
   - given: James
     family: Bond
   - name: Backup
     members:
      - given: Robert
        family: Roe
```

Using quick-check, we can define the schema that governs such data and
use it to parse, convert and finally obtain a team object, instance of
our own homw-grown classes.

```typescript
const schema = new Grammar();
schema.define("person")
    .as(anObject()
        .with(aProperty("given")
              .ofType("string")
              .withDefault("Unknown"))
        .with(aProperty("familyname").ofType("string")));

schema.define("team")
    .as(anObject()
        .with(aProperty("name").ofType("string"))
        .with(aProperty("members")
              .ofType(anArrayOf(eitherOf("person", "team")))));
```

We can now type check some YAML data, which we read from a file:

```typescript {highlight: \[5]}
const fieContent = fs.readFileSync('./data.yaml', 'utf8');
const data = yaml.safeLoad(fileContents);

try {
    const team = schema.read(data).as("team");

} catch (errors) {
    console.log(errors)

}
```

## Converting objects to home-grown Classes

We can see that the JSON schema underlying our data differs from the
UML class diagram shown previously. Persons' firstname and lastname
are serialized using 'given' and 'family' respectively.

Quick-check let us define convertion rules in order to automatically
convert the object it founds to some specific classes. To do so, we
extend our schema as follows:

```typescript
schema.on("person").apply((data) => {
   return new Person(data.given,
                     data.family)
});

schema.on("team").apply((data) => {
   return new Team(data.name,
                   data.members)
});
```

Now parsing the data will return an a Team object.

We assume that we have encoded these two classes in Typescript as
shown below. We can hook any kind of business logic on our home-grown
classes, for instance, we could define that the `name` of a person is
its lastname concatenated to its lastname.

```typescript
abstract class Partner {
    public abstract get name(): string;
}

class Person extends Partner {
    private _firstname: string;
    private _lastname: string;

    constructor (firstname: string, lastname: string) {
        super();
        this._firstname = firstname;
        this._lastname: lastname;
    }

    public get name(): string {
        return `${this._lastname}, ${this._firstname}`;
    }
}

class Team extends Partner {
    private _name: string;
    private _members: Partner[];

    constructor(name: string, members: Partner[]) {
        super();
        this._name = name;
        this._members = members;
    }

    public get name(): string { return this._name }
}
```

repository: fchauvel/quick-check

gha_language: TypeScript

gha_license_id: MIT

repo_name: fchauvel/quick-check


text:
A few examples showcasing how to use xebra.js

These examples require the [Max app](https://cycling74.com/downloads/) and use the [prebuilt distribution of xebra.js](https://cycling74.s3.amazonaws.com/download/xebra.js)


text:
# 1 AMeFu-Net
Repository for the paper :

**Depth Guided Adaptive Meta-Fusion Network for Few-shot Video Recognition**

[[paper](https://arxiv.org/abs/2010.09982)]

[[News! presentation video uploaded in 2021/10/06 in Bilibili.](https://www.bilibili.com/video/BV1i44y1t78U?spm_id_from=333.999.0.0)]

[[News! presentation video uploaded in 2021/10/10 in Youtube.](https://www.youtube.com/watch?v=KqNYuZD5xdw)]

![](https://upload-images.jianshu.io/upload_images/9933353-a0414d86bce9bee5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

If you have any questions, feel free to contact me. My email is<EMAIL_ADDRESS>
# 2 setup and datasets
A new virtual environment is suggested.

Before running our code, you are suggested to set up the virtual environment of Monodepth2. We use the Monodepth2 model to extract our depth frames in our paper.

## 2.1 setup monodepth2
Following [the monodepth2 repo](https://github.com/nianticlabs/monodepth2) to finish the **Setup** and **Prediction for a single image** steps.

## 2.2 preparing the datasets
Totally three datasets are used in our experiments, including Kinetics, UCF101, and HMDB51.

We suppose that you have downloaded the datasets by yourself.  Sorry for that we could not provide the original video datasets.

There are mainly three steps to processing our dataset.  We also provide the scripts for your convenience.

1. extracting the video frames.
`sources/video_jpg.py`
2. calculate the number of frames per video.
`sources/n_frames.py`
3. extracting the depth frames for each video.
`sources/generate_depth.py`

Take the Kinetics dataset as an example, our final datasets are organized as follows:

```
miniKinetics_frames
├── class1
│   ├── video1
│   │   ├── image_00001.jpg
│   │   ├── image_00002.jpg
│   │   ├── ...
│   │   ├── monodepth
│   │   │   ├── image_00001_disp.jpeg
│   │   │   └── image_00002_disp.jpeg
│   │   │   └── ...
│   │   └── n_frames
│   └── video2
│       ├── image_00001.jpg
│       ├── image_00002.jpg
│       ├── ...
│       ├── monodepth
│       │   ├── image_00001_disp.jpeg
│       │   └── image_00002_disp.jpeg
│       │   └── ...
│       └── n_frames
└── class2
└── ...
```

# 3 network testing

We provide the pretrained checkpoints for submodels and full models.

**full model:**
- model_full_ucf.pkl: https://drive.google.com/file/d/1NaIOcGJCHp9Mf5mWjnMwQfZVvZfz1TNq/view?usp=sharing
- model_full_hmdb.pkl: https://drive.google.com/file/d/1qivNcrgnLiaJNyEzv_Ywp-M8oDYBvHlt/view?usp=sharing
- model_full_kinetics.pkl: https://drive.google.com/file/d/1PH96YY64v82-4vWNPwZFYUwMNi9BvJRA/view?usp=sharing

**submodels:**
- ucf_depth_submodel.pkl: https://drive.google.com/file/d/19tyUWm2jQvrh8nnvfVa6S8hyNa0X_g-Y/view?usp=sharing
- ucf_rgb_submodel.pkl: https://drive.google.com/file/d/1zxGJ6vUGqyDkucsWtDjXS1w93VI9h60o/view?usp=sharing
- hmdb_depth_submodel.pkl：  https://drive.google.com/file/d/1neXreD2TdGMdJjbgxSzjlQnvgikbfdKy/view?usp=sharing
- hmdb_rgb_submodel.pkl:  https://drive.google.com/file/d/1-yVLNZmR9BXNxD7CgQEGQEI5zEO011mh/view?usp=sharing
- kinetics_depth_submodel.pkl: https://drive.google.com/file/d/1-gcMQR6qDIwDSWUem0LTj3a5VUgbeljE/view?usp=sharing
- kinetics_rgb_submodel.pkl: https://drive.google.com/file/d/12yTuCx-lw63YO8acQ1yLNqD5a5NMmyLt/view?usp=sharing

usage for Kinetics dataset:
```
CUDA_VISIBLE_DEVICES=0 python network_test.py --dataset kinetics --ckp ./result/model_full_kinetics.pkl --k_shot 1
```

usage for UCF101  dataset:
```
CUDA_VISIBLE_DEVICES=0 python network_test.py --dataset ucf --ckp ./result/model_full_ucf.pkl --k_shot 1
```

usage for HMDB51 dataset:
```
CUDA_VISIBLE_DEVICES=0 python network_test.py --dataset hmdb --ckp ./result/model_full_hmdb.pkl --k_shot 1
```

Due to the randomness of the few-shot learning,  the result may vary.

# 4 network training
Take Kinetics as an example:

If ''out of the memory" occurred, then two cards are required.

```
CUDA_VISIBLE_DEVICES=0,1 python network_train_meta_learning.py --dataset kinetics --exp_name test --pre_model_rgb ./result/kinetics_rgb_submodel.pkl --pre_model_depth ./result/kinetics_depth_submodel.pkl
```

You can use the submodel provided by us.

If you want to train the submodels by yourself,  we refer you to our previous work [emboded few-shot learning](https://github.com/lovelyqian/Embodied-One-Shot-Video-Recognition).

# 5 Citing

Please cite our paper if you find this code useful for your research.

```
@inproceedings{fu2020depth,
  title={Depth Guided Adaptive Meta-Fusion Network for Few-shot Video Recognition},
  author={Fu, Yuqian and Zhang, Li and Wang, Junke and Fu, Yanwei and Jiang, Yu-Gang},
  booktitle={Proceedings of the 28th ACM International Conference on Multimedia},
  pages={1142--1151},
  year={2020}
}
```


text:
# reading-notes

My name is **Wissam Talal AbuAresh** ,I graduate CS computer science from mutah university and i wish to be agood web developer in this course

## table of content 301 code

| Contents    | Link        |   About   |
| :---        |    :----:   |          ---: |
| read301-01    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-1) | Introduction to React and Components |
| read301-02    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-2) | State and Props |
| read301-03     | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-3) | Passing Functions as Props |
| read301-04     | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-4) | React and Forms |
| read301-05    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-5) | Putting it all together |
| read301-06    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-6) | NODE.JS |
| read301-07    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-7) | REST |
| read301-08    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-8) | APIs |
| read301-09    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-9) | FUNCTIONAL PROGRAMMING |
| read301-10    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-10) |  In memory storage |
| read301-11    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-11) | Mongo and Mongoose |
| read301-12    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-12) | CRUD |
| read301-13    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-13) | Diversity & Inclusion in the Tech Industry |
| read301-14    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-14) | Authentication |
| read301-15    | [Click Here](https://wissamtalal9.github.io/reading301-note/read301-15) | Project Kickoff |


text:
---
layout: page
title: Species-wide and genome-wide variant discovery, genome assembly, and annotation
permalink: Research/Projects/Variation/
menu: research
category: research
image: variant-calling.png
order: 2
---

Because of the efforts of a number of highly dedicated scientists and citizen volunteers, we have amassed a large collection of more than 500 *C. elegans* strains from throughout the world. These strains represent nearly all known isolation locations where we have found this species. Our goals are to use this large strain collection to identify functional variation for a large number of traits and to understand more about the population genetic forces shaping the genome.

To this end, we deep sequenced all of these strains using the Illumina HiSeq platform (minimum 50x depth of coverage). This large sequence data set allows us to not only identify single nucleotide variants but to dig deeper into other classes of genetic variation, including insertion/deletions, transposon insertions, genomic rearrangements, microsatellite repeats, and copy number variants. We hope that these additional classes of variation will contribute to our understanding of how genetic variation contributes to phenotypic variation and genome evolution.


text:
# tonkotsukatsubot
Reddit Bot that corrects submitters and commenters on /r/ramen that they had tonkOtsu broth rather than tonkAtsu

## Dependencies:

* Python 3.6 (probably? because this is my first ever python script, I'm not sure yet)
* Reddit API: [praw](https://praw.readthedocs.io/en/latest/)
* Reddit App (just follow the instructions in the praw quickstart guide)

## Then what

Then just run the script, and watch the "Good bot!s" karma roll in.

repository: nikp/tonkotsukatsubot

repo_name: nikp/tonkotsukatsubot


text:
watchevent
----------

`watchevent` watches filesystem, and if the files are changed,
sleep specified interval and invoke specified shell command.

## Options

```
Usage:
   watchevent [OPTIONS]
Options
  -c string
        config file
  -config string
        config file
  -d value
        directory to be watched
  -directory value
        directory to be watched
  -version
        show version
```

## Example

Create a config file:

```yaml
action:
  - name: write-logs
    on: [all]
    run: echo $(date) $WEV_EVENT $WEV_PATH >>log.txt

# zap logger's config (see zap document)
# https://github.com/uber-go/zap
log:
  level: "info"
  encoding: "console"
  #encoding: "json"
  encoderConfig:
    messageKey: "msg"
    levelKey: "level"
    timeKey: "time"
    nameKey: "name"
    callerKey: "caller"
    stacktraceKey: "stacktrace"
    levelEncoder: "capital"
    timeEncoder: "iso8601"
    durationEncoder: "string"
    callerEncoder: "short"
  outputPaths:
    - "stdout"
  errorOutputPaths:
    - "stderr"
```

Invoke `watchevent` command:

```
$ make
$ mkdir dir  # target directory
$ bin/watchevent -c config.yml -d dir/
```

And in another terminal:

```
$ touch dir/foo
```

It lets `watchevent` output logs like:

```
2017-08-27T21:38:10.785+0900    INFO    watchevent/watchevent.go:140      (1) Created file: dir/foo
2017-08-27T21:38:10.785+0900    INFO    watchevent/task.go:163  (1/1) Executing echo $(date) $WEV_EVENT $WEV_PATH >>log.txt ...
2017-08-27T21:38:10.785+0900    INFO    watchevent/watchevent.go:160      (2) File changed permission: dir/foo
2017-08-27T21:38:10.786+0900    INFO    watchevent/task.go:163  (2/1) Executing echo $(date) $WEV_EVENT $WEV_PATH >>log.txt ...
```

and `log.txt` content is:

```
Sun Aug 27 21:43:01 DST 2017 CREATE dir/foo
Sun Aug 27 21:43:01 DST 2017 CHMOD dir/foo
```

repository: tyru/go-watchevent

repo_name: tyru/go-watchevent


text:
# polysplit

## Synopsis

The purpose of this project is to split a given [JTS](http://www.vividsolutions.com/jts/JTSHome.htm) polygon into any number of equal areas, while ensuring minimum length of line based cuts. The solution is based on [this algorithm by Sumit Khetarpal](http://www.khetarpal.org/polygon-splitting/). It works for both convex and concave polygons, as long as they don't have any intersecting edges and are defined by a single exterior ring.

## Code Example
```
    Polygon polygon = (Polygon) new WKTReader().read("POLYGON ((0 0, 100 0, 90 50, 10 50, 0 0))");
    List<Polygon> parts = new GreedyPolygonSplitter().split(polygon, 2);
```

## Known issues

**Caution: carefuly test the code before considering it production-ready!**

A list of known issues can be found under the issues tab.

## Build

The project is built using Maven.

Currently requires JDK 8.

## Tests

Unit tests are present for most methods.

Test cases covering real-world or randomly generated scenarios could be added.

## Contributors

Developed by: Gediminas Rimša

Sponsored by: Incentergy GmbH

**Contributions are welcome!**

## Licence

Licensed under the [MIT license](https://github.com/grimsa/polysplit/blob/master/LICENSE).

repository: dtrungtin/polysplit

repo_name: dtrungtin/polysplit


text:
# FilledSpriteShader

[日本語版README](https://github.com/Kilimanjaro-a2/FilledSpriteShader/blob/master/README.ja.md)

## Description

This is a shader that allows Sprite to do the same as Image.FillMethod.Radial360 in Unity.

![AnimationGif](https://user-images.githubusercontent.com/30808673/69492684-fe4ecc80-0ee8-11ea-8b7a-68ce8664b3c9.gif)

https://docs.unity3d.com/ja/2018.4/ScriptReference/UI.Image.FillMethod.Radial360.html

## Demo
This is a demo built with WebGL.

https://kilimanjaro-a2.github.io/FilledSpriteShader/

## Usage
Save the following file as **FilledSprite360.shader** in your project.

[FilledSpriteRadial360.shader](https://github.com/Kilimanjaro-a2/FilledSpriteShader/blob/master/Assets/FilledSpriteRadial360.shader)

Then attach any material to the sprite and change the shader to **Unlit/FilledSprite360**.

```C#
Material mat = mySpriteGameObject.GetComponent<SpriteRenderer>().material;

/*
  By assigning a value to _FillAmount,
  you can change the size of the sprite display area.
  The value can be assigned a range from 0 to 1,
  and the value is mapped from 0 to 360 degrees.
  For example, if it is 0.75, the sprite display area will be 0 to 270 degrees.
*/
mat.SetFloat("_FillAmount", 0.75);

/*
  By assigning a value to _Clockwise,
  You can set whether the direction of increasing the sprite display area is clockwise.
  The value can only be set to 0 or 1.
  If it is 1, it will be clockwise.
*/
mat.SetFloat("_Clockwise", 0);

/*
  By assigning values to _FillOriginX and _FillOriginY,
  you can determine the direction from which the sprite display area starts.
  Each value ranges from -1 to 1.
  For example, if _FillOriginX is 1 and _FillOriginY is 0,
  the direction from which the display area starts is from the center of the right edge.
*/
mat.SetFloat("_FillOriginX", 1);
mat.SetFloat("_FillOriginY", 0);
```

Refer to **Assets/Plugin/FilledSprite/Samples** for detailed usage.


text:
# Running Virtual HelpDesk in a Container on IBM Cloud with Kubernetes

This instruction helps you to deploy the `Virtual HelpDesk` application into a container running on IBM Cloud, using Kubernetes.

The commands below use environment variables in order to define the specific details of the deployment. Substitute your names in the commands:
```
$ export CLUSTER_NAME=lzcluster
$ export CONFIG_MAP=virtualhelpdeskmap
$ export POD_NAME=virtualhelpdesk.yml
$ export KUBE_SERVICE=vhelpdeskservice
$ export CONVERSATION_SERVICE=Assistant-ICD
$ export CONTAINER_CONVERSATION_VARIABLE=conversationvariable
$ export DISCOVERY_SERVICE=Discovery-ICD
$ export CONTAINER_DISCOVERY_VARIABLE=conversationvariable
```

# Steps

## Login

Open a command window and navigate to the root folder of the code pattern project. You take all steps in this folder.

* Login to IBM Cloud if necessary.

```
$ ibmcloud login
```

* Set org and/or space in IBM Cloud if necessary,

```
$ ibmcloud target --cf
```

* Log in to the IBM Cloud Container Registry CLI. Note: Ensure that the [container-registry plug-in](https://console.bluemix.net/docs/services/Registry/index.html#registry_cli_install) is installed.

```
$ ibmcloud cr login
```

## Creating the Kubernetes cluster

You need the Kubernetes cluster to deploy your docker images

* Follow the instructions to [Create a Kubernetes Cluster](https://github.com/IBM/container-journey-template). If you already have a cluster, or choose a cluster name other than the one exported as $CLUSTER_NAME, re-export this new name:

```
$ export CLUSTER_NAME=<your_cluster_name>
```

* Before you continue to the next step, verify that the deployment of your worker node is complete.

```
ibmcloud ks workers $CLUSTER_NAME
```

> When your worker node is finished provisioning, the status changes to Ready, and you can start binding IBM Cloud services.

* Set the Kubernetes environment variable KUBECONFIG to work with your cluster:

```
ibmcloud cs cluster-config $CLUSTER_NAME
```

* The output of this command will contain a KUBECONFIG environment variable that must be exported in order to set the context. `Copy and paste the output in the terminal window to set the KUBECONFIG environment variable`. An example is:

```
export KUBECONFIG=/home/rak/.bluemix/plugins/container-service/clusters/Kate/kube-config-prod-dal10-<cluster_name>.yml
```

## Setting up your private registry

Set up your own private image repository in IBM Cloud Container Registry to securely store and share Docker images with all cluster users. A private image repository in IBM Cloud is identified by a namespace. The namespace is used to create a unique URL to your image repository that developers can use to access private Docker images.

```
$ ibmcloud cr namespace-add <namespace>
```

`<namespace>` can be any unqie name.

## Binding the Watson Asistant Service to your cluster

After binding the Watson Asistant Service to your cluster, the crediential of the Watson Asistant Service becomes available to the Kubernetes cluster. A Kubernetes secret is created.

* Retrieve available service instance:

```
$ ibmcloud service list
```

* Obtain the ID of your cluster:

```
$ ibmcloud cs clusters
```

* Bind the service instance to your cluster:

```
$ ibmcloud cs cluster-service-bind <cluster-ID> default $CONVERSATION_SERVICE
```

## Binding the Watson Discovery Service to your cluster

After binding the Watson Discovery Service to your cluster, the crediential of the Watson Discovery Service becomes available to the Kubernetes cluster. A Kubernetes secret is created.

* Retrieve available service instance:

```
$ ibmcloud service list
```

* Obtain the ID of your cluster:

```
$ ibmcloud cs clusters
```

* Bind the service instance to your cluster:

```
$ ibmcloud cs cluster-service-bind <cluster-ID> default $DISCOVERY_SERVICE
```

## File .env

File .env in the root folder of the code pattern project should have been updated for your environment at this point. If you skipped file .env configuration, please revisit the instructon in the main [README](../../README.md) file.

## Creating a Kubernetes Configuration Map

Through Kubernetes Configuration Map, you can make additional environment variables available in the Kubernetes cluster. Entries in file .env becomes environment variables in the Kubernetes cluster after this section.

* Create a Kubernetes Configuration Map:

```
$ kubectl create configmap $CONFIG_MAP --from-env-file=.env
```

* Verify that the configuration is set:

```
$ kubectl get configmaps $CONFIG_MAP -o yaml
```

## Creating Docker image

* Build, tag, and push the app as an image to your namespace in IBM Cloud Container Registry. Don't forget the period (.) at the end of the command.

>Build a Docker image that includes app files in the root directory, and push the image to your IBM Cloud Container Registry namespace. Any time when you need to make a change to the app, repeat the steps to create another version of the image.

>Use lowercase alphanumeric characters or underscores (_) only in the image name. Don't forget the period (.) at the end of the command. The period tells Docker to look inside the current directory for the Dockerfile and build artifacts to build the image.

```
ibmcloud cr build -t registry.<region>.bluemix.net/<namespace>/virtualhelpdesk:1 .
```
>For example,

```
ibmcloud cr build -t registry.ng.bluemix.net/zhangllc/virtualhelpdesk:1 .
```

* Verify docker image

```
ibmcloud cr images
```

* If you need to delete docker image
```
ibmcloud cr image-rm registry.ng.bluemix.net/zhangllc/hello-world:5
```

## Modifying Kubernetes Pod Configuration File virtualhelpdesk.yml

* If you changed the following environment variable setting at the beginning, you should review and modify the Kubernetes pod configuration file accordingly. By default, it's in file virtualhelpdesk.yml.

```
$ export CONFIG_MAP=virtualhelpdeskmap
$ export POD_NAME=virtualhelpdesk.yml
$ export CONVERSATION_SERVICE=Assistant-ICD
$ export CONTAINER_CONVERSATION_VARIABLE=conversationvariable
$ export DISCOVERY_SERVICE=Discovery-ICD
$ export CONTAINER_DISCOVERY_VARIABLE=conversationvariable
```

* Below are the entries in the Kubernetes pod configuration file that you should review and modify.

```
        env:
          - name: WORKSPACE_ID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: WORKSPACE_ID
          - name: ENVIRONMENT_ID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: ENVIRONMENT_ID
          - name: COLLECTION_ID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: COLLECTION_ID
          - name: DISCOVERY_URL
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: DISCOVERY_URL
          - name: MAXIMO_AUTH
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_AUTH
          - name: MAXIMO_CONTEXT_TYPE
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_CONTEXT_TYPE
          - name: MAXIMO_REST_URL
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_REST_URL
          - name: MAXIMO_PERSONID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_PERSONID
          - name: MAXIMO_CLASSSTRUCTUREID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_CLASSSTRUCTUREID
          - name: MAXIMO_PREFIX
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_PREFIX
          - name: MAXIMO_UI_URL
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: MAXIMO_UI_URL
          - name: conversationvariable
            valueFrom:
              secretKeyRef:
                name: binding-assistant-icd
                key: binding
          - name: discoveryvariable
            valueFrom:
              secretKeyRef:
                name: binding-discovery-icd
                key: binding
```

## Deploying the Kubernetes Pod

* Deploy container:

```
$ kubectl create -f $POD_NAME
```

* Verify the deployment and service in Kubernetes dashboard

> 1. In IBM Cloud web UI, navigate to Containers and then Clusters.
> 1. Click your cluster entry.
> 1. Click the Kubernetes Dashboard at the top-right corner.
> 1. Navigate to the Overview tab.
> 1. Review Deployments, Services, Config Maps and Secrets sections.
> 1. In the Deployments section, select your deployment entry.
> 1. In the New Replica Set section, you may click the `Logs` icon to view the log files. This can be very handy if you encountered issues.

* Identify the **Public IP** address of your worker:

```
$ ibmcloud cs workers $CLUSTER_NAME
```

* Identify the external port your pod is listening on:

> Note: The Dockerfile determines the port that the container listens on using the `EXPOSE <port>` command. Kubernetes maps this to a publicly addressable port:

```
$ kubectl get services $KUBE_SERVICE
```
> Port 32032 is the external port in the sample output below,

```
NAME               TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
vhelpdeskservice   NodePort   <IP_ADDRESS>   <none>        3000:32032/TCP   1h
```

* Access the application using `http://<public IP Address>:<Port>`

## Looking Under the Hood

Now that you have created and bound a service instance to your Kubernetes cluster, let's take a deeper look at what is happening behind the scenes.

* Binding the conversation service to your cluster creates a Kubernetes secret named `binding-${CONVERSATION_SERVICE}` .

* The secret contains a key named binding with its data being a JSON string of the form:

```json
{
 "url":"https://gateway.watsonplatform.net/conversation/api",
 "username":"service-instance-user-uuid",
 "password":"service-instance-password"
}
```

* The secret is mapped into the container as an environment variable through the Kubernetes pod configuration(in file virtualhelpdesk.yml):

```yaml
          - name: $CONTAINER_CONVERSATION_VARIABLE
            valueFrom:
              secretKeyRef:
                name: binding-${CONVERSATION_SERVICE}
                key: binding
```

* For an application that expects the service credentials to be set in the environment variables `CONVERSATION_USERNAME` and `CONVERSATION_PASSWORD`, we set these in the container environment.

* Example usage is to have a script that is run when the container is started. We can then parse them from the  environment variable `$CONTAINER_CONVERSATION_VARIABLE` using jq:

```bash
$ export CONVERSATION_USERNAME=$(echo "${CONVERSATION_ENV_VARIABLE}" |
                                  jq -r '.username')
```

* Kubernetes Configuration Map $CONFIG_MAP makes all key/value pairs in .env file avilable in the container environment.

* The Kubernetes Configuration Map is mapped into the container as environment variables through the Kubernetes pod configuration(in file virtualhelpdesk.yml):

```
        env:
          - name: WORKSPACE_ID
            valueFrom:
              configMapKeyRef:
                name: virtualhelpdeskmap
                key: WORKSPACE_ID
```

You can see the defined secrets in the Kubernetes dashboard by running ``kubctl proxy`` and accessing [http://<IP_ADDRESS>:8001/ui](http://<IP_ADDRESS>:8001/ui).

## Troubleshooting

If a pod doesn't start examine the logs:

```bash
$ kubectl get pods
$ kubectl logs <pod name>
```

## Cleanup

To delete all your services and deployments, run:

```bash
$ kubectl delete deployment $KUBE_SERVICE
$ kubectl delete service $KUBE_SERVICE
```

## Acknowledgement

The instructions in this document were created mainly based on the information in the following resources.

* [Running watson-conversation-slots-intro in a Container on IBM Cloud with Kubernetes](https://github.com/IBM/watson-conversation-slots-intro/blob/master/doc/source/Container.md)

* [Tutorial: Creating Kubernetes clusters](https://console.bluemix.net/docs/containers/cs_tutorials.html#cs_cluster_tutorial)


text:
---
date: "2018-02-01T09:00:00Z"
description: Show how you can use meta package to manage multiple arch linux systems
slug: archlinux-meta-packages
tags:
  - linux
  - automation
  - archlinux
sidebar:
  - [
      "/blog/archlinux-repo-in-aws-bucket/",
      "Hosting an Arch Linux Repository in an Amazon S3 Bucket",
    ]
  - ["/blog/archlinux-meta-packages/", "Managing Arch Linux with Meta Packages"]
  - ["/blog/archlinux-installer/", "Creating a Custom Arch Linux Installer"]
---

# Automating Arch Linux Part 2: Managing Arch Linux with Meta Packages

In this three-part series, I will show you one way to simplify and manage
multiple Arch Linux systems using a custom repository, a set of meta-packages and a
scripted installer. Each part is standalone and can be used by its self, but
they are designed to build upon and complement each other each focusing on a
different part of the problem.

- **Part 1:** [Hosting an Arch Linux Repository in an Amazon S3 Bucket]
- **Part 2:** _Managing Arch Linux with Meta Packages_
- **Part 3:** [Creating a Custom Arch Linux Installer]

[hosting an arch linux repo in an amazon s3 bucket]: /blog/archlinux-repo-in-aws-bucket/
[creating a custom arch linux installer]: /blog/archlinux-installer/

I really enjoy Arch Linux for its customisation - you can truly make it _your_
own. But while crafting your system exactly how you want it once can be a fun
and rewarding experience, repeating this process on multiple computers becomes
tedious. Worst, it easily leads to inconsistencies between each system as
you forget things that you configured or as you slowly evolve your configs on
each system you set up.

There are a fair few applications that aim to make this easier, most notably
the plethora of _[dotfile managers]_ out there. I have used a few of these over
the years and they all suffer from the same problem; they are only designed to
manage user files. I want to manage my whole system. I used [SaltStack] for [a
while][salt-arch] but started to dislike it when it became hard to debug
problems (salts error handling is quite bad) and I kept forgetting to run
`salt-call state.apply` to resync my systems.

My ultimate goal is to find a way to automatically install Arch Linux on a
system with minimal input (only things like host name, username, password etc).
As well as for a way to automatically update all of my systems whenever I
change a config or add/remove a package. Ideally just running `pacman -Syu` on
a system to sync all the configs from a master set. In this post, I will show
you how I solved this second goal using the repository I set up in my [last
post] with a set of custom [meta-packages].

[dotfile managers]: https://wiki.archlinux.org/index.php/Dotfiles
[saltstack]: https://saltstack.com/
[salt-arch]: https://github.com/mdaffin/salt-arch
[last post]: /blog/archlinux-repo-in-aws-bucket/
[meta-packages]: https://wiki.archlinux.org/index.php/creating_packages

## What are Meta-Packages

Simply put, meta-packages are packages that do nothing but depend on other
packages. The result of this is that you can install a group of packages at
once by installing a single meta-packages. Now, Arch Linux has a similar
concept; package groups, and while they serve a similar purpose they are
suitably different. This difference is when you add or remove dependencies -
groups will not install/remove additional dependencies whereas meta packages
will, this is exactly what we want. When a dependency is added all our systems
to automatically install it when they update.

Now, we are going to abuse this concept slightly and not only use them to
install groups of packages via dependencies but also to install related system
configuration. This is not something `pacman` is really designed to do and
results in some hacky workaround which we will discuss below. In practice this
works really well.

## Organising Our Meta-Packages

You can create as many or as few meta-packages as you require. The more you
have, the more there is to maintain. The less you have the less flexible they
become. How many you require depends on your needs but I recommend starting
with few large packages that do the bulk of the work that is common to all or
most of your systems. Then create smaller more specific ones, that depends on
these more general ones.

For example, I have [`mdaffin-base`] that contains everything that I require on
all of my systems. Then [`mdaffin-desktop`] for any system that needs a desktop
interface, such as my desktops and laptops. I still only have one package to
install as this package depends on [`mdaffin-base`]. But then I have a
[`mdaffin-dell-xps-13`] which contains specific settings only useful on my
laptop. This, in turn, depends on [`mdaffin-desktop`].

Separate to this I have [`mdaffin-devel`] package that contains a whole bunch
of development tools and languages that I commonly use and want on any system
that I do development on. Changing a system to a development system becomes as
simple as `pacman -S mdaffin-devel`.

In the future, I might have a `mdaffin-laptop` or `mdaffin-server` as or when I
decide I will require them but for now, these systems will be based off one of
the existing packages.

One major advantage of using meta-packages like this is it is simple to
see how your system is configured with simple `pacman` commands, for example,
to see packages that were explicitly installed run the following.

```bash
% pacman -Qe
hugo 0.34-1
krita 3.3.3-1
mdaffin-dell-xps-13 0.0.2-1
mdaffin-devel 0.0.3-1
powertop 2.9-1
s3fs-fuse 1.80-2
```

Or to see all of our meta-packages are install run the following.

```bash
% pacman -Qqs mdaffin-
mdaffin-base
mdaffin-dell-xps-13
mdaffin-desktop
mdaffin-devel
```

This is a hidden and quite powerful feature of this method. Whereas on most
Arch Linux systems you might see hundreds of packages explicitly installed with
no way to track why you installed them, we only have a handful. This is
actually useful as it lets you track bloat on your systems over time where
you can either promote them to one of your meta-packages if you use them a lot
or remove them from your systems if you don't. You also have the option of
commenting the dependencies in your meta-packages to remind you why you added
them.

[`mdaffin-base`]: https://github.com/mdaffin/arch-pkgs/tree/5ce54e82b1d763c18493fda3d9bb78bd8a5b9786/pkg/base
[`mdaffin-desktop`]: https://github.com/mdaffin/arch-pkgs/tree/5ce54e82b1d763c18493fda3d9bb78bd8a5b9786/pkg/desktop
[`mdaffin-dell-xps-13`]: https://github.com/mdaffin/arch-pkgs/tree/5ce54e82b1d763c18493fda3d9bb78bd8a5b9786/pkg/dell-xps-13
[`mdaffin-devel`]: https://github.com/mdaffin/arch-pkgs/tree/5ce54e82b1d763c18493fda3d9bb78bd8a5b9786/pkg/devel

## Creating a Meta-Package

All you require to build a meta-package is a `PKGBUILD` file along with any
configs you want. You can read more about the finer details about [creating a
package] and the [PKGBUILD] file structure, both of which are worth a read or
at least to look up as a reference.

So, the first part of creating meta-packages is specifying dependencies. For
this we need a minimal `PKGBUILD` file, all you need to do is fill in the
details with your own and flesh out the dependency list.

```bash
# Maintainer: Michael Daffin<EMAIL_ADDRESS>pkgname=mdaffin-base
pkgver=0.0.1
pkgrel=1
pkgdesc="Base system configuration for mdaffin systems"
arch=('any')
url="https://github.com/mdaffin/arch-pkgs"
license=('MIT')
depends=(
    # package list
)
```

[creating a package]: https://wiki.archlinux.org/index.php/creating_packages#Meta_packages_and_groups
[pkgbuild]: https://wiki.archlinux.org/index.php/PKGBUILD

### Adding Dependencies

List the packages you want to be installed with this package in the `depends`
block, as quoted strings separated by white space (such as a newline). A good
set of packages to start with is the `base` group. But there is a problem - you
cannot specify groups of packages as dependencies. Instead, we must first
expand the group to get a list of packages in that group.

```bash
 % pacman -Sqg base
bash
bzip2
coreutils
...
which
xfsprogs
```

Then surround all of these with quotes and include them in the depends list
like so.

```bash
depends=(
    'bash'
    'bzip2'
    'coreutils'
    ...
    'which'
    'xfsprogs'
)
```

And there, that is our first meta package, although, it's currently not much
more helpful than the base group. Go ahead and add any additional packages
you want, for example, I have added these (as well as many others) to the list
as I use them on all of my systems.

```bash
    'sudo'
    'neovim'
    'avahi'
    'nss-mdns'
```

### Adding Config Files

Adding a config file to a package is done just like any other package except
you also add it to the `backup` array in the `PKGBUILD`. This instructs pacman
to not replace the file during an upgrade if the user has modified it at all.
But we don't want this for our package - rather, we want to treat config files
as any other package file ensuring it gets replaced on an upgrade. We do this to
stop the configs from drifting apart at the risk of losing some changes to one
system if you don't add those changes back to the package.

Some packages don't drop a default config, while others will read and merge all
files inside a certain directory. These types of packages are easy to add
configs for, we just add the file to our package and let pacman place it in
the correct place. To do this place the configs you want next to the `PKGBUILD`
and add it to the `sources` array with a corresponding entry in `md5sum` or
`sha256sum` (or equivalent) arrays. Then add an `install` line in the `package`
function to copy the file to the correct location inside `$pkgdir`, like so:

```bash
source=('vconsole.conf'
        'sudoers.wheel'
        'mdaffin-base.sh')
md5sums=('12733d28ff3b5352ea1c3d84b27cd6bd'
         '52719e50fbbea8255275964ba70aa0a7'
         '9463e8e19ee914684f7bd5190243aa3f')

package() {
    install -Dm 0644 vconsole.conf "$pkgdir/etc/vconsole.conf"
    install -Dm 0640 sudoers.wheel "$pkgdir/etc/sudoers.d/wheel"
    install -Dm 0755 mdaffin-base.sh "$pkgdir/etc/profile.d/mdaffin-base.sh"
}
```

With this, pacman will drop our configs in the given locations when the package
is installed. It will replace them if we upgrade the package in the future and
will prevent any other package from directly modifying them.

### Overwriting Existing Configs

However, a lot of packages drop a default config file to give the users a base
to start editing from and do not support config directories. Unfortunately
these are problematic as pacman will not allow us to simply install our config
over them. Pacman has no nice way around this limitation but there is a
slightly hacky way to work around the problem using pacman's install hooks.

Instead of dropping the config file directly into place, we can drop it
alongside the existing file, that way we get no conflict with other packages.
Then we can use the `post_install` and `post_upgrade` hooks to copy our config
into place.

The downside of this approach is that pacman does not own or manage the
lifecycle of this file, at least not with our package. It will still treat it
as a config file for the original package, to be backed up or removed upon the
removal of the original package. It will also not be reverted when we remove
our package, although, this can be worked around by using the `post_install`
hook to backup the original config and the `pre_remove` hook to restore it if
you desire. If anyone knows of a better solution to this problem I would love
to hear from you.

Let's take a look at how I did this with my i3 config file in my
`mdaffin-desktop` package. First, we install the config file like we did in the
previous section, but this time next to the original package's config.

```bash
source=('i3-config')
md5sums=('d9dcd133475af688ed86a879821c9384')
package() {
    install -Dm 0644 i3-config "$pkgdir/etc/i3/mdaffin-desktop-config"
}

```

Then we define the hooks in a separate install file, which is a bash script
with at least one of the following functions defined.

- `pre_install()` - runs before the package contents are installed the first
  time the package is installed
- `post_install()` - after the package contents are installed the first time
  the package is installed
- `pre_upgrade()` - before the package contents are installed when a package is
  being upgraded
- `post_upgrade()` - after the package contents are installed when a package is
  being upgraded
- `pre_remove()` - before the package contents are removed when a package is
  being removed
- `post_remove()` - after the package contents are removed when a package is
  being removed

Let's call this file `mdaffin-desktop.install`, once again place it next to the
`PKGBUILD` file. It can be called whatever you want but
`<package-name>.install` is how it is conventionally named.

```bash
post_install() {
    post_upgrade
}

post_upgrade() {
    cp /etc/i3/mdaffin-desktop-config /etc/i3/config
}
```

These run during an install or upgrade and copy the packaged configs to their
destination, overwriting the configs that the upstream package dropped.

Next, we need to tell `makepkg` about this install file by adding the following
to `PKGBUILD`.

```bash
...
install=mdaffin-desktop.install
...
```

Which tells `makepkg` to include this install script in the package and pacman
will run the relevant functions during an install or upgrade of the package.

### Starting Services

One more common thing we want to do is enable/start services. Typically, Arch
Linux does not auto enable or start services on a package install, instead, it
leaves this up to the user. Normally, this is a better approach as it lets you
configure them before they are started for the first time. This is against the
packaging guidelines but since we are creating personal meta-packages it is not
a major problem.

The `post_install` hook from the previous section can also be used to get
`systemctl` to start and enable the service on the first install, where the
user is then free to disable/stop it thereafter. We could also add it to the
`post_upgrade` hook to ensure it gets re-enabled after an upgrade, or if you add
an extra service to a package later on. For example, my desktop package has
these in the install script (in addition to the things in the previous
section).

```bash
post_install() {
    systemctl enable --now sddm
    systemctl enable --now avahi-daemon
}
```

Note that `--now` on a `systemctl enable` causes it to also start the service
in addition to enabling it, basically equivalent to `systemctl start` and
`systemctl enable` in one command. `systemctl` will also behave correctly
inside a chroot environment (such as when pacstrapping a system).

## Building the Package

Once you have crafted a package to your liking it is time to build it. This can
be done with `makepkg` as anyone who has built a package from AUR should be
aware. But instead, I will make use of its lesser-known wrapper `makechrootpkg`
(part of the same package as `makepkg`). While a little bit involved it does
provide a clean build for packages by building them in a fresh chroot
environment rather than on your host system. The downside is that it takes some
prep work and is a little slower. Feel free to continue to use `makepkg` if you
want.

To save time on installing a base arch system into each chroot, `makechrootpkg`
relies on a prepared root which it copies for each package it builds. We can
create this root filesystem by running `mkarchroot`.

```bash
mkdir -p ./chroots
mkarchroot -C /etc/pacman.conf ./chroots/root base-devel
```

`chroot` is where all of the chroots for each of our build environments will
live and `root` is the base root filesystem `makechrootpkg` will use as a base for each
environment by default.

While inside our packages directory run `makechrootpkg` and tell it what
directory to use for the chroot environments (`-r`).

```bash
makechrootpkg -cur ./chroots
```

Once done you will end up with a `<package>-<version>.pkg.tar.xz` package in
the current directory just like with `makepkg`.

For the last step, we will install this package into a repository, such as the one I
showed you how to create in my [last post].

```bash
# Copy the live repository down
mkdir -p local-repo
s3cmd sync s3://mdaffin-arch/repo/x86_64/mdaffin.{db,files}.tar.xz local-repo/
ln -sf local-repo/mdaffin.db.tar.xz local-repo/mdaffin.db
ln -sf local-repo/mdaffin.files.tar.xz local-repo/mdaffin.files
# Add the packages to the repo
repo-add local-repo/mdaffin.db.tar.xz *.pkg.tar.xz
# Upload the packages as well as the changed repo
s3cmd sync --follow-symlinks --acl-public *.pkg.tar.xz \
    local-repo/mdaffin.{db,files}{,.tar.xz} \
    s3://mdaffin-arch/repo/x86_64/
```

You can now install this package like you do any other package with `pacman`,
as long as you have your repository added to `/etc/pacman.conf`.

[last post]: /blog/archlinux-repo-in-aws-bucket/

## Git Repository and Scripting the Build

Now that we can create meta-package and publish them for use let's place these
in a git repository (or another version control system if you prefer) and write
a wrapper script to make building/uploading the packages even easier. You can
find [my repository] on GitHub, feel free to use it as a reference or clone it
to create your own but the packages in there are tuned to my liking. I
encourage you to create your own with how you like your systems setup as I will
radically change them without warning should I wish to try something new.

```bash
mkdir arch-pkgs
cd arch-pkgs
git init
```

I like to put all of my packages inside `pkg/<package name>` to keep them in
one place. Let's copy the package we created above to that location

```bash
mkdir pkg
cp -r ~/mdaffin-base pkg/mdaffin-base
```

But there a whole bunch of temporary/generated files we don't want to commit
to. Let's add a gitignore for these.

```bash
cat <<'EOF' >.gitignore
*.pkg.tar.xz
*.tar.gz
/pkg/**/pkg/
/pkg/**/src/
repo/
*.log
/root/
EOF
```

Now stage these files and check we are not including anything we don't want.

```bash
% git add .
% git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   .gitignore
    new file:   pkg/mdaffin-base/PKGBUILD
    new file:   pkg/mdaffin-base/mdaffin-base.install
    new file:   pkg/mdaffin-base/mdaffin-base.sh
    new file:   pkg/mdaffin-base/sudoers.wheel
    new file:   pkg/mdaffin-base/vconsole.conf
```

If anything is listed that you don't want, just add it to the `.gitignore` and
run `git reset <file>`. Repeat until you are happy then commit.

```bash
git commit -m "My first package"
```

[my repository]: https://github.com/mdaffin/arch-pkgs

### The Build Script

The commands above can be wrapped into a helper script to make building and
uploading the packages simple. Here is the script in its entirety.

```bash
#!/bin/bash
# Wraps aursync command to mount an amazon s3 bucket which contains a repository
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR

REMOTE_PATH=s3://mdaffin-arch/repo/x86_64
LOCAL_PATH=$HOME/.local/share/arch-repo
REPO_NAME=mdaffin

PACKAGES=${@:-pkg/*}
CHROOT="$PWD/root"

mkdir -p "$LOCAL_PATH"
mkdir -p "$CHROOT"

[[ -d "$CHROOT/root" ]] || mkarchroot -C /etc/pacman.conf "$CHROOT/root" base base-devel

for package in $PACKAGES; do
    cd "$package"
    rm -f *.pkg.tar.xz
    makechrootpkg -cur $CHROOT
    cd -
done

s3cmd sync "$REMOTE_PATH/$REPO_NAME".{db,files}.tar.xz "$LOCAL_PATH/"
ln -sf "$REPO_NAME.db.tar.xz" "$LOCAL_PATH/$REPO_NAME.db"
ln -sf "$REPO_NAME.files.tar.xz" "$LOCAL_PATH/$REPO_NAME.files"

repo-add "$LOCAL_PATH/$REPO_NAME.db.tar.xz"<EMAIL_ADDRESS>s3cmd sync --follow-symlinks --acl-public \
<EMAIL_ADDRESS>\
    "$LOCAL_PATH/$REPO_NAME".{db,files}{,.tar.xz} \
    "$REMOTE_PATH/"
```

It starts with some boilerplate code which I will skip over, read [this
post][bash-strict-mode] for more details about it.

Some useful variables are then defined, `${@:-pkg/*}` means take all arguments,
but if there are none it defaults to `pkg/*`. This allows us to build a single
package, any number of packages or by default all packages. `REMOTE_PATH` and
`REPO_NAME` should be changed to match your repository.

We create the `chroot` directory and init the main root filesystem if it does
not already exist. Then loop over all the packages to build them one at a time
with `makechrootpkg`, during which we delete all old package files left over
from previous builds. This keeps the list of built packages down and ensures we
only upload the latest build version.

Lastly, we sync down the remote database to a local cache, add the built
packages to the database then upload all the artefacts back up to the S3
bucket.

Some of this should look familiar from the script we created in the last post.
It would be handy to store both this script and the `aursync` script from my
previous post inside our repository under the `./bin/` directory.

[bash-strict-mode]: /blog/another-bash-strict-mode/

## Example Config Meta-Packages

Here are some examples of system config meta-packages that others have created:

- [mdaffin/arch-pkgs](https://github.com/mdaffin/arch-pkgs/tree/master/pkg/mdaffin)
- [Earnestly/pkgbuilds](https://github.com/Earnestly/pkgbuilds/tree/master/system-config)
- [Foxboron/PKGBUILDS](https://github.com/Foxboron/PKGBUILDS/tree/master/foxboron-system)

## Summary

Now, this is quite a lot of work to set up initially and might not be worth it
if you only manage one or two Arch Linux systems that you rarely change. But if
you manage multiple systems and want to keep them in sync it can be worth the
effort. Once you have set everything up for the first time tweaks to the
packages are much simpler to make and ongoing maintenance less time consuming
than manually ensuring all of your systems have your latest settings.

It is also worth noting that this does not solve the issue of keeping user
files in sync. But most of the user files I want to keep in sync also have
system level defaults that I can keep in sync instead lowering the number of
files I need to manage in my home directory. This works best when you only have
one user, or all your users are fine with the same default settings, but they
can always override them within their own home directory like you normally
would.

_[Discuss on Reddit]_

[discuss on reddit]: https://www.reddit.com/r/archlinux/comments/7v7g4w/managing_multiple_arch_linux_systems_with/

gha_language: Vue

gha_license_id: NOASSERTION


text:
# lein-watch

A Leiningen plugin to watch directories and run tasks automatically.

## Usage

Put `[lein-watch "0.0.2"]` into the `:plugins` vector of your project.clj and
add :watch configuration to your project.clj.

Example configuration (run compile task when .clj file is changed) :

    (defproject sample-project
      ...
      :watch {
        :rate 500 ;; check file every 500ms ('watchtower' is used internally)
        :watchers {
          :compile {
            :watch-dirs ["src"]
            :file-patterns [#"\.clj"]
            :tasks ["compile"]}}}
      ...)

and just run watch task

    $ lein watch

See [sample-project](https://github.com/runoshun/lein-watch/tree/master/sample-project) for more complex usage.

## License

Distributed under the MIT License.

Copyright © 2014 runoshun

repository: runoshun/lein-watch

gha_language: Clojure

repo_name: runoshun/lein-watch


text:
---
layout: post
title: 'leetcode-1'
date: 2018-03-04
categories: 技术
tags: leetcode算法题
---

1. Two Sum

   Given an array of integers, return **indices** of the two numbers such that they add up to a specific target.

   You may assume that each input would have **exactly** one solution, and you may not use the *same* element twice.

   **Example:**

   ```Python
   Given nums = [2, 7, 11, 15], target = 9,

   Because nums[0] + nums[1] = 2 + 7 = 9,
   return [0, 1].
   ```

   ~~~python
   def two_sum(nums,target):
       '''

       :param nums: num list
       :param target: int
       :return:
       '''
       dic={}
       res=[]
       for index,i in enumerate(nums) :
           dic[i]=index

       for j in nums:
           if target-j in dic:
               res.append((dic[j],dic[target-j]))
               dic.pop(j)

       return res

   print(two_sum([1,2,3,6,7,8],9))
   ~~~

2. Add Two Numbers

   You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order** and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

   You may assume the two numbers do not contain any leading zero, except the number 0 itself.

   **Example**

   ```python
   Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) #按个十百...排列
   Output: 7 -> 0 -> 8
   Explanation: 342 + 465 = 807.
   ```

3. reverse

   ~~~python
   def reverse( x):
       """
       :type x: int
       :rtype: int
       """
       l=[]
       is_minus=False
       if x<0:
           x=abs(x)
           is_minus=True
       for index in range(len(str(x))):
          l.insert(0,str(x)[index])
       res=''
       for i in l:
           res+=i
       if is_minus==True:
           return (0-int(res))
       else:
           return int(res)

   print(reverse(-123))
   ~~~

4. 切片

   ```python
   l=[1,2,3,4,5,6]
   print(l[2::-1])
   print(l[4::-1])
   print(l[:3:-1])
   print(l[1:4:-1])
   print(l[:5:-1])
   print(l[1::2])
   print(l[4::-2])

   结果：
   [3, 2, 1]
   [5, 4, 3, 2, 1]
   [6, 5]
   []
   []
   [2, 4, 6]
   [5, 3, 1]
   ```


text:
---
title: Even more coding with the Fuze
layout: post
author: tristan.payne
permalink: /even-more-coding-with-the-fuze/
source-id: 1viL2aPL9cLJ8CuYckb1wsnRwBblDXGM-CsSSif6I5A4
published: true
---

    Title
    Even more coding with the fuze
    Date
    28/11/2016

    Starting point:
    Knowing quite a bit about the Fuze

    Target for this lesson?
    Manage to get through more than 2 pieces of code

    Did I reach my target?
(add details to "Lesson Review")
    Yes I did, I did 1 long piece of code and 3 short pieces of code

    How did I learn? What strategies were effective?

    Be VERY precise with the code because literally 1 letter could make the program not work

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

    We made 1 mistake, not putting in a line of code which make the program say 'error in line 14'. It hindered my working and therefore I couldn’t do an extra piece of work

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

    I know I’ve said this before, it seems like I’m not learning [even though I am!] Look out for those little mistakes, it could completely change[or jam] the code