teleren/devto huggingface dataset:
Open Source Process Manager for Node.js 
Tags: javascript, opensource, node, webdev
Published: 2022-01-28 15:59:19

## [PM2](https://github.com/Unitech/pm2)
<span><strong><i class="fa fa-star">Star 36.4k</i> <i class="fa fa-eye">Watch 667</i> <i class="fa fa-code-fork">Fork 2.4k</i></strong></span>


PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

PM2 is constantly assailed by more than 1800 tests.

[Official website](https://pm2.keymetrics.io/)

Works on Linux (stable) & macOS (stable) & Windows (stable). All Node.js versions are supported starting Node.js 12.X.

## Managing Applications
Once applications are started you can manage them easily:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jfaswi15wt0ljdcghnyb.png)
To list all running applications:
```shell
$ pm2 list
```
Managing apps is straightforward:
```shell
$ pm2 stop     <app_name|namespace|id|'all'|json_conf>
$ pm2 restart  <app_name|namespace|id|'all'|json_conf>
$ pm2 delete   <app_name|namespace|id|'all'|json_conf>
```
To have more details on a specific application:
```shell
$ pm2 describe <id|app_name>
```
To monitor logs, custom metrics, application information:
```shell
$ pm2 monit
```

## Cluster Mode: Node.js Load Balancing & Zero Downtime Reload
The Cluster mode is a special mode when starting a Node.js application, it starts multiple processes and load-balance HTTP/TCP/UDP queries between them. This increase overall performance (by a factor of x10 on 16 cores machines) and reliability (faster socket re-balancing in case of unhandled errors).
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rusoj9k7pp5by01huzts.png)

Starting a Node.js application in cluster mode that will leverage all CPUs available:
```shell
$ pm2 start api.js -i <processes>
```
`<processes>` can be `'max'`, `-1` (all cpu minus 1) or a specified number of instances to start.

**Zero Downtime Reload**
Hot Reload allows to update an application without any downtime:
```shell
$ pm2 reload all
```

## Host monitoring speedbar
PM2 allows to monitor your host/server vitals with a monitoring speedbar.

To enable host monitoring:
```shell
$ pm2 set pm2:sysmonit true
$ pm2 update
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trdf8tu5vq7dxl36q8tm.png)

## Terminal Based Monitoring
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjur1ccgeqpz4fplqynf.png)
Monitor all processes launched straight from the command line:
```shell
$ pm2 monit
```

## PM2+ Monitoring
If you manage your apps with PM2, PM2+ makes it easy to monitor and manage apps across servers.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jixtcs2yb4a1yfygb9pg.png)
Feel free to try it:
[Discover the monitoring dashboard for PM2](https://app.pm2.io/)
Thanks in advance and we hope that you like PM2!

## License
PM2 is made available under the terms of the GNU Affero General Public License 3.0 (AGPL 3.0).
Write Interactive Documentation with Templates and Parameters
Tags: documentation, productivity, javascript, markdown
Published: 2022-01-28 15:58:33


Let's say you want to do a local port forwarding via SSH, but you don't remember the command. You do a quick search on google and find something like this:

```sh
ssh -L 8080:localhost:80 user@10.20.30.40
```

But, in your case, the SSH server doesn't run on the standard port, so you have to specify the custom port. You do another quick search and assemble the full command (in your head or in a text editor that acts as a buffer):

```sh
ssh -L 8080:localhost:80 user@10.20.30.40 -p 1234
```

Now you have a generic example, and you have to replace the key parts in the command to make it work. So you have to replace the local port, remote port, remote user, remote ip and the SSH port.

A few copy-pastes later and you realize you forgot how it works: *local_port:ip:remote_port* OR *remote_port:ip:local_port* ? Google saves you again:

```sh
ssh -L LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
```

You just spent 10 minutes gathering or refreshing some valuable info. You also spent valuable time on editing or copy-paste parts of the command in order to customize it.

[ReactiveDoc](https://reactivedoc.com/) can help you write documentation with templates and parameters. Why is this useful? Because it saves you a couple of minutes next time you'll want to reuse this command.

Let's start with the basic command as a template:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cw70jgznajdo6uikey7k.jpg)

Add some basic explanation from https://linux.die.net/man/1/ssh and a link to this excellent [resource](https://unix.stackexchange.com/questions/115897/whats-ssh-port-forwarding-and-whats-the-difference-between-ssh-local-and-remot) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzwe48abxh51nzucmw3w.jpg)

Then add a Number Input, and change the label value to "Local Port", variableName to "local_port" and set 8080 as defaultValue, like this: 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbl8x7iwkqf3z1n6zage.jpg)

In the command template, replace 8080 with `{{local_port}}`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0ypjgi51nsga0arr880.jpg)

Now, add a Text Input for the destination IP, then replace 'localhost' in the template with the `{{destination_ip}}` variable:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixhkylcel6p7vwyrfuwj.jpg)

You can extract each command's part as a parameter:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tov09v86sq2uz0h6d4mx.jpg)

Export this document as an HTML page and, next time you want to do a SSH port forward, just open it with any browser, set the parameters, click on the 'copy' button and paste it in a terminal. 2 minutes saved!

You can also share this HTML file with your team (they don't have to install anything to run it - it works in any browser) or host it on a local server as a static page.

[Try ReactiveDoc Now!](https://reactivedoc.com/editor/)
From PHP to Kotlin - Day 3 - Dealing with exceptions
Tags: kotlin, tutorial, beginners, programming
Published: 2022-01-28 15:56:44

---
series: From PHP to Kotlin
---

Previously, our Value object validated that the value was correct. But we used a generic exception, which only lets us put a message.

That may be fine, but in DDD context it's not quite right. The idea is that through folder struture and files that we have, we can get an idea of the domain.

In this case, it's more wise to handle a custom exception. And in the future, we will be able to better control the exceptions in our flow.

So, we're going to change the test that expects the exception and we're going to be more explicit.

``` kotlin
...
internal class YMowerPositionTest
{
...
    @Test
    fun `Should throw exception for invalid values` ()
    {
        assertThrows(InvalidMowerPositionException::class.java) {
            YMowerPosition.build(INVALID_POSITION)
        }
    }
}
```

And to create the exception, we'll use a test for the 
InvalidMowerPositionException.

``` kotlin
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.*
import kotlin.test.Test

private const val POSITION: Int = 4;
private const val MESSAGE: String = "Invalid Y position $POSITION. Only positive values are valid."

internal class InvalidMowerPositionExceptionTest
{
    @Test
    fun `Should be build with custom value`() {
        val exception = assertThrows(InvalidMowerPositionException::class.java) {
            throw InvalidMowerPositionException.withValue(POSITION)
        }

        assertThat(exception.message).isEqualTo(MESSAGE)
    }
}
```

And the code that implements it.

``` kotlin
class InvalidMowerPositionException private constructor (message: String? = null, cause: Throwable? = null) : Exception(message, cause) {
    companion object {
        private const val MESSAGE: String = "Invalid Y position %d. Only positive values are valid."

        @JvmStatic
        fun withValue(value: Int): InvalidMowerPositionException
        {
            return InvalidMowerPositionException(String.format(MESSAGE, value), null)
        }
    }
}
```

This time we've gone faster creating that class. We know a little better how to do it and it's not more complex.

## Tip

If you take a closer look, when creating the message, the test uses a simple concatenation, and the exception a **String.format()**. This is done on purpose to avoid do copy/pasting from test to implementation. This ensures that the result is as expected.

---

## Links and resources

### Exceptions

https://kotlinlang.org/docs/exceptions.html?q=con#exception-classes

---
From PHP to Kotlin - Day 1 - Setting goals
Tags: kotlin, beginners, tutorial, programming
Published: 2022-01-28 15:56:05

---
series: From PHP to Kotlin
---

To switch to another language, you have to learn its structure and rules. But really, to get the best benefit, it's more useful to think about doing an exercise you've solved before using your favorite language and try to solve it using the new one.

Thinking about how to approach the language change, I've done a list of rules so as not to get lost in the transition.

---

### Rules for changing language

- To start with, **find a kata that has varied elements** to test your skills.

- **Use the good practices that you already know** from your usual language and fight to achieve the same. **Never lower the quality!!!**
You may have to rethink certain terms that seemed non-negotiable in your usual language and that are approached differently in the new language... **that mental process of arguing why it is different will give you the deep knowledge of the new language**.

- **Apply TDD with DDD always**. That means that you have to start thinking about how to use the testing framework of that language and then writing the code. As we know, TDD without an structure like DDD is useless. You can do something unreadable but full tested and it's not the goal. **Change the language, not the structure.**

It may seem a bit crude to fight with the testing framework before the code. But if you have decided to change to another language, it's surely because you've already read something about how it's articulated and you've liked what you see,

so now it's time to get serious (from kindness, of course) and see how to set up the tests with the new language. Having different rules may susprise you and will also make you change your mentality.

You will hardly be able to do the same thing the way you are used to... and tests are no exception. In my case I'll use the **mower kata**.

---
Getting out of the comfort zone with Kotlin
Tags: kotlin, beginners, tutorial, programming
Published: 2022-01-28 15:55:23

---
series: From PHP to Kotlin
---

Here we are. Actually I don't want go out of PHP. It gives me great stuff and has a lot of impressive libraries. But if I want to grow, I have to embrace another language and see if I can write the same as makes me happy in PHP.

Essentially, the goal is to see if I have the necessary architecture tools to achieve the same result in another language. With other rules and philosophy.

Having Symfony with Messenger and Doctrine makes my life easy, but.... What if I didn't have this pieces of software?... What if I was in another language with other rules or another reality?.. what would happen?

The first language chosen is... Kotlin!!... Why?... Because is used in Android, server side applications. It shares strong roots with Java, there's a community version of IntelliJ... and because it's hot...


Movement is demonstrated by walking... and that's what we're going to do...
every() and some() methods in JavaScript
Published: 2022-01-28 15:52:00

## The two methods can be used in an array
The every() method is used to determine whether or not all of the array's elements satisfy the given condition.

The some() method is used to determine whether at least one element of the array meets the supplied criterion.

The only difference is that the some() function returns true if any of the predicates are true, but the every() method returns true if all of them are true.

## The some() method is used in this example.

```javascript
function isnumbereven(element) {
	return (element % 2 == 0);
}
	
function print() {
	var arr = [ 4, 3, 13, 43, 58 ];
	
	// cheking if at least one number is even
	var value = arr.some(isnumbereven);
	console.log(value);
}
print();
```
`output: true`

## The every() method is used in this example.

```javascript
function isnumbereven(element) {
	return (element % 2 == 0);
}
	
function print() {
	var arr = [ 4, 3, 13, 43, 58 ];
	
	// cheking if all the number are even
	var value = arr.every(isnumbereven);
	console.log(value);
}
print();
```
`output: false`
How to inject a React app in a Chrome Extension as a Content Script
Tags: react, chrome, extension
Published: 2022-01-28 15:51:08

This is an update to an article I wrote on Medium in 2017 called [How to inject a React app into a Chrome Extension as a content script](https://medium.com/@yosevu/how-to-inject-a-react-app-into-a-chrome-extension-as-a-content-script-3a038f611067). A few people have been interested in it, but it is out of date and the source code needed to be updated for React 17. Find the updated version on GitHub: https://github.com/yosevu/react-content-script.
Open Source Wallpaper Maker
Tags: opensource, javascript, vue, github
Published: 2022-01-28 15:34:24

## [colorfu](https://github.com/pearmini/colorfu)
<span><strong><i class="fa fa-star">Star 246</i> <i class="fa fa-eye">Watch 2</i> <i class="fa fa-code-fork">Fork 32</i></strong></span>


ColorFu is where people can use words, colors, patterns and images to make unique wallpapers to express their feelings or ideas.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/elrdz9qwriuobltar73l.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/csxox6yb003vebj3n7p3.png)

## Why is it
Writing the word "福" (Fu) is the tradition of Chinese New Year, people will write a big "福" on red paper and stick it on the door to express the good expectations of the new year.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wdpf6bsu2zi5muc9cuo.png)
This is a great example that people use words and colors to express their feelings or ideas. And on the other hand, wallpaper is the most common thing we see everyday which should not be cold.

What it if you can use more colors and more words to make wallpapers to express more feelings ? In that way, not only can you make your wallpapers beautiful, but also make them meaningful.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/decoti3rxpcnxduwpej9.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmwog6c5198vmhvzhj6y.png)

## Features
1. There are some interesting color pallettes for you to help you express your feelings.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqh5nq05830qjftornec.png)

2. Extract colors from image.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8l776vk0ysmepf0ue7tp.png)

3. There are some emojis and emoticons for your to boost your imagination.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yoy7iqx1h6bhtqzy84dp.png)

4. Supports multiple devices: PC, phone, pad.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdan0aja19o742ris51r.png)

## License
MIT
Cloud Concepts
Tags: cloud, azure, aws, gcp
Published: 2022-01-28 15:29:00

**_Cloud Types_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6hos9xkr0pta7jwteic.png)
1. Public Cloud:
Here the vendors allow public to use depending on their demand. The customers cannot access hardware or any back end . But they can know in which region the service resides . The vendors will maintain the service . Again the customers can access it anyone round the world if he/she has an internet connection. For example, people use azure portal(vendor) to work with their services 

2. Private Cloud: The resources are not shared to general public. A company creates a their service and keeps it with it's organization and everything is done by them . For example, Microsoft manages their team and company by this private cloud.

3. Hybrid Cloud : Mixed of both Public and Private

Some terms:
1. On demand resourcing: When you need something, you will get that. It is like filling a form and submitting it and then get a verification mail
2. Consumption based: You pay what you use
3. Scalable & agility: Scaling "up and down" to increase or decrease computer powers and to "in and out" means adding more vms or removing them
4. Economy of scale: Cost is reduced for companies
5. High available: Very available throughout regions
6. Flexible & elasticity: You can choose how much and how long you need things without being worried
7. Shared infrastructure: Reduces space for hardware
8. Security: Very much secured


**_Cloud Service Models_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wxhxur43myxdu1jwfai.png)

1. SaaS: You can use the service but cannot change anything. 
For example, Google Gmail

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86b5p82zfowz7yygcft1.png)
2. PaaS: You can get access to the operating system, software but not Vms or others.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hmjtj9vwgmc2a8pafs4.png)

3. IaaS: Can access software, operating system , cm but not hardware.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wd2k0uhi4j6ubpzw6epv.png)

Offers highest level of customization . 

4. DRaaS (Disaster recovery as service)
5. CaaS (Communication recovery as service)
6. MaaS ( Monitoring as a service)
Free Laravel 8 Admin Starter Kit
Tags: laravel, admin, webdev, programming
Published: 2022-01-28 15:13:15

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53d53unbwjsvz2t0npan.png)

## Tech-Admin - Laravel 8 Admin Starter Kit

Today I am going to explain about installing LARAVEL 8 admin starter kit.

## Features

- Mobile Responsive Bootstrap 4 Design
- User Management with Roles
- Role Management
- Permissions Management
- Access Control List (ACL)
- Laravel 8 + Bootstrap 4

I have Explained every step in this video you can watch and try this out, 

{% youtube AQeWj89c6FE %}

The Final Implementation [Github Repository](https://github.com/TechTool-India/techtool-laravel-admin) you can download this and can use it for any project.

Some Final Output Screens are here

![App Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53d53unbwjsvz2t0npan.png)

![App Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pp9vfllktg4gyarwqq84.png)

![App Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijs2pn14sroqt37n6nq9.png)

![App Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5w9yy33y0fspnnl68t0m.png)

![App Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5p71gck63r039mk6jix.png)

Thank You for Reading

Reach Out To me.
[Twitter](https://twitter.com/shanisingh03)
[Instagram](https://www.instagram.com/shanisingh03/)
[TechToolIndia](https://youtube.com/techtoolindia)
Historia do Git
Tags: git, beginners
Published: 2022-01-28 15:12:51

**Breve Historia do git**

O git já começa com uma historia bastante controvérsia e criativa.

O kernel Linux é um projeto de código aberto. Durante os primeiros anos da manutenção do Linux(1991-2002), todas as mudanças eram passadas como patches e arquivos arquivados. Em 2002, o projeto começou a usar um DVCS proprietário chamado BitKeeper.

Em 2005, o relacionamento entre ambos quebrou, e o status de gratuito foi revogado, ou seja, produziram um software com acesso por um tempo e logo depois decidiram o acesso pago. Isso levou a comunidade de desenvolvimento do linux(enfase ao Linus Torvalds, o criador do Linux) a desenvolver seu próprio software com base no que aprenderam com o BitKeeper. Objetivos do novo sistema foram : 

- Velocidade

- Design Simples

- Forte suporte para desenvolvimento não linear(ramificações paralelas)

- Totalmente distribuído

- Capaz de lidar com projetos grandes de forma eficiente(velocidade no tamanho dos dados)


Desde 2005 dada a criação do git, ele amadureceu para fácil usabilidade e manter as qualidades iniciais. É eficiente com projetos grandes e possui um sistema de ramificação com ótimo desempenho para desenvolvimento não linear.
Calculating 6502 Execution Time - Part 1
Tags: opensource, assembly, 6502
Published: 2022-01-28 15:08:15

Today I'm working on lab 2 for my software portability and optimization class, wherein we're looking at writing and analyzing assembly code written for the MOS 6502 as emulated [here](http://6502.cdot.systems/). This is the first in a series of posts about writing assembly for the 6502, part 2 of which you can find [here](https://dev.to/gusmccallum/calculating-6502-execution-time-part-2-6ih) and part 3 of which you can find [here](https://dev.to/gusmccallum/calculating-6502-execution-time-part-3-4jf1). Because the emulator isn't a 1:1 recreation of the 6502 and execution time may vary from one to the other, as well as manual calculation being fairly simple, I'll be manually determining execution time of a program and going through the steps to do so here.

First off is breaking down the program into individual instructions, finding the cycles it takes to run an instruction by its mnemonic [here](https://masswerk.at/6502/6502_instruction_set.html). 

Using a table like this one, we can look up the machine cycles it takes to run each instruction and compile these to calculate the total time.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dctljr7op1tpaywqykvp.png)

Once we find the relevant instruction in the instruction set, we need to check what kind of memory is being accessed and enter the appropriate cycle count in our table. For example the first instruction, LDA #$00, references an immediate value as evidenced by the preceding # symbol. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6gxuvugx2zutgk3kfyr.png)

Other possible options include:
- Memory on the zero (first - $0000 - $00FF) page, or zero page with the value of the X register added.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4n0mdt458entq32v2z5.png)

These are faster than accessing other absolute memory locations as the addresses are only 8 bits.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7n3e0cmkju9924iptuuh.png)

- Absolute addresses
- Absolute addresses plus X 
- Absolute addresses plus Y 

The latter two operations come with the condition that if the page boundary is crossed, 1 cycle should be added to the count.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsemktxur54kfs0egosb.png)

- Address plus X dereferenced
- Address dereferenced plus Y  

The latter comes with the aforementioned condition that a cycle is added if a page boundary is crossed. 

In the next blog post I'll start using the info I've gone through in this post to measure the runtime of the program and begin optimizing it.