text:
Principium is a React Native starter kit with Redux. Ready to roll

## Why?

When I started working with React Native I was frustrated about two things.
1. Default configuration was missing a lot of boilerplate
2. Starter projects were too bloated and assumed too many things.

Principium is setting out to solve that with the absolute minimum you need in
order to start your project.

### What it includes

1. React Native
2. Redux
3. Reducer to set the device and the version (so you can use that in conditions
   around your code)

The starter kit has no screens and no navigation pre-baked, you can choose your
own and it will work out of the box.

## Running the project

In order to run the project all you need to do is clone it and run with Xcode
or Android Studio, no other configuration needed.

If you know Redux and React from the web, you should be good to go in minutes.

## Project structure

```
src/
├── actions
│   └── Device
├── constants
│   └── DeviceActionTypes.js
├── containers
│   └── App
├── lib
│   └── configureStore.js
├── principium.js
└── reducers
    ├── Device.js
    └── index.js
```

As you can see above, the project `src` directory is really basic and only
includes the minimum. You have a container called `App` where you start coding
your app and the rest is Redux connections.

## Contributing...

* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution

repository: astannard/principium

repo_name: astannard/principium


text:
---
layout: post
title: "Identifying and Understanding User Reactions to Deceptive and Trusted Social News Sources"
date: 2018-05-30 15:20:14
categories: arXiv_CL
tags: arXiv_CL
author: Maria Glenski, Tim Weninger, Svitlana Volkova
mathjax: true
---

* content
{:toc}

##### Abstract
In the age of social news, it is important to understand the types of reactions that are evoked from news sources with various levels of credibility. In the present work we seek to better understand how users react to trusted and deceptive news sources across two popular, and very different, social media platforms. To that end, (1) we develop a model to classify user reactions into one of nine types, such as answer, elaboration, and question, etc, and (2) we measure the speed and the type of reaction for trusted and deceptive news sources for 10.8M Twitter posts and 6.2M Reddit comments. We show that there are significant differences in the speed and the type of reactions between trusted and deceptive news sources on Twitter, but far smaller differences on Reddit.

##### Abstract (translated by Google)
在社会新闻时代，了解各种可信度的新闻来源引发的反应类型是很重要的。在目前的工作中，我们试图更好地理解用户如何对两个流行且非常不同的社交媒体平台上的可信和欺骗性新闻来源做出反应。为此，（1）我们开发了一个模型，将用户反应分为九种类型之一，例如答案，细化和问题等;（2）我们衡量速度和对可信和欺骗性新闻的反应类型10.8M Twitter帖子和6.2M Reddit评论的来源。我们发现在Twitter上可信和欺骗新闻来源之间的反应速度和反应类型存在显着差异，但在Reddit上的差异要小得多。

##### URL
[http://arxiv.org/abs/1805.12032](http://arxiv.org/abs/1805.12032)

##### PDF
[http://arxiv.org/pdf/1805.12032](http://arxiv.org/pdf/1805.12032)

license: MIT

branch_name: refs/heads/master

extension: md

license_type: permissive


text:
## IKOS - API ##

IKOS-API provides a Python and OCaml API for [IKOS: Inference Kernel for Open Static Analyzers](http://ti.arc.nasa.gov/opensource/ikos/).

IKOS is a C++ library designed to facilitate the development of sound static analyzers based on Abstract Interpretation. IKOS-API provides an easy to use API in Python and OCaml.

## Getting started ##

[http://ikos-api.bitbucket.org](http://ikos-api.bitbucket.org)

## Contents ##

* PyIkos :: IKOS API in Python
* OIkos  :: IKOS API in OCaml

## Dependencies ##

- IKOS: **boost**, **gmp**, **pthread**
- OIkos: IKOS, **ocaml**, **ocamlbuild**
- lustrec: OIkos, **ocamlgraph** : http://ocamlgraph.lri.fr
- PyIkos: IKOS, **python** (2 or 3), **boost_python**

## Build ##

You will need **python** for the build system, _waf_.

run `./waf configure` and then, `./waf build` to build all.

You can compile only OIkos or PyIkos using the options `--no-ocaml` or `--no-python`.
You can also choose a specific version of python, by specifying the path to the python interpreter : `./waf configure --python=/bin/python3`.

## License ##

* [IKOS](http://ti.arc.nasa.gov/opensource/ikos/) is released under the [NASA Open Source Agreement](http://ti.arc.nasa.gov/m/opensource/downloads/ikos/IKOS_NASA_Open_Source_Agreement.pdf).
* IKOS-API is released under the MIT License.
--------
The MIT License (MIT)

Copyright (c) 2014 Carnegie Mellon University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

 IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

------

repository: coco-team/Ikos-Api

repo_name: coco-team/Ikos-Api


text:
---
layout: post
title: "Road to RHCSA 8 - Getting Started"
date: 2020-01-02
categories: RedHat RHCSA Linux certification education
permalink: /road-to-rhcsa8-getting-started/
---

_Updated 2020-01-04_ - Added the Red Hat Certs Slack group to the community list and lab environment to the lab list.

Choosing my educational goal for the year always causes a bit of anxiety. I try to find the right balance between something that is fun to learn and something that will help with my day job. Last year, the educational goal was to learn Volatility memory forensics better through a training class. This year I want to do something a little less complex that will help improve my Linux skills since I often focus on malware and threats for Linux during my day job. So, tackling the Red Hat Certified System Administrator certification seems like a good goal. In this post, I'll go over some of the most recommended resources to start learning for the RHCSA version 8 from Reddit and other sources.

## Exam Details

[Per Red Hat](https://www.redhat.com/en/services/training/ex200-red-hat-certified-system-administrator-rhcsa-exam), the RHCSA is awarded for passing a 2.5 hour exam (EX200). The exam has a practical lab format where the candidate is expected to perform tasks demonstrating mastery of the learning objectives. During the exam, you cannot use Internet or any printed resources, but you can use manpages and documentation shipped with the system.

For exact objectives, see the [exam page](https://www.redhat.com/en/services/training/ex200-red-hat-certified-system-administrator-rhcsa-exam).

## Formal Classroom Training

If you love formal classroom training, Red Hat offers two recommended classes to prepare:

- [Red Hat System Administration I (RH124)](https://www.redhat.com/en/services/training/rh124-red-hat-system-administration-i)
- [Red Hat System Administration II (RH134)](https://www.redhat.com/en/services/training/rh134-red-hat-system-administration-ii)

These classroom trainings are **NOT** required and many people find self-study methods sufficient for success.

## Books

Since the RHCSA exam was recently updated for Red Hat Enterprise Linux (RHEL) 8, there's a shortage of book material. At the time of writing, there's really only one recommended book- [Red Hat RHCSA 8 Cert Guide: EX200 by Sander van Vugt](http://www.pearsonitcertification.com/store/red-hat-rhcsa-8-cert-guide-ex200-9780135938133).

The book is available via numerous means, but purchasing through Pearson's site will allow you to get a book + ebook bundle for ePUB, PDF, and MOBI formats. This cost me about $50.

Michael Jang is another prominent author of RHEL study material, but an updated guide was not available at the time of writing. However, many of the RHCSA v8 objectives overlap with v7 objectives. If you're looking for a second book you could potentially grab Jang's book for RHCSA 7 and use it for the overlappng objectives.

## Video Training

If you are an absolute beginner to Linux, Red Hat has published [free videos on Udemy](https://www.udemy.com/course/red-hat-enterprise-linux-technical-overview/) to get you started.

Two more video training courses are rather widely recommended. The first is the [RHCSA 8 video course from Linux Academy](https://linuxacademy.com/course/red-hat-certified-systems-administrator-rhcsa-ex-200-exam-prep/). The videos are bite-sized and very easy to consume. In addition, you can test out what you learn with Linux Academy's playground environment on RHEL and CentOS servers.

The second recommended video course was the [RHCSA 8 Video Course by Sander van Vugt](http://www.pearsonitcertification.com/store/red-hat-certified-system-administrator-rhcsa-complete-9780135656525). You can purchase this course with a one-time cost or via subscription through [O'Reilly Learning](https://www.oreilly.com/library/view/red-hat-certified/9780135656495/).

## Hands-On Lab Time

To get a good handle on working with RHEL systems, lab time is required to pass the exam. You can achieve this in a few ways.

### Home Lab

You can set up your own physical or virtual lab at home. To do this, you can start with using [CentOS](https://centos.org). This Linux distribution is incredibly similar to RHEL with only a [few package differences](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS8.1905#Packages_and_Applications). The changes mostly revolve around branding, but one major function from RHEL 8 will be missing from CentOS systems- `subscription-manager`.

If you want the full RHEL experience, you can get a free, limited subscription for development and education. The developer subscription entitles you to unlimited RHEL VMs and one physical host running RHEL. For more details, check out [this FAQ](https://developers.redhat.com/articles/faqs-no-cost-red-hat-enterprise-linux/).

If you're going to use virtualization in your home lab, RHEL and CentOS should work fine with nearly any hypervisor available from Virtualbox to VMware.

A good virtual lab setup has been developed by the admin of the Red Hat Cert Slack group here: [https://github.com/rdbreak/rhcsa8env](https://github.com/rdbreak/rhcsa8env).

### Cloud Systems

If you're not a fan of hosting your own systems, you can also study in a cloud lab environment. AWS support RHEL 8 on its "Free Tier" and DigitalOcean usually supports CentOS. At the time of writing it looks like DigitalOcean may not have an updated CentOS image, however.

If you subscribe to Linux Academy, you have access to their playground environment. This lets you set up one or more RHEL 8 systems as desired to test your knowledge. There are also hands-on lab exercises with Linux Academy to practice what you watch in videos.

On the side of "miscellaneous lab training", a couple more resources have been recommended on Reddit:

- [lab.redhat.com](lab.redhat.com)
- [redhatgov.io](redhatgov.io)

From what I can tell so far, these resources are far from comprehensive and will only get you a little relevant training for the RHCSA.

## Community

The community I'm most familiar with is [/r/redhat](https://reddit.com/r/redhat), but there is also an awesome [Slack group](https://join.slack.com/t/redhat-certs/shared_invite/enQtNTk5MTE3MjkwMDA3LTNlMmUyYjM2ODgzN2QwZjJhNzI1MmI3MThhYzk5NzFkZmVmMDA1YWU2Yzk4MzZkOWRjN2MxYTcyMDVlZDU2NGI) for Red Hat certification study that I'm exploring.

## Product Documentation

Finally, there are loads of free and open-source resources for learning Linux. Red Hat publishes loads of documentation freely for RHEL: [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/).

In addition, you can learn from manpages. These are pages of documentation included with products that you download and install on a Linux system. They may be accessed with commands similar to:

```
man systemctl
```

## Wrapping Up

So far, the year is young and I haven't attempted the RHCSA, yet. Once I do, I'll update this post with the resources that helped the most. Cheers!


text:
---
layout: post
title: Moving Azure Scheduler Jobs
date: 2015-10-14 11:36

categories: [Uncategorized]
---
Due to some poor prior planning, my company has a bunch of different Azure subscriptions used for different things, and billing is kinda tough.  Months ago, we chose to merge those subscriptions into just two:  one for real stuff that we want to administer and maintain, and another for folks to use for PoCs and so on.

After moving the VMs in IaaS to the new subscription, I now get to move the table storage, queues, scheduler jobs, and the other PaaS systems to the new subscription.   I have decided to start with the queues and Scheduler Jobs, which kind of go together, since the jobs are write to queue storage.

Problem is, I can't find a way to migrate the jobs anywhere.  The cmdlet "Get-AzureSchedulerJob" retrieves all of the settings for the jobs there, but not the messages that the jobs write.  The solution is to figure out how to get this using the REST API.

Using the hard work from this guy, I was able to piece together a script that would download the current job definitions using the REST API.  The following two functions create the HTTPClient that is needed to get into a subscription and get the scheduler jobs from the given job collection.

# this function gets the azure management certificate for the given subscription and returns the full httpClient connection
function get-azuremanagementhttpclient($xMsVersionHeader='2013-08-01', $sub) {
 $cert = Get-AzureSubscription -SubscriptionName $sub -ExtendedDetails | select -ExpandProperty Certificate
 add-type -AssemblyName System.Net.Http
 add-type -AssemblyName System.Net.Http.WebRequest
 $handler = New-Object System.Net.Http.WebRequestHandler
 $handler.ClientCertificates.Add($cert) | out-null
 $httpClient = new-object System.Net.Http.HttpClient($handler)
 $httpClient.DefaultRequestHeaders.Add('x-ms-version', $xMsVersionHeader)
 $mediaType = new-object System.Net.Http.Headers.MediaTypeWithQualityHeaderValue('application/xml')
 $httpClient.DefaultRequestHeaders.Accept.Add($mediaType)
 $httpClient
}

# this function gets the jobs from the httpClient at the srcURI
function get-jobs($httpClient,$Uri)
{
 $task = $httpClient.GetAsync($Uri)
 $task.Wait()
 if($task.Result.IsSuccessStatusCode -eq "True")
 {
 $jobs = $task.Result.Content.ReadAsStringAsync().Result # $srcSched becomes the JSON definition of the source jobs
 } else {
 $errorInfo = $task.Result.Content.ReadAsStringAsync().Result
 $errorStatus = $task.Result.StatusCode
 Write-Error "Call to GET $Uri failed with HTTP code $errorStatus and message $errorInfo"
 }
 return $jobs
}

Now that I have the jobs defined in text, I replaced the old storage account and queue names with the ones for my target location.   Finally, I used "ConvertFrom-JSON" to convert the $jobs output to a PowerShell object, and used New-AzureSchedulerStorageQueueJob to create the new jobs.

New-AzureSchedulerStorageQueueJob -Location $destLocation -JobCollectionName $destJobCollectionName -JobName $obj.id -StorageQueueAccount $destStorageAccountName `
 -StorageQueueName $destStorageAccountName -SASToken $obj.Action.QueueMessage.sasToken -StorageQueueMessage $obj.Action.QueueMessage.Message `
 -Interval $obj.recurrence.interval -Frequency $freq -JobState Enabled

This wasn't as pretty as I wanted it to be and it took a lot longer than it would have if "
Get-AzureSchedulerStorageQueueJob" had simply given me the message to begin with.   Oh well....works now.

As a to-do, I have to still manually change the Start Times on the new jobs, as they just go into the system with the current time as the start.   If you want to run something daily or weekly, though, you probably want to configure the times.    You can automate this with the Set-AzureSchedulerStorageQueueJob cmdlet or you can just do it in the portal.


text:
## 3.1.1
- Display "Genesis Tx" instead of "Invalid date" in UI if timestamp is not present on tx.
- Fix UI error when reverse order is enabled together with TX type filter
- Adjust ES mapping to be more tolerant toward "scheduleTime" format in POOL_UPGRADE transaction
- Prettier UI
- Display transaction count given currently selected filter/search in UI
- Cap pagination to max 500 pages given default page size of 50

## 3.0.0
- Using `Elasticsearch` instead of `Mongo` for storage
- `indyscan-daemon` is reading configuration file defining what and how to scan, instead of passing configuration
  in environment variables.
- `indysccan-daemon` main scanning loop simplified
- `indyscan-api` extracted out of `indyscan-webapp`
- Before transactions are stored in storage, various expansions on this documents take place, depending on
  type of transaction. For example for `CLAIM_DEF` transactions, details about schema it is based on is added.
- `indyscan-webapp` - the transaction view now does not only display raw ledger data, but alo easy to read
  highlights about the transaction, depending on transactions type.
- `indyscan-webapp` - the transactions list view contains fulltext search feature
- `indyscan-webapp` - the transactions list view displays selection of important information about transaction
  instead of `roothash`
- `indyscan-webapp` - removed `stats` view. Can be expected to be added again in following 3.x.x versions.
- updated from `Node 8` to `Node 12`
- updated IndySDK to `1.14.1`
- decreased `inyscan-webapp` docker image size from `869` to `290` mb
- decreased `indyscan-daemon` docker image size from `3GB` to `1.3GB` (still terrible, help appreciated).

## 2.0.0
##### Daemon
- Use refactored storage module
- Complete rewrite into modular architecture of transaction resolvers, transaction emitter and
transaction consumer.

##### Explorer webapp
- Fix failing to render tx list page if there's unknown transaction type
- Add support for new transaction types `REVOC_REG_DEF`, `REVOC_REG_ENTRY`, `AUTH_RULE`,
`AUTH_RULES`, `TXN_AUTHOR_AGREEMENT`, `TXN_AUTHOR_AGREEMENT_AML`
- Use refactored storage module
- Display timeseries graphs on separate page
- Display latest transactions on homepage
- Adjust layout of network / menu links
- Display pretty error if tx page for particular transaction can't be displayed
- Display current version of webapp at footer of homepage

## 1.x.x
- First official release
- Improved color-coded logging using Winston library. Better use of info/debug levels.
- Error handling improvements
- Initial delay before scanning begins is configurable via `INITIAL_SCAN_DELAY_MS` environment variable.

license: ISC

repository: mta-blockchain-lab/indyscan

repo_name: mta-blockchain-lab/indyscan


text:
Forkify

[![Status](https://img.shields.io/badge/status-active-success.svg)]()

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)

---

 Forkify helps you to decide about recipes for your next pasta

##📝 Table of Contents

- [About](#about)
- [Getting Started](#getting_started)
- [Deployment](#deployment)
- [Usage](#usage)
- [Built Using](#built_using)
- [TODO](../TODO.md)
- [Contributing](../CONTRIBUTING.md)
- [Authors](#authors)
- [Acknowledgments](#acknowledgement)

## 🧐 About

This project was build as an example of the power of vanilla javascript to make life easier searching for recipes that we fetch from an API

## 🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.

### Prerequisites

```
Node Js
```

## 🎈 Usage

Open the app using npm run start.

## 🚀 Deployment

You can deploy this page to Netlify.

## ⛏ Built Using

- [Javascript](https://www.mongodb.com/) - Programming language
- [Webpack](https://expressjs.com/) - Bundle
- [HTML](https://vuejs.org/) - The body
- [CSS](https://nodejs.org/en/) - Styles

## ✍ Authors

- [@fernandocutire](https://github.com/FernandoC1217) - Build by
- [@jonasschmedtmann](https://github.com/jonasschmedtmann) - Idea & Initial Work

  See also the list of [contributors](https://github.com/FernandoC1217/Forkify/contributors) who participated in this project.

## 🎉 Acknowledgements

- It was a fun project
- Only uses vanilla Javascript
- Project of Udemy course Jonas

repository: FernandoCutire/Forkify

branch_name: refs/heads/main

repo_name: FernandoCutire/Forkify


text:
# Catan

## Maps, Hexes, and Tiles, oh my!

### Glossary

* Hex: The logical structure of a single hexagon. The board is made up of a pattern of these
* Tile: The "face" of the hexagon. The face contains the things that sit on top of the hexagon's inner space. This includes the terrain/resource type, the chit, and possibly the robber
* Edge: a single edge of a hexagon, which can contain a road or harbor
* Vertex: a single point representing the point at which three edges meet. A vertex can contain a settlement or city
* Flat top: The layout of the board (as opposed to "pointy top"). We are using flat top because it is easier to lay out an ascii board in flat top orientation.

### Hexes and Tiles

#### In order to have a unique address for every point on the board, each hex "owns" a pair of vertices and the hex's southern edges. The other vertices and edges are owned by adjacent hexagons on the board. See the following ascii illustration for naming conventions:

```
             >-----<
            /~~~~~~~\
           /~~~2:1~~~\
 :left    <~~~brick~~~> :right
           \~~~~~~~~~/
     :sw    \~~~~~~*/   :se
             >-----<
               :s
```

### References (these are important!)

* http://www.redblobgames.com/grids/hexagons/
* www.catan.com/files/downloads/catan_5th_ed_rules_eng_150303.pdf


text:
Image Carousel For ReactJs
====================================
* Image carousel component for ReactJs

## Installation
    npm install --save image-carousel-react
    yarn add image-carousel-react

## Example

``` javascript
import ReactImageCarousel from 'image-carousel-react';
import React, { Component } from 'react';
export default class Example extends Component{
  constructor(props){
    super(props);
    this.state={
      images:{
        {
          source: 'path',
          caption: 'caption'
        },
        {
          source: 'path',
          caption: 'caption'
        },
        {
          source: 'path',
          caption: 'caption'
        },
        {
          source: 'path',
          caption: 'caption'
        },
        {
          source: 'path',
          caption: 'caption'
        },
      }
    }
  }
  render(){
    return(
      <ReactImageCarousel images={this.state.images}
      defaultImage={`default image index`}
      />
    )
  }
}

```
## License MIT
* MIT License

Copyright (c) 2018 anubhav04

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

 IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


text:
+++
title = "Consulting"
+++

# Bitcoin Trade Consulting – (coming soon)

For many traders, sometimes reading a manual is not enough. We therefore offer one on one telephone consulting to review the techniques presented in the manual.

Bitcoin Consulting can be done at anytime as the markets are trading 24 x 7\. We only have to find a time which is convenient for both of us.

During the 1 hour Bitcoin Consulting session, each of the trading techniques presented in the manual will be explained using real time charts. We walk you through each trading scenario with recent market data. We explain how and when each technique is used and what signals to look for to either enter or exit the trade. We then guide you through the recent past market patterns to validate the techniques.

Requirements:

Studied the Pro Bitcoin Trading Manual

Computer with internet connection (no smart phones)

Telephone

1 Hour of uninterrupted time

To schedule your 1 hour Bitcoin Consulting session, send an email to<EMAIL_ADDRESS>Please provide at least two dates and times to select from. Once times are verified, you will be given a Bitcoin address for payment. Payment must be made prior to the consulting session begins.


text:
---
title: Finding Shortest Paths using Breadth First Search
header:
  overlay_image: /assets/images/flights-traversals/header.png
  overlay_filter: 0.5
  og_image: https://og-image.vercel.app/Shortest%20Paths%20Using%20Breadth%20First%20Search.png
  collection: blog
excerpt: Wait, we can use BFS for shortest paths too? Tell me more.
date: July 20, 2018
show_date: true
toc: true
toc_label: Content
toc_sticky: true
tags:
- Competitive Programming
- Graphs
- Traversal Algorithms
applause_count: 0
---

## Finding Shortest Paths using Breadth First Search

Do you know the amount of global air traffic in 2017? Do you know what the rise has been for air traffic over the past several years ? Well, lets look at some statistics.

Source: [https://www.statista.com/statistics/564769/airline-industry-number-of-flights/](https://www.statista.com/statistics/564769/airline-industry-number-of-flights/)

According to the [International Civil Aviation Organization](https://www.icao.int/Pages/default.aspx) (ICAO), a record 4.1 billion passengers were carried by the aviation industry on scheduled services in 2017. And, the number of flights rose to 37 million globally in 2017.

That’s a lot of passengers and a lot of flights occupying the air space on a daily basis across the world. Since there are hundreds and thousands of these flights all around the globe, there are bound to be different routes with multiple stops in between from one place to another.

Every flight has a source and destination of its own and a standard economy seat price associated with it. Let’s leave out the fancy business class tickets and extra leg room and what not!

In such a scenario, it is too confusing to choose what flight would be the best one if we want to go from one place to another.

Let’s see the number of flight options [StudentUniverse](https://www.studentuniverse.com/?noMoreRedirect=true) (provides discounts for students 😜) gives me from Los Angeles to New Delhi.

Every flight has a Details hyperlink with it, so we searched for that and found 119 total flights.

Every flight has a Details hyperlink with it, so we searched for that and found 119 total flights.

119 total flights are being offered. Then there appears a pop up on the website saying that there are other websites that might be offering similar flights at even cheaper rates. 😩

So many websites and uncountable flights for just a single source and destination.

As a developer, if I want to solve this problem, I would build a system to efficiently address the following queries:

* Total number of destinations reachable (with a max number of stops) from my current location, and also list those destinations. One should keep their options open when they want to travel 😃.
* It is a known fact (IMO 😉) that a route with multiple stops tends to be a cheaper alternative to direct flights. So, given a source and a destination, we may want to find routes with at least 2 or 3 stops.
* Most importantly: What is the cheapest route from a given source to a given destination?
* And…. We’ll come to this one in the end 🙈.

As you might guess, there would be potentially thousands of flights as the output of the first two queries. But we can certainly reduce that by providing some other criteria to lessen the output size. For the scope of this article, let us focus on these original queries themselves.

## Modeling the Flight Network as a Graph

It’s pretty clear from the headline of this article that graphs would be involved somewhere, isn’t it?

Modeling this problem as a graph traversal problem greatly simplifies it and makes the problem much more tractable. So, as a first step, let us define our graph.

We model the air traffic as a:

* directed
* possibly cyclic
* weighted
* forest.

*Directed* ~ because every flight will have a designated source and a destination. These carry a lot of meaning.

*Cyclic* ~ because it is very possible to follow a bunch of flights starting from a given location and ending back at the same location.

*Weighted* ~ because every flight has a cost associated with it which would be the economy class flight ticket for this article.

And finally, a *forest* because we might have multiple connected components. It is not necessary that all the cities in the world have some sort of flight network between them. So, the graph can be disconnected, and hence a forest.

The vertices, `V`, would be the locations all over the world wherever there are working airports.

The edges, `E`, would be representative of all the flights constituting the air traffic. An edge from `u --> v` simply means you have a directed flight from the location / node `u` to `v` .

Sample flight network with the cost labelling for different flights.

Now that we have an idea about how to model the flight network as a graph, let us move on and solve the first common query that a user might have.

## Total Number of Destinations Reachable

Who doesn’t like to travel?

As someone who likes to explore different places, you would want to know what all destinations are reachable from your local airport. Again, there would be additional criteria here to reduce the results of this query. But to keep things simple, we will simply try and find all the locations reachable from our local airport.

Now that we have a well defined graph, we can apply traversal algorithms to process it.

Starting off from a given point, we can use either [Breadth First Search](https://en.wikipedia.org/wiki/Breadth-first_search) (BFS) or [Depth First Search](https://en.wikipedia.org/wiki/Depth-first_search) (DFS) to explore the graph or the locations reachable from the starting location *within a maximum number of stops.* Since this article is all about the breadth first search algorithm, let’s look at how we can use the famous BFS to accomplish this task.

We will initialize the BFS queue with the given location as the starting point. We then perform the breadth first traversal, and keep going until the queue is empty or until the maximum number of stops have been exhausted.

*Note:* If you are not familiar with the breadth first search or depth first search, I would recommend going through [this article](https://medium.freecodecamp.org/deep-dive-into-graph-traversals-227a90c6a261) before continuing.
{: .notice--info}

Let’s look at the code to initialize our graph data structure. We also need to look at how the BFS algorithm would end up giving us all the destinations reachable from a given source.

Some Random set of flights with source, destination and their prices.

Now that we have a good idea about how the graph is to be initialized, let’s look at the code for the BFS algorithm.

Performing `bfs` on the city of Los Angeles would give us the following destinations which are reachable:

```
{'Chicago', 'France', 'Ireland', 'Italy', 'Japan', 'New Delhi', 'Norway'}
```

That was simple, wasn’t it?

We will look at how we can limit the BFS to a maximum number of stops later on in the article.

In case we have a humongous flight network, which we would have in a production scenario, then we would not ideally want to explore all the reachable destinations from a given starting point.

This is a use case if the flight network is very small or pertains only to a few regions in the United States.

But, for a large network, a more realistic use case would be to find all the flight routes with multiple stops. Let us look at this problem in some more detail and see how we can solve it.

## Routes with multiple stops

It is a well known fact that more often than not, for a given source and destination, a multi stop trip is cheaper than a direct, non-stop flight.

A lot of times we prefer the direct flight to avoid the layovers. Also because the multi-stop flights do tend to take a lot of time — which we don’t have.

However, if you don’t have any deadlines approaching and you want to save some bucks (and are comfortable with the multi-stop route that a lot of airlines suggest), then you might actually benefit a lot from something like this.

Also, you might get to pass through some of the most beautiful locations in the world with some of the most advanced airports which you can enjoy. So, that’s enough motivation as it is.

In terms of the graph model that we have been talking about, given a source and a destination, we need to come up with routes with 2 or more stops for a given source and destination.

As an end user, we might not want to see flights in this order for this query:

```
[A, C, D, B], 2 stops, $X
[A, E, D, C, F, W, G, T, B], 8 stops, $M
[A, R, E, G, B], 3 stops, $K
[A, Z, X, C, V, B, N, S, D, F, G, H, B, 11 stops, $P
```

I know. Nobody in their right minds would want to go for a flight route with 11 stops. But the point I’m trying to make is that an end user would want symmetry. Meaning that they would want to see all the flights with 2 stops first, then all the flights with 3 stops and so on till maybe a max of, say, 5 stops.

But, all the flight routes with the same number of stops in between should be displayed together. That is a requirement we need to satisfy.

Let’s look at how we can solve this. So, given the graph of flight networks, a source `S` and a destination `D`, we have to perform a level order traversal and report flight routes from `S --> D` with at least 2 and at most 5 stops in between. This means we have to do a level order traversal until a depth of 7 from the start node `S` .

Have a look at the code for solving this problem:

This might not be the best way to go about solving this problem at scale — the largest memory constraint would be due to the nodes currently present in the queue.

Since every node or location can have thousands of flights to other destinations in the world, the queue could be humongous if we store actual flight data like this. This is just to demonstrate one of the use cases of the breadth first search algorithm.

Now, let us just focus on the traversal and look at the way it is done. The traversal algorithm is simple as it is. However, the entire space complexity of the level order traversal comes from the elements in the queue and the size of each element.

There are multiple ways to implement the algorithm. Also, each of them varies in terms of maximum memory consumed at any given time by the elements in the queue.

We want to see the maximum memory consumed by the queue at any point in time during the level order traversal. Before that, let’s construct a random flight network with random prices.

Now let us look at the implementation of level order traversal.

This above is the easiest and most straightforward implementation of the level order traversal algorithm.

With every node we add to the queue, we also store the level information and we push a tuple of `(node, level)` into the queue. So every time we pop an element from the queue, we have the level information attached with the node itself.

The level information for our use case would mean the number of stops from the source to this location in the flight route.

It turns out that we can do better as far as memory consumption of the program is concerned. Let us look at a slightly better approach to doing level order traversal.

The idea here is that we don’t store any additional information with the nodes being pushed into the queue. We use a `None` object to mark the end of a given level. We don’t know the size of any level before hand except for the first level, which just has our `source` node.

So, we start the queue with `[source, None]` and we keep popping elements. Every time we encounter a `None` element, we know that a level has ended and a new one has started. We push another `None` to mark the end of this new level.

Consider a very simple graph here, and then we will dry run this through the graph.

```
************************** LEVEL 0 begins
level = 0, queue = [A, None]
level = 0, pop, A, push, B, C, queue = [None, B, C]

pop None ********************** LEVEL 1 begins
push None
level = 1, queue = [B, C, None]
level = 1, pop, B, push, C, D, F, queue = [C, None, C, D, F]
level = 1, pop, C, push, D, D (lol!), queue = [None, C, D, F, D, D]

pop None ********************** LEVEL 2 begins
push None
level = 2, queue = [C, D, F, D, D, None] .... and so on
```

I hope this sums up the algorithm pretty well. This certainly is a neat trick to do level order traversal, keep track of the levels, and not encounter too much of a memory concern. This certainly reduces the memory footprint of the code.

Don’t get complacent now thinking this is a great improvement.

It is, but you should be asking two questions:

1. How big of an improvement is this?
2. Can we do better?

I will answer both of these questions now starting with the second question. The answer to that is Yes!

We can do one better here and completely do away with the need for the `None` in the queue. The motivation for this approach comes from the previous approach itself.

If you look closely at the dry run above, you can see that every time we pop a `None`, one level is finished and the other one is ready for processing. The important thing is that an entire next level exists in the queue at the time of popping of a `None` . We can make use of this idea of considering the queue size into the traversal logic.

Here is the pseudo code for this improved algorithm:

```
queue = Queue()
queue.push(S)
level = 0
while queue is not empty {
      size = queue.size()
      // size represents the number of elements in the current level
      for i in 1..size {
          element = queue.pop()
          // Process element here
          // Perform a series of queue.push() operations here level += 1
```

And here is the code for the same.

The pseudo code is self explanatory. We essentially do away with the need for an extra `None` element per level and instead make use of the queue’s size to change levels. This would also lead to improvement over the last method, but how much?

Have a look at the following Jupyter Notebook to see the memory difference between the three methods.

* We track the maximum size of the queue at any time by considering the sum of sizes of individual queue elements.
* According to Python’s documentation, `sys.getsizeof` returns the object’s pointer or reference’s size in bytes. So, we saved almost 4.4Kb space `(20224 — 15800 bytes)` by switching to the `None` method from the original level order traversal method. This is just the memory savings for this random example, and we went only until the 5th level in the traversal.
* The final method only gives an improvement of 16 bytes over the `None` method. This is because we got rid of just 4 `None` objects which were being used to mark the 4 levels (apart from the first one) that we processed. Each pointer’s size (pointer to an object) is 4 bytes in Python on a 32 bit system.

Now that we have all these interesting multi-path routes from our source to our destination and highly efficient level order traversal algorithms to solve it, we can look at a more lucrative problem to solve using our very own BFS.

What’s the cheapest flight route from my source to a given destination? This is something everybody would be instantly interested in. I mean who doesn’t want to save some bucks?

## Shortest Path from a given source to destination

There’s not much description to give for the problem statement. We just need to find the shortest path and make the end user happy.

Algorithmically, given a weighted directed graph, we need to find the shortest path from source to destination. Shortest or cheapest would be one and the same thing from the point of the view of the algorithm.

We will not go into describing a possible BFS solution to this problem because such a solution would be intractable. Let us look at the graph below to understand why that is the case.

We say that BFS is the algorithm to use if we want to find the *shortest path* in an [undirected, unweighted graph](https://medium.freecodecamp.org/deep-dive-into-graph-traversals-227a90c6a261)*_._* The claim for BFS is that the first time a node is discovered during the traversal, that distance from the source would give us the shortest path.

The same cannot be said for a weighted graph. Consider the graph above. If say we were to find the shortest path from the node `A` to `B` in the undirected version of the graph, then the shortest path would be the direct link between A and B. So, the shortest path would be of length `1` and BFS would correctly find this for us.

However, we are dealing with a weighted graph here. So, the first discovery of a node during traversal *does not guarantee* the shortest path for that node. For example, in the diagram above, the node `B` would be discovered initially because it is the neighbor of `A` and the cost associated with this path (an edge in this case) would be `25` . But, this is not the shortest path. The shortest path is `A --> M --> E --> B` of length `10`.

Breadth first search has no way of knowing if a particular discovery of a node would give us the shortest path to that node. And so, the only possible way for BFS (or DFS) to find the shortest path in a weighted graph is to search the entire graph and keep recording the minimum distance from source to the destination vertex.

This solution is not feasible for a huge network like our flight network that would have potentially thousands of nodes.

We won’t go into the details of how we can solve this. That is out of scope for this article.

What if I told you that BFS is just the right algorithm to find the shortest path in a weighted graph with a slight constraint ?

## Constrained Shortest Paths

Since the graph we would have for the flight network is humongous, we know that exploring it completely is not really a possibility.

Consider the problem of shortest paths from the customer’s perspective. When you want to book a flight, these are the following options you ideally consider:

*   It shouldn’t be too long a flight.
*   It should be under your budget (Very Important).
*   It may have multiple stops but not more than `K` where `K` can vary from person to person.
*   Finally we have personal preferences which involve things like lounge access, food quality, layover locations, and average leg room.

The important point to consider here is the third one above: it may have multiple stops, but not more than `K` where `K` can vary from person to person.

A customer wants the cheapest flight route, but they also don’t want say 20 stops in between their source and destination. A customer might be okay with a maximum of 3 stops, or in extreme cases maybe even 4 — but not more than that.

We would want an application that would find out the cheapest flight route with [at most K stops](https://leetcode.com/problems/cheapest-flights-within-k-stops/description/) for a given source and destination.

This question from LeetCode has been the primary motivation for me to write this article. I strongly recommend going through the question once and not only relying on the snapshot above.

“Why would BFS work here?” one might ask. “This is also a weighted graph and the same reason for the failure of BFS that we discussed in the previous section should apply here.” NO!

The number of levels that the search would go to is limited by the value `K` in the question or in the description provided at the start of section. So, essentially, we would be trying to find the shortest path, but we won’t have to explore the entire graph as such. We will just go up to the level `K`.

From a real life scenario, the value of `K` would be under 5 for any sane traveler 😝.

Let us look at the pseudo-code for the algorithm:

```python
def bfs(source, destination, K):
      min_cost = dictionary representing min cost under K stops for each node reachable from source.       set min_cost of source to be 0 Q = queue()
      Q.push(source)
      stops = 0
      while Q is not empty { size = Q.size
           for i in range 1..size {
                 element = Q.pop()                 if element == destination then continue for neighbor in adjacency list of element {
                        if stops == K and neighbor != destination        then continue                        if min_cost of neighbor improves, update and add back to the queue.
                }
           }
           stops ++
      }
```

This again is level order traversal and the approach being used here is the one that makes use of the queue’s size at every level. Let us look at a commented version of the code to solve this problem.

> Essentially, we keep track of the minimum distance of every node from the given source. The minimum distance for the source would be 0 and +inf for all others initially.

Whenever we encounter a node, we check if the current minimum path length can be improved or not. If it can be improved, that means that we have found an alternate path from source to this vertex with cheaper cost — a cheaper flight route until this vertex. We queue this vertex again so that locations and nodes reachable from this vertex on are updated (may or may not be) as well.

The key thing is this:

```python
# No need to update the minimum cost if we have already exhausted our K stops.
if stops == K and neighbor != dst:
    continue
```

So we just popped the a node represented by `element` in the code and `neighbor` can either be a destination or a random other node. If we have already exhausted our `K` stops with the `element` being the `Kth` stop, then we shouldn’t process and update (possibly) the minimum distance for `neighbor`. This would violate our maximum `K` stops condition in that case.

As it turns out, I solved this problem originally using Dynamic Programming and it took around 165ms to run on the LeetCode platform. I ran using BFS and it was blazing fast with just 45ms to execute. Motivation enough to write this article for you guys.

I hope you were able to derive some benefit from this article on Breadth First Search and some of its applications. The major focus was to showcase its application to shortest paths in a weighted graph under some constraints 😃.

gha_language: JavaScript

gha_license_id: MIT


text:
# no-at-important

This rule forbid the use of `!important`.
_`!important` make css maintenance hard, you should use it with [care](https://css-tricks.com/when-using-important-is-the-right-choice/)._

## options

### true

The following pattern are considered violations:

```css
a {
  color: white !important;
}

.foo {
  color: white !important;
}
```

### ignoreLayers: ["string"]

The ITCSS archi is based on [layers](https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/), it can be usefull to use `!important` in some of them like the `utilities` one.

This option disable the rule in the layers targeted by the option's content.

repository: KamiKillertO/stylelint-itcss

branch_name: refs/heads/develop

gha_language: TypeScript

repo_name: KamiKillertO/stylelint-itcss


text:
# Elman_Network
Elman neural network is a kind of feedback neural network; based on BP neural network hidden layer adds an undertake layer, as the delay operator, the purpose of memory, so that the network system has ability to adapt to the time-varying dynamic characteristics and has strong global stability.

It is used to predict power consumption.
Data is also in this file. You need ipython notebook to open this.


text:
# Interpolations and Barycenters

Some distances distance define the existence of a shortest path, a *geodesic*. An interpolation is essentially a datapoint on that shortest path. We provide some functionality to interpolate between different spectra and models under transport-based metrics.

Below is an example usage of interpolations. We initially create two random systems, we then define the distance under which to interpolate and then calculate the frequency response for some different values of the interpolation parameter $t \in (0,1)$

```@example
using SpectralDistances, ControlSystemsBase, Distances, Plots, Random
plotly()
Random.seed!(0)

n = 4
r1 = complex.(-0.01 .+ 0.001randn(3), 2randn(3))
r1 = ContinuousRoots([r1; conj.(r1)])

r2 = complex.(-0.01 .+ 0.001randn(3), 2randn(3))
r2 = ContinuousRoots([r2; conj.(r2)])

r1,r2 = normalize_energy.((r1, r2))

A1 = AR(r1)
A2 = AR(r2)

##
fig1   = plot()
t      = 0.1
dist   = RationalOptimalTransportDistance(domain=Continuous(), p=2, interval=(0., exp10(1.01)))
interp = SpectralDistances.interpolator(dist, A1, A2)
w      = exp10.(LinRange(-1.5, 1, 300))
for t = LinRange(0, 1, 7)
    Φ = clamp.(interp(w,t), 1e-10, 100)
    plot!(w, sqrt.(Φ), xscale=:log10, yscale=:log10, line_z = t, lab="", xlabel="", title="W_2", ylims=(1e-3, 1e1), colorbar=false, l=(1,), c=:viridis)
end

rdist  = EuclideanRootDistance(domain = Continuous(), p = 2)
interp = SpectralDistances.interpolator(rdist, A1, A2, normalize=false)
fig2   = plot()
for t = LinRange(0, 1, 7)
    Φ = interp(w,t)
    plot!(w, sqrt.(Φ), xscale=:log10, yscale=:log10, line_z = t, lab="", xlabel="", title="RD", ylims=(1e-3, 1e1), colorbar=false, l=(1,), c=:viridis)
end

fig3 = plot()
Φ1   = bode(tf(A1), w)[1][:]
Φ2   = bode(tf(A2), w)[1][:]
for t = LinRange(0, 1, 7)
    plot!(w, (1-t).*Φ1 .+ t.*Φ2, xscale=:log10, yscale=:log10, line_z = t, lab="", xlabel="Frequency", title="L_2", ylims=(1e-3, 1e1), colorbar=false, l=(1,), c=:viridis)
end

fig = plot(fig1, fig2, fig3, layout=(3,1))
savefig("interpolation.html"); nothing # hide
```

```@raw html
<object type="text/html" data="../interpolation.html" style="width:100%;height:450px;"></object>
```

## Barycenters
A barycenter is a generalization the the arithmetic mean to metrics other than the Euclidean. A barycenter between models is calculated like this
```julia
bc = barycenter(distance, models)
```
It can be useful to provide some options to the solvers:
```julia
options = (solver=sinkhorn_log!, tol=1e-8, iters=1_000_000, γ=0.0, uniform=true, inneriters=500_000, innertol=1e-6)
distance = OptimalTransportRootDistance(domain=Continuous(), p=2, β=0.01, weight=simplex_residueweight)
bc = barycenter(distance, models; options...)
```
We can plot the barycenters:
```@example
using SpectralDistances, ControlSystemsBase, Plots
models   = examplemodels(3)
distance = OptimalTransportRootDistance(domain=Continuous())
bc       = barycenter(distance, models)
w        = exp10.(LinRange(-0.5, 0.5, 350)) # Frequency vector
G        = tf.(models) # Convert models to transfer functions from ControlSystemsBase.jl
plot()
bodeplot!.(G, Ref(w), plotphase=false, lab="Input models", linestyle=:auto)
bodeplot!(tf(bc), w, plotphase=false, lab="Barycenter", xscale=:identity, c=:green)
savefig("barycenter.html"); nothing # hide
```
```@raw html
<object type="text/html" data="../barycenter.html" style="width:100%;height:450px;"></object>
```

### Barycenters between spectrograms
We can also calculate a barycenter between spectrograms (or arbitrary matrices) using an efficient convolutional method. The most important parameter to tune in order to get a good result, apart from the regularization parameter `β`, is the `dynamic_floor`. This parameter determines where (in log space) the floor of the PSD is. This serves as a denoising, why the barycenter appears with a very dark background in the image below.
```@example barycenter_spectrograms
using SpectralDistances, DSP, Plots
N     = 24_000
t     = 1:N
f     = range(0.8, stop=1.2, length=N)
y1    = sin.(t .* f) .+ 0.1 .* randn.()
y2    = sin.(t .* reverse(f .+ 0.5)) .+ 0.1 .* randn.()
S1,S2 = spectrogram.((y1,y2), 1024)

A = [S1,S2]
β = 0.0001     # Regularization parameter (higher implies more smoothing and a faster, more stable solution)
λ = [0.5, 0.5] # Barycentric coordinates (must sum to 1)
B = barycenter_convolutional(A, β=β, tol=1e-6, iters=2000, ϵ=1e-100, dynamic_floor=-2)
plot(
    plot(S1, title="S1"),
    plot(B, title="Barycenter"),
    plot(S2, title="S2"),
    layout=(1,3),
    colorbar=false
)

savefig("barycenter_sg.html"); nothing # hide
```
```@raw html
<object type="text/html" data="../barycenter_sg.html" style="width:100%;height:450px;"></object>
```
Note that in order to calculate the barycenter, the sum of each input spectrogram is normalized.

This function works for any vector of matrices as long as all entries are positive and each matrix has an equal sum.

For a more thourogh example, see [whistle.jl](https://github.com/baggepinnen/SpectralDistances.jl/blob/master/examples/whistle.jl).

### Trade off between frequency and time
There is currently no way of having different costs between transport in time and transport along the frequency axis other than to change the resolution of the spectrogram.

## Barycentric coordiantes
The inverse problem to that of finding a barycenter is that of finding the barycentric coordinates λ of a query point $Q$, such that the resulting barycenter is as close as possible to the query point. Given a set of rational spectra $\left\{ G_i \right\}$, a nonlinear projection of a spectrum $Q$ onto this set can be obtained by solving the following nested optimization problem
```math
\begin{aligned}
  λ &= \argmin_{\bar{λ}} \, W\big(Q,  Q^*(\bar{λ})\big)\\
  Q^*(\bar{λ}) &= \argmin_{\bar{Q}} \sum_i \bar{λ}_i W(G_i, \bar{Q})
\end{aligned}
```
where $λ$ are the barycentric coordinates belonging to the probability simplex. Problems of this type are sometimes referred to as [histogram regression](https://perso.liris.cnrs.fr/nicolas.bonneel/WassersteinBarycentricCoordinates/WBC_lowres.pdf).

A nonlinear projection onto a basis consisting of spectra can be useful for, e.g., spectral dictionary learning, basis pursuit, topic modelling, denoising and detection. The function [`barycentric_coordinates`](@ref) is available for select distances:
```@docs
barycentric_coordinates
```

Below is an example that assumes that you have access to a vector with a signal called `y` and the corresponding sample rate `fs` (in this example, we use the `y` constructed in the previous example. In the example, we simply use one of the input spectra as query point. This way, we know what barycentric coordinates we expect
```@example barycenter_spectrograms
using SpectralDistances, DSP, Plots
models = map(DSP.arraysplit(y1, 8*512, 0)) do y
    spectrogram(y, 512, fs = 24_000, window=hanning)
end

matrices = s1.(normalize_spectrogram.(models))

β      = 0.01
dist   = ConvOptimalTransportDistance(β=β)
Q      = matrices[2] # Use the second spectrogram as query
λ, res = barycentric_coordinates(dist, matrices, Q)
plot(
    bar(λ, title="Barycentric coordinates", lab=""),
    plot(spectrogram(y1, window=hanning), title="Signal"),
    heatmap(Q, title="Query point")
)

savefig("barycentric_coords_sg.html"); nothing # hide
```
```@raw html
<object type="text/html" data="../barycentric_coords_sg.html" style="width:100%;height:450px;"></object>
```

## K-Barycenters
Below, we show an example of how one can run the K-barycenter algorithm on a collection of sound signals. `sounds` is expected to be of type `Vector{Vector{T}}`. The example further assumes that there is a vector of `labels::Vector{Int}` that contain the true classes of the datapoints, which you do not have in an unsupervised setting.
```julia
using SpectralDistances, ControlSystemsBase
fitmethod = TLS(na=12)
models = SpectralDistances.fitmodel.(fitmethod, sounds)
G = tf.(models) # Convert to transfer functions for visualization etc.

##
using Clustering
dist = OptimalTransportRootDistance(domain=Continuous(), β=0.01, weight=simplex_residueweight)
@time clusterresult = SpectralDistances.kbarycenters(
    dist,
    models,
    n_classes, # number of clusters
    seed       = :rand,
    solver     = sinkhorn_log!,
    tol        = 2e-6,
    innertol   = 2e-6,
    iters      = 100000,
    inneriters = 100000,
    verbose    = true,
    output     = :best,
    uniform    = true,
    kiters     = 10
)

bc,ass = clusterresult.barycenters, clusterresult.assignments

# Visualize results
using MLBase, Plots.PlotMeasures, AudioClustering
newass,perm = AudioClustering.associate_clusters(labels,ass)
classinds   = 1:n_classes
yt          = (classinds, [label_strings[findfirst(labels .== i)] for i in classinds])

@show mean(labels .== newass)
cm = confusmat(n_classes,labels,newass)
heatmap(cm./sum(cm,dims=2), xlabel="Cluster assignment",ylabel="Best matching class", color=:viridis)
anns = [(reverse(ci.I)..., text(val,12,:gray)) for (ci,val) in zip(CartesianIndices(cm)[:], vec(cm))]
annotate!(anns)
yticks!(yt)
xticks!(yt, xrotation=45)
current()
```
The figure should look like the last figure in [the paper](http://arxiv.org/abs/2004.09152).

```@index
Pages = ["interpolations.md"]
Order   = [:type, :function, :macro, :constant]
```
```@autodocs
Modules = [SpectralDistances]
Private = false
Pages   = ["interpolations.jl", "barycenter.jl", "kbarycenters.jl"]
```

gha_language: Julia

gha_license_id: NOASSERTION


text:
## What's mongoose-attachments?

Mongoose-Attachments is an attachments plugin for [Mongoose.js](http://mongoosejs.com/). Supports [Amazon S3](http://aws.amazon.com/es/s3/) out-of-the-box and ImageMagick transformations styles.

### Installation

    $ npm install mongoose-attachments

### Usage

The following example extens the 'Post' model to use attachments with a property called 'image' and three different styles.

    var mongoose = require('mongoose');
    var attachments = require('mongoose-attachments');
    var PostSchema = new mongoose.Schema({
      title: String,
      description: String
    });

    PostSchema.plugin(attachments, {
      directory: 'achievements',
        storage: {
          providerName: 's3',
          options: {
          key: '<key>',
          secret: '<secret>',
          bucket: '<bucket>'
        }
      },
      properties: {
        image: {
          styles: {
            original: {
              // keep the original file
            },
            small: {
              resize: '150x150'
            },
            medium: {
              resize: '120x120'
            },
            medium_jpg: {
              '$format': 'jpg' // this one changes the format of the image to jpg
            }
          }
        }
      }
    });

    var Post = mongoose.model('Post', PostSchema);

#### Using with Express.js uploads

Assuming that the HTML form sent a file in a field called 'image':

    app.post('/upload', function(req, res, next) {
      var post = new mongoose.model('Post')();
      post.title = req.body.title;
      post.description = req.body.description;
      post.attach('image', req.files.image, function(err) {
        if(err) return next(err);
        post.save(function(err) {
          if(err) return next(err);
          res.send('Post has been saved with file!');
        });
      })
    });

#### Using with an stand-alone app files

    var post = new mongoose.model('Post')();
    post.title = 'Title of the Post';
    post.description = 'Description of the Post';
    post.attach('image', {
        path: '/path/to/the/file.png'
      }, function(err) {
        if(err) return next(err);
        post.save(function(err) {
          if(err) return next(err);
          console.log('Post has been Saved with file');
        });
    })

### Metadata

When mongoose-attachments is used with images, it can provide basic information for each one of the specified styles:

Example:

    {
      "dims" : {
        "w" : 120,
        "h" : 103
      },
      "depth" : 8,
      "format" : "PNG",
      "oname" : "dragon.png",
      "mtime" : ISODate("2012-05-22T06:21:53Z"),
      "ctime" : ISODate("2012-05-22T06:21:53Z"),
      "size" : 26887,
      "path" : "/achievements/4fbaaa31db8cec0923000019-medium.png",
      "defaultUrl" : "http://gamygame-dev.s3.amazonaws.com/achievements/4fbaaa31db8cec0923000019-medium.png"
    }

### Styles and ImageMagick Transformations

Transformations are achieved by invoking the **convert** command from ImageMagick and passing all the properties of the style as arguments.

For more information about convert, take a look at http://www.imagemagick.org/script/command-line-options.php

Example in convert command:

    convert source.png -resize '50%' output.png

Example in plugin options:

    styles: {
      small: {
        resize: '50%'
      }
    }

#### Keeping the Original File

    styles: {
      original: {
        // no transformations
      }
    }

#### Multiples Transformations

Use another properties under the style to provide more transformations

    styles: {
      small: {
        crop: '120x120',
        blur: '5x10' //radius x stigma
      }
    }

More information about 'blur' at the [ImageMagick website] http://www.imagemagick.org/script/command-line-options.php#blur

#### Changing the Destination Format

You can change the destination format by using the special transformation '$format' with a known file extension like *png*, *jpg*, *gif*, etc.

Example:

    styles: {
      as_jpeg: {
        '$format': 'jpg'
      }
    }

Note: **DO NOT** include the dot in the extension.

### Contributors

* [Johan Hernandez](https://github.com/thepumpkin1979)
* [Chantal Ackermann](https://github.com/nuarhu)

## License (MIT)

Copyright (c) 2011 Firebase.co - http://firebase.co

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


text:
---
title: How to split a string in Java
date: "2019-12-17"
tags: ['java','string','split']
template: post
---

To split a string we need to use the `String.split()` method by passing a regular expression as an argument in Java.

Here is an example which splits the string by a delimiter dot `.`

```java
String name = "code.examples";

String[] output = name.split("\\."));

System.out.println(output[0]);
System.out.println(output[1]);
```

Output:

```java
code
examples
```

>Note: The period/dot is a special character in regex so that we have used double backslashes (`\\`) to escape it.

Other example:

```java
String phone = "1334-345-5465";

String[] output = phone.split("-");

System.out.println(output[0]);
System.out.println(output[1]);
System.out.println(output[2]);
```

Output:

```java
1334
345
5465
```


text:
# Find the nearest fraction in the E24 numbers

This program is by Takayuki Hosoda (alias Lyuka) and is used here by permission.

Please visit [_Lyuka's_ personal Website](http://www.finetune.co.jp/~lyuka/technote/e24/e24-35s.html)
and the Wikipedia Page [E series of preferred numbers](https://en.wikipedia.org/wiki/E_series_of_preferred_numbers#Overview)
for more information.

## Program usage

The input value must be in the REGX register.

The output values (Vector format) are in REGY and REGX.

- REGY = next candidate: [numerator, denominator, error]
- REGX = nearest E24 pair: [numerator, denominator, error]

### Load program

```
XEQ E ENTER
```

### Example

```
9.6774
XEQ E ENTER
```
```
RUNNING
```
```
[16.000, 1.6000, 0.0323]
[15.e0, 1.6e0, 32.256e-3]
```

## Listing

The following variables are used:

- R00-23 = E24 series
- I = index I
- J = index J
- K = offset
- N = normalized value
- P = previous error
- Q = previous candidate
- R = answer
- S = scaled numerator
- X = scaling factor

Command line options

```
perl -Ilib asm2hpc.pl --jumpmark --plain --file=examples/3rd-party/E24/E.asm > examples/3rd-party\E24\E.txt
perl -Ilib asm2hpc.pl --jumpmark --shortcut --unicode --file=examples/3rd-party/E24/E.asm > examples/3rd-party/E24/E.35s
```


text:
pomelo-logger-es6
========

pomelo-logger-es6 is a [log4js](https://github.com/nomiddlename/log4js-node) wrapper for [pomelo](https://github.com/NetEase/pomelo) which provides some useful features.

## 和pomelo-logger的关系

1. pomelo-logger-es6是pomelo-logger根据最新规范和模块所写

## Installation

```
npm install pomelo-logger-es6
```

## Features

### log prefix
besides category, you can output prefix as you like in your log
prefix can be filename, serverId, serverType, host etc
to use this feature, you just pass prefix params to getLogger function
```
const logger = require('pomelo-logger-es6').getLogger(category, prefix1, prefix2, ...);
```
 log output msg will output with prefix ahead

### get line number in debug
when in debug environment, you may want to get the line number of the log
to use this feature, add this code
```
process.env.LOGGER_LINE = true;
```

in pomelo, you just configure the log4js file and set **lineDebug** for true
```
{
  "appenders": {
  },

  "category": {
  },

  "lineDebug": true
}
```

### log raw messages
in raw message mode, your log message will be simply your messages, no prefix and color format strings
to use this feature, add this code
```
process.env.RAW_MESSAGE = true;
```

in pomelo, you just configure the log4js file and set **rawMessage** for true
```
{
  "appenders": {
  },

  "levels": {
  },

  "rawMessage": true
}
```

## Example

``` json
{
  "appenders": {
    "console": {
      "type": "console"
    },
    "rpc-log": {
      "type": "file",
      "filename": "./logs/rpc-log-${opts:serverId}.log",
      "maxLogSize": 1048576,
      "backups": 5
    }
  },
  "categories": {
    "default": {
      "appenders": [
        "console"
      ],
      "level": "debug"
    },
    "rpc-log": {
      "appenders": [
        "rpc-log",
        "console"
      ],
      "level": "error"
    }
  },
  "rawMessage": false,
  "lineDebug": true
}
```

log.js
```
require('pomelo-logger-es6').configure(require('./log4js.json'), {serverId: 'dummy'});
const logger = require('pomelo-logger-es6').getLogger('rpc-log', __filename, process.pid);

process.env.LOGGER_LINE = true;
logger.info('test1');
logger.warn('test2');
logger.error('test3');
```

MIT License

Copyright (c) 2019 wangkunmeng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

 IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


text:
# twitter-sent-dnn
Twitter Sentiment Analysis using Convolutional Neural Network(CNN)

## What is it

A web app that allows to:

- predict sentiment "positiveness" for tweets
- gain an overview of the "positiveness" of [hashtags](https://support.twitter.com/articles/49309-using-hashtags-on-twitter#)

## Demo

Click [here](https://twitter-sentiment-cnn.herokuapp.com/)

## Algorithm

Please refer to [A Convolutional Neural Network for Modelling Sentences](http://nal.co/papers/Kalchbrenner_DCNN_ACL14) for more information about the algorithm.

## Technical choices

- [Tornado](http://www.tornadoweb.org/en/stable/) as the web framework
- [Theano](http://deeplearning.net/software/theano/) as the neural network training implementation
- [Scipy](http://www.scipy.org/) as the neural network classification(online version) implementation

## Training techniques

1. Fan-in, fan-out initialization
2. Dropout
3. AdaDelta

## Contributors
Han Xiao and Yao Lu

repository: hotpxl/nebuchadnezzar

repo_name: hotpxl/nebuchadnezzar


text:
# proxy_layout

[![pub package](https://img.shields.io/pub/v/proxy_layout.svg)](https://pub.dartlang.org/packages/proxy_layout)

Package to select layout per orientation or device size like mobile vs tablet layouts or portrait vs landscape

## Usage

You have two widgets at your disposal, `DeviceProxy` to use different widget for mobile and tablet devices, `OrientationProxy` to use different device depending of the device orientation.

### DeviceProxy

```dart
DeviceProxy(
        mobileBuilder: (context) => Text('Mobile widget'),
        tabletBuilder: (context) => Text('Tablet widget'),
      ),
```

The threshold to separate Mobile and Tablet devices is 600, you can override it by setting the `threshold` attribute.

If you don't want to specify mobile and tablet you can use `builder` attribute that will let you know if you are on tablet or mobile with `DeviceProxyType` enum.

The is `isMobile` and `isTablet` static methods available if you need to know at some point the device type to tweak some attributes.

### OrientationProxy

```dart
OrientationProxy(
          landscapeBuilder: (context) => Text('Landscape widget'),
          portraitBuilder: (context) => Text('Portrait widget'),
        ),
```

If you don't want to specify portrait and landscape you can use `builder` attribute that will let you know which orientation you are with `DeviceOrientationType` enum.

The is `isPortrait` and `isLandscape` static methods available if you need to know at some point the orientation to just tweak some attributes.

### LayoutProxy
LayoutProxy help you manage device and orientation at once, check this out:

```dart
LayoutProxy(
          tabletPortraitBuilder: (context) => Text('Tablet portrait widget'),
          tabletLandscapeBuilder: (context) => Text('Tablet landscape widget'),
          mobilePortraitBuilder: (context) => Text('Mobile portrait widget'),
          mobileLandscapeBuilder: (context) => Text('Mobile landscape widget'),
        ),
```

The threshold to separate Mobile and Tablet devices is 600, you can override it by setting the `threshold` attribute.

gha_language: Dart


text:
---
layout: post
title: "An Overview of Troubling Trends in Machine Learning Scholarship"
author: billy_rick
excerpt: "A new paper presented in ICML 2018 describes some of the troubling trends in machine learning (ML) scholarship."
modified:
comments: true
tags: [ML]
image:
  thumb: ml_troubling_trends.png
---

![](https://miro.medium.com/max/1400/1*LWxe_m9JnLIrZhHJnEOiBQ.png)

\\
A new [paper](https://arxiv.org/abs/1807.03341) presented in ICML 2018 describes some of the troubling trends in machine learning (ML) scholarship. The authors, Zachary C. Lipton and Jacob Steinhardt, discuss the implications of these trends on the field of ML and the proper distilling of machine learning research and knowledge.

\\
Machine learning (ML) research aims to disseminate knowledge about data-driven algorithms through theoretical characterizations and or empirical results. The field of ML is growing rapidly, at an unprecedented scale and speed, with certain troubling patterns emerging which could negatively affect meaningful progress in the field, **poorly serving to researchers and enthusiasts.

\\
ML research is most valuable when communicated properly to the interested reader by avoiding the presentation of speculations as facts and other misleading interpretations and explanations. Lipton and Steinhardt propose several ways to combat some of the troubling trends occurring in the ML community, particularly as it relates to the poor dissemination of foundational knowledge and empirical results. The overall goal is to communicate research and findings with greater clarity and to pay closer attention to the following troubling patterns:

### **Explanation vs. Speculation**

In writing, speculation encompasses a whole range of techniques used to explain concepts and intuitions without providing proper evidence or formal definitions. For example, we claim that X produces Y given some conditions Z. We know X and Y to be true, but we don’t know if all conditions Z apply because we haven’t formally defined them. Yet we claim that all conditions Z seem to work even when we haven’t defined them properly. Just because the reader isn’t aware or doesn’t care about all Zs it doesn’t mean the claim warrants validity — *it’s “explanation disguised as speculation.”*

\\
This is a risky form of science communication since other researchers may blindly use them as facts in their work, further increasing the severity and reach of the initial speculation. It’s important to avoid asserting speculations as facts and explicitly separating them from facts when using them. (See actual examples in the paper)

![](https://miro.medium.com/max/1120/0*DmfsfA-JCsWXi7Pn.png)

### **Failure to Identify the Sources of Empirical Gains**

Sometimes ML researchers propose complex models that combine several techniques to address a problem. Even though the proposed approach does well, authors sometimes fail to identify the source/s of empirical gains.
The problem is that this may generate a false impression that the authors did a lot of work when in reality the improvements were incremental and only occurred due to a small change. This can sometimes be minimized and clarified by performing proper ablation studies. (See more examples in the paper)
\\
![](https://miro.medium.com/max/752/0*m5KmxuY3L0zw0SWo.png)

### **Mathiness**

Mathiness is a concept proposed by economist Paul Romer that describes the idea of using both natural language and mathematics to explain concepts but failing to provide tight links between statements and symbols. Mathiness manifests in many ways such as authors trying to pile math equations to convey technical depth without proper explanations and linkings.
The problem with this approach is that clarity suffers, distracting the readers from acquiring the important knowledge and insights of the research. The best remedy seems to be avoiding the use of mathiness and providing clear explanations of the formulations so that it benefits all kinds of readers and not just ML researchers.
\\
![](https://miro.medium.com/max/752/0*cd3SbJbw0cqseDP4.png)

### **Misuse of Language**

Lipton and Steinhardt currently identified three types of language misuse in machine learning research: *suggestive definitions*, *overloaded terminology*, and *suitcase words*. Let’s briefly describe the three below:

- ***Suggestive definitions*** — This occurs when authors coin suggestive terms that convey human qualities (i.e., anthropomorphic characterizations) such as “thought vectors.” These type of terms are not necessarily bad but if not qualified may only confuse readers.
- ***Overloaded terminology*** — This refers to the inappropriate or contradictory use of a technical term that already holds a very precise meaning in the literature. An example is the misuse of the term “deconvolution” to refer to transpose convolution as opposed to “reversing a convolution” which is what it originally describes.
- ***Suitcase words*** — This refers to terms that may pack many different meanings, often creating a confusion to readers with different backgrounds. These type of words could also manifest in the form of suggestive definitions and overloaded terminology as explained above. Some notorious examples include “generalization”, “interpretability”, and “bias.” Loosely using these type of words is common practice but often detracts and confuse readers.
\\
![](https://miro.medium.com/max/752/0*zIrt9rR0W6DGzBYA.png)

### **Potential Causes Behind Troubling Trends**

Lipton and Steinhardt also discuss the potential causal factors to these troubling trends in ML scholarship:

- **Complacency in the face of progress** — This describes the notion that authors feel entitled to make weak arguments because they are already providing strong results. This poses a problem since reviewers may feel pressured to accept potentially flawed papers only to compensate for the quantitative findings.
- **Growing pains** — ML is expanding rapidly and thus increases the entrance of inexperienced researchers which are more susceptible to the misuse of language. This is not to say that experienced researchers cannot fall into these patterns, especially when their reviewing responsibilities increase with the rapid growth of the field. This is not to discourage junior researchers, but spreading awareness of these issues is key to conducting proper research.
- **Misaligned incentives** — As ML becomes more popular, both the media and startup investors seek to provide incentives for things which may not be aligned with the objectives of the field. For instance, anthropomorphic descriptions, such as “simulated brain”, may be effective for popular coverage but could actually cause confusion in the ML community and literature.
![](https://miro.medium.com/max/752/0*hF1JDenZ0JdCUNkL.png)

### **Suggestions**

Besides recommending that authors — experienced and inexperienced — refrain from participating in these trends, Lipton and Steinhard outline a few preliminary suggestions:

- **What, Why, How** — Identify “what worked” and provide clear details explaining “why it worked”, and not just “how well it worked.”
- **Insights** — Authors are encouraged to provide error analysis, ablation studies, and robustness check. Besides identifying empirical gains, authors can also discuss insights with strong evidence to support them.
- **Writing tips** — Authors are recommended to revise important questions and theorems reported in the research, with clarity, flow, and precision in mind. Open problems can also be separated from closed ones when offering discussions to avoid confusion and to encourage follow-up research. Other suggestions are also provided for publishers and reviewers. (See paper for more details)
![](https://miro.medium.com/max/752/0*879_wpeyAGluJXTj.png)

\\
Overall, it’s important to avoid the use of confusing terminology (e.g. anthropomorphic characterization) and unsupported claims. Greater rigor is essential for the healthy growth of ML scholarship and scientific progress more broadly. There are special cases where the recommendations set forth above may actually hurt the fast pace of research. In some cases, original ideas may even be impeded. However, historically speaking, undisciplined scholarship affects both researchers and the public, which means there could potentially emerge a crisis and a “lack of meaningful progress.”

### **Final Words From the Editor**

\\
Machine learning has grown tremendously over the past few years and it promises to be at the epicenter of “everything technology.” It’s the responsibility of everyone — researchers, students, reviewers, industry, startups, lawmakers, and everyone involved — to participate in the debate and to ensure the proper distilling of machine learning research and knowledge in a transparent and accurate way. We are responsible for guiding the conversation in the right direction and to avoid harming the ML field and science more broadly.

----------

*Ref:* [https://arxiv.org/abs/1807.03341](https://arxiv.org/abs/1807.03341) — “Troubling Trends in Machine Learning Scholarship” — Zachary C. Lipton and Jacob Steinhardt

gha_language: HTML


text:
# Space images search-engine
Retrieving Images and Automatically saving various random beautiful space/astronomy images from a database server using Python 2.7.10
```
Different types of search mechanism:

1. Random search [working]
2. Keyword-based search [not-working at present]
```
```
Execution:

For random-search:

Run hubble.py using Git or Python interpreter or anything that runs Python.
This was tested Python 2.7.10 [Latest]
Note: Oh! Turn on your internet connection while trying it.
For picking random numbers, choose from 0 to 14.
Currently, only 17 images are in the database.
Download image numbers start from 0. So it's 0 to 16 images at present.
Programmers/Developers love including 0, right? lol
Loading more images are in-progress.
Sooner, I am aiming to load more than 1000 images if possible, not just from Hubble.

Run space-planets.py using Git or Python interpreter or anything that runs Python.
This was tested Python 2.7.10 [Latest]
Note: Oh! Turn on your internet connection while trying it.
For picking random numbers, choose from 0 to 1.
Currently, only 2 images are in the database.
Loading more images are in-progress.
Sooner, I am aiming to load more images.
```
Release:
There will be a release sooner with good enhancements.

For now, this is a pre-release.
***
Contributions:

If interested to send more space images along with it's name and telescope used for capturing and year...

(or details links)

then mail me to ashumeow[at]live[dot]com

repository: ashumeow/random-space-images

gha_language: Python

repo_name: ashumeow/random-space-images


text:
# Cyber Issue Scoring for Exploit, Malware, and Vulnerability (EMV)

<!-- Last Updated 11/10/2020 -->
Version 0.0.1

EMV was presented at BSides Idaho (https://www.bsidesidaho.org/) on October 23, 2020. A video recording of the presentation is found below.

[![STIG Video](/images/bsides.png)](https://www.youtube.com/watch?v=_qEseoPgdec)

<img align="right" width="260" src="/images/EMV_rev1.png"> Exploit, Malware and Vulnerability (EMV) is a tool used for scoring cyber issue against various hardware configurations and compare that score against other scored issues for prioritization and trending over time.

See the [EMV Innovation Sheet](EMV_INL_Innovation_Sheet2019.pdf) for an overview.

There are a large number of potential exploits, malware, and vulnerabilities (EMV) that can be used to attack control systems on critical infrastructure.  Exploits and malware represent the offense aspects and vulnerabilities represent the maintenance aspects of the challenge. Successfully protecting a control system against these attacks requires a structured process for identifying, evaluating, prioritizing, and addressing EMVs. EMV Scoring is needed since other scoring methodologies do not include: Exploits and Malware; applicability to a specific configuration; defense capabilities; consequence; or other adversary factors. A benefit of processing through the EMV Scoring process is the identification of potential threat object characteristics that can be used for automated response.

Idaho National Laboratory (INL) participated as a team member with Southern California Edison on the California Energy Systems for the 21st Century (CES-21) Program and has refined these concepts with the asset owner's point of view to prioritize EMV based on their operational knowledge of the system under protection, sometimes with a limited knowledge of the adversary, but a full understanding of the utilities' ability to defend against potential consequences including the consideration of the asset owner's risk tolerances. This EMV prioritization enables a scored ranking of issues to be addressed. CES-21 uses EMV to determine the creation of indicator and remediation language in automated response technologies, providing for agile response capabilities within substation automation environments.

## Installation

Select an operating system for installation instructions. Newer versions may be available but have not been tested.

[Linux .deb (Ubuntu 16.04.5)](#linux-.deb-(ubuntu-16.04.5-lts))

[Linux .rpm (Centos 7)](#linux-.rpm-(centos-7))

[Windows 7 64 bit](#windows-7-64-bit)

[Mac OS X (Mojave)](#mac-os-x-(mojave))

### Linux .deb (Ubuntu 16.04.5 LTS)

#### Update and Install Dependencies

Open a terminal and run the following commands to update the system and install dependencies:
```
sudo apt update
sudo apt upgrade
sudo apt install curl build-essential checkinstall libssl-dev git
```
#### Install nvm

Install nvm repository using the following:

`curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash`

Close and re-open the terminal. Run the following command to view available nvm versions:
`nvm ls-remote`

Install the latest version of node (14.3.0 was the latest at the time of this writing):

`nvm install 14.3.0`

#### Install yarn

Install the yarn package manager. In a terminal window, issue the following commands:

```
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee -a /etc/apt/sources.list.d/yarn.list

sudo apt update && sudo apt install yarn
```

#### Install Java

Install Java for OrientDB (11.0.7 at the time of this reading):

```
sudo apt install default-jre
```

#### Install OrientDB and Configure as a Service

The CIS Application has been tested using OrientDB v3.0.31. New versions may be available, but have not been tested. Download version 3.0.31 by issuing the following command in a terminal window.
```
wget https://s3.us-east-2.amazonaws.com/orientdb3/releases/3.0.31/orientdb-3.0.31.tar.gz -O orientdb-community-3.0.31.tar.gz
```

Navigate to the tar file and extract the files. This assumes the downloaded file is in the Downloads folder. In a terminal:

```
cd ~/Downloads
tar -zxvf orientdb-community-3.0.31.tar.gz
```

Move the extracted files to the /opt directory.
`sudo mv ~/orientdb-community-3.2.31 /opt/orientdb`

Start the OrientDB server.
```
cd /opt/orientdb
sudo bin/server.sh
```
You will be prompted to create a password for the root user. Use "OrientPW". If you chose something else previously, then modify line 205 in the following file: src/app.tsx

Configure OrientDB to run as a Service. Open a new terminal window and issue the command:

`sudo useradd -r orientdb -s /sbin/nologin`

Change the ownership of OrientDB

`sudo chown -R orientdb:orientdb /opt/orientdb`

You will need to make a few changes to the orientdb.sh script

`sudo nano /opt/orientdb/bin/orientdb.sh`

Change the directory and user as follows:
```sh
ORIENTDB_DIR="/opt/orientdb"
ORIENTDB_USER="orientdb"
```
Save and close the file (`ctrl-x` then `y`).

Copy the Systemd service
`sudo cp /opt/orientdb/bin/orientdb.service /etc/systemd/system`

You will need to make settings changes as follows:
`sudo nano /etc/systemd/system/orientdb.service`

Modify the User, Group, and ExecStart commands
```sh
[Service]
User=orientdb
Group=orientdb
ExecStart=/opt/orientdb/bin/server.sh
```
Save and close the file (`ctrl-x` then `y`).

Reload the daemon
`sudo systemctl daemon-reload`

Start the Service

`sudo systemctl start orientdb`

Enable the service to start on boot
`sudo systemctl enable orientdb`

#### Extract EMV Application files

Download EMV from git:
`git clone http://<IP_ADDRESS>/ces21/emv.git`

Navigate to the EMV folder, run the following:
```shell
npm install
npm start
```
`npm install` is only needed the first time the CIS application is run to install dependencies, or if you update a dependency.

NOTE: Some linux distributions have a problem with `npm install`. In this case, use `yarn install` and `yarn start`.

Login to the EMV Application using the username: `admin` and password: `admin`

NOTE: The OrientDB service needs to be running for the CIS application to connect to the database.

#### (Optional): Build and Executable

Open a terminal and navigate to the EMV directory. Run the following: ==UPDATE==

`yarn make`

The package(s) for your platform will be found in "out/make". The binary can be found in "out/EMV-{platform}/EMV".

### Linux .rpm (Centos 7)

#### Install Dependencies

Open a terminal and run the following commands to update the system and install dependencies:
```
sudo yum install update
sudo yum install git libXScrnSaver
```
#### Install nvm

Install nvm repository using the following:

`curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`

Close and re-open the terminal. Check the nvm version to make sure the install worked.

`nvm --version`

Run the following command to view available nvm versions:

`nvm ls-remote`

Install the latest LTS version by running the following (8.12.0 was the latest at the time of this writing):

`nvm install 8.12.0`

#### Install yarn

Install the yarn package manager. In a terminal window, issue the following commands:

```
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install yarn
```
Check the version of yarn to verify the installed
`yarn --version`

#### Set Java Environment Variables

Configure the java environment.
`update-alternatives --config java`

Create a java profile 'java.sh' in the /etc/profile.d/ directory.
`sudo vim /etc/profile.d/java.sh`

Enter the following to configure java:
```sh
#Setting JAVA_HOME in PATH
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH
```

Make the file executable.
```
sudo chmod +x /etc/profile.d/java.sh
source /etc/profile.d/java.sh
```

Check the java environment to verify the PATH setting.
`echo $JAVA_HOME`

#### Install OrientDB and Configure as a Service

The CIS Application has been tested using OrientDB v2.2.20. New versions may be available, but have not been tested. Download OrientDB by issuing the following command in a terminal:

`wget -O orientdb-community-2.2.20.tar.gz http://orientdb.com/download.php?file=orientdb-community-2.2.20.tar.gz&os=linux`

Untar the downloaded file:
`tar -zxvf orientdb-community-2.2.20.tar.gz`

Move the extracted files to the /opt directory.
`sudo mv ~/orientdb-community-2.2.20 /opt/orientdb`

Start the OrientDB server. NOTE: use the following for the username and password: root/OrientPW
```
cd /opt/orientdb
sudo bin/server.sh
```
You will be asked to create a password for the root user. Use "OrientPW". ==Need to include additional instructions to create unique password==

Configure OrientDB to run as a Service

Open a new terminal window

`sudo useradd -r orientdb -s /sbin/nologin`

Change the ownership of OrientDB

`sudo chown -R orientdb:orientdb /opt/orientdb`

Make a few changes to the orientdb.sh script

`sudo nano /opt/orientdb/bin/orientdb.sh`

Change the directory and user as follows:
```sh
ORIENTDB_DIR="/opt/orientdb"
ORIENTDB_USER="orientdb"
```
Save and close the file.

Copy the Systemd service

`sudo cp /opt/orientdb/bin/orientdb.service /etc/systemd/system`

Make settings changes as follows:

`sudo nano /etc/systemd/system/orientdb.service`

Modify the User, Group, and ExecStart commands
```sh
[Service]
User=orientdb
Group=orientdb
ExecStart=/opt/orientdb/bin/server.sh
```
Reload the daemon

`sudo systemctl daemon-reload`

Start the Service

`sudo systemctl start orientdb`

Enable the service to start on boot

`sudo systemctl enable orientdb`

#### Extract EMV Application files

Download the EMV.tar.gz archive to your machine. ==Need to update with actual link to download file==

Navigate to the tar file and extract the files. This assumes the downloaded file is in the Downloads folder. In a terminal:

```
cd ~/Downloads
tar -zxvf EMV.tar.gz
```

Navigate to the EMV folder, run the following:
```
npm install
npm start
```
`npm install` is only needed the first time the CIS application is run to install dependencies, or if you update a dependency.

NOTE: Some linux distributions have a problem with `npm install`. In this case, use `yarn install` and `yarn start`.

Login to the EMV Application using the username: `admin` and password: `admin`

NOTE: The OrientDB service needs to be running for the EMV application to connect to the database.

#### (Optional): Build and Executable

Open a terminal and navigate to the EMV directory. Run the following: ==UPDATE==

`yarn make`

The package(s) for your platform will be found in "out/make". The binary can be found in "out/EMV-{platform}/EMV".

### Windows 7 64-bit

#### Install Git

Download and run the git installer from here:
https://git-scm.com/download/win

#### Install node.js

Download the run node.js installer from here:
https://nodejs.org/en/download/

Update npm to avoid issues with dependencies. Open Command Prompt and run the following command:
```
npm i npm@latest -g
```

#### Install yarn

Download and run the yarn installer from here: https://yarnpkg.com/lang/en/docs/install/#windows-stable

#### Install Java

Download and run the Java8 JDK installer from here:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

#### Install OrientDB

The EMV Application has been tested using OrientDB v2.2.20. New versions may be available, but have not been fully tested.

Download orientdb-community-2.2.20 from: https://bit.ly/2r1YBMi

Extract the .zip file to the C: drive. Navigate to `c:\orientdb-community-2.2.20\bin`

Run `orientdb.bat`

You will be asked to create a password for the root user. Use "OrientPW". ==Need to include additional instructions to create unique password==

#### Configure Orientdb as a service

Follow the instructions at https://orientdb.com/docs/2.2.x/Windows-Service.html to install OrientDB as a service.

#### Extract EMV Application files

Copy the EMV.tar.gz archive to your machine and unarchive to `c:\`.

NOTE: Run the unarchiving tool as administrator.

Open a command prompt as Administrator and navigate to the EMV folder, run the following:
```
yarn install
yarn start
```
NOTE: `yarn install` is only needed the first time the CIS application is run to install dependencies, or if you update a dependency.

Login to the EMV Application using the username: `admin` and password: `admin`

NOTE: The OrientDB service needs to be running for the EMV application to connect to the database.

#### (Optional): Build and Executable

Open a terminal and navigate to the EMV directory. Run the following: ==UPDATE==

`yarn make`

The package(s) for your platform will be found in "out/make". The binary can be found in "out/EMV-{platform}/EMV".

### Mac OS X (Mojave)

#### Install Homebrew

Install Homebrew from https://brew.sh

#### Install Dependencies

Open a terminal window and issue the following commands:

```
brew install wget
brew install node
brew install yarn --without-node
brew upgrade yarn
```

Verify that git is installed by running the following command:
```
git --version
```

NOTE: If git is not installed, you will be prompted to install it.

#### Install Java 8 JDK

Download and run the the `Mac OS X x64` installer from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

#### Install OrientDB

Follow the instructions at https://orientdb.com/docs/2.2.x/Unix-Service.html to install OrientDB using homebrew and to change a root password. User `OrientPW` for the new root password. ==need instructions on how to select unique password==

#### Extract EMV Application files

Download the EMV.tar.gz archive to your machine. ==Need to update with actual link to download file==

Navigate to the tar file and extract the files. This assumes the downloaded file is in the Downloads folder. In a terminal:

```
cd ~/Downloads
tar -zxvf EMV.tar.gz
```

Navigate to the EMV folder, run the following:
```
yarn install
yarn start
```

`yarn install` is only needed the first time the CIS application is run to install dependencies, or if you update a dependency.

NOTE: Some distributions have a problem with `yarn install`. In this case, use `npm install` and `npm start`.

Login to the EMV Application using the username: `admin` and password: `admin`

NOTE: The OrientDB service needs to be running for the EMV application to connect to the database.

#### (Optional): Build and Executable

Open a terminal and navigate to the EMV directory. Run the following: ==UPDATE==

`yarn make`

The package(s) for your platform will be found in "out/make". The binary can be found in "out/EMV-{platform}/EMV".

## Advanced Customization

For instructions on editing the criteria set or configurations see Advanced_Customization.md.

## Encrypting Communication

Please follow the instructions provided: https://www.orientdb.com/docs/3.0.x/security/Using-SSL-with-OrientDB.html
You will also have to change any connections to the server from port 2424 to 2434.

NOTE: Some machine's might experience issues with a self signed certificate, to which you can add a line: process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';.  This fix is fairly unsecure (as it opens up the application to untrusted sources), should be temporary and extended to something more secure.

## Known Issues

- NPM might have outdated packages. This application was built with static versions from npm. If a package is updated, it has the potential to cause issues.
- This application was designed around a single-user system.
- It is assumed that the OrientDB database and EMV application will reside on the same machine. Security concerns exist if the database is moved to another machine as the communication between electron-forge and orientdb is unencrypted.1

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## Licensing

See COPYRIGHT.md and LICENSE.md for copyright and licensing information.

repository: filin-dev/EMV

repo_name: filin-dev/EMV


text:
# Dnsmasq configuration files for Pi-hole

This repo contains

> Dnsmasq configuration files to stop tracking and advertisements, especially on mobile applications

from [javabean/dnsmasq-antispy](https://github.com/javabean/dnsmasq-antispy), formatted for the [Pi-hole](https://pi-hole.net).

repository: michaeldimoudis/dnsmasq-antispy-pihole

repo_name: michaeldimoudis/dnsmasq-antispy-pihole