teleren/devto huggingface dataset:
Forces Yarn to be used on a project by using "only-allow"
Tags: javascript, npm, yarn
Published: 2020-08-19 00:42:47

---
title: Forces Yarn to be used on a project by using "only-allow"
published: true
description: 
tags: [JavaScript, NPM, Yarn]
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/p5rzofi1d0cbev8oza6n.png
---

[only-allow] is a tool that enforces developers to use a specific package manager on their project.

[only-allow]: https://www.npmjs.com/package/only-allow

## Problems

The standard package manager for JavaScript is NPM, however there are other popular package managers such as Yarn and PNPM.

Between the package managers, there are some incompatibilities. For example, npm and yarn lock the versions of the installed packages in a different way. NPM saves it in package-lock.json, Yarn does in yarn.lock.

To use the same one package manager among the developers is important. This is to prevent unexpected incompatibilities.

## Solutions

### Documentation

The simplest way to employ the one same package manager in the team is to call a developer's attention by documentation. For example, you can write about it on README.md like:

> "Please use Yarn to set up this project!"

However, this way sometimes fails. Some developers don't read it. There is no force in documentation.


### "only-allow"

The better way to enforce the developers to use a specific package manager is to employ [only-allow]. It enforces developers to use a specific package manager on their project.

If a developer tries to use NPM in a Yarn-only-allowed project, the process will fail. `only-allow` will tell s/he to use Yarn instead of NPM:

![](https://i.imgur.com/jdVxhS1.png)


#### How to set up "only-allow"

To set up `only-allow` is quite simple. Just adds a `preinstall` script to the `package.json`:

```package.json
{
  "scripts": {
    "preinstall": "npx only-allow yarn"
  }
}
```

It does't need to install `only-allow`.

## Conclusion

* To use a same package manager among developers in a project is important.
* Documentation sometimes can't force the developers to use the same package manager.
* `only-allow` is useful to force to use the same package manager in a project.
Stream Idea - Teaching Go Live
Published: 2020-08-19 00:40:24

So I've been contemplating ways to make my stream more valuable to the audience. Games are, well, games. Live coding, at least to me, is super boring and hard to follow at times.

So I had an idea, what about offering to teach Go live, doing code reviews, or just offering help with someone's code? What do ya'll think about that idea and do you have your own?
How ReactJS creates inside functions? amazing ! 
Tags: react, javascript, functional, opensource
Published: 2020-08-19 00:05:06

In the past, I did not care how ReactJS creates functions and variables while re-rendering components.
But I had a few chance to look at about this.

Now ReactJS creates all functions and variables newly whenever they re-render their component.
To optimize performance with memory, useCallback was very effective for this, and decreased re-creation times a lot more.
Please check my repository, and github pages to test.

https://github.com/yeahCH/react-performance-inspector
https://yeahch.github.io/react-performance-inspector/
Why we need the measurements ?
Tags: productivity, codequality, startup, learning
Published: 2020-08-19 00:00:52

How many times our team lead, CTO, CPO or product owner tell us that they wish see metrics, logs or something related a feature?

Once time, A team lead ask me about the coverage of the code I remember that I think "why, if my code works?".

![inciting-problem](https://media.giphy.com/media/xThuWjk0OAZgeJwahG/giphy.gif)

In others similar situation a CPO ask me about the analytics metrics, "how the users adopts the last release?" And in the same way the PO ask me "This screen are slow, we know what happens?"

So life was going well, the team keep working without any metric or productive logs and by surprise the product was aceptable and the users started to growing, and y remember me and my coworkers celebrating.

```
NICE! We are the best team in the word
```

![rising-action](https://media.giphy.com/media/uokhSmdmyfh2o/giphy.gif)

So life was going well, right? ;) One day a user found a fat bug and anyone know what happened or how reproduce and we fall through the ladders, I was imagine to Rocky falling for the ladders but I can't found the GIF 😂 

![crisis](https://media.giphy.com/media/1AzW5Fw4DFdja/giphy.gif)

We fail, we lost a lot of money and the organisation getting mad with the developers and with a lot of pain we accept that we needed the metrics to monitor the user adoption and behaviours, we needed the logs and traces and why not we needed a performance monitor.

So, getting metrics, logs, testings of your product is part of the quality that the each developer should do and you can trust in me when I tell you that this is hard to start but it's a good investment this will make your job more easier. Because you will more available information to find a solution to your problems or more information to improve flows or complex task in your application.

If you are interested in tutorials about 'how measure a react native application?' leave a comment and I will prepare something more technical.

"Shit happens, but if you are smart maybe you can clean the shit from your shoes and change something that can care your shoes the next time"
How to write test cases for registration and login page
Tags: testcases, codequality, loginandregistration
Published: 2020-09-01 10:55:07

---
title: How to write test cases for registration and login page
published: true
date: 2020-08-19 00:00:00 UTC
tags: TestCases,Quality,LoginandRegistration
canonical_url: https://www.loginradius.com/engineering/blog/test-cases-for-registration-and-login-page/
---

Here is a set of Use Cases for Login and Registration Pages to test and to make sure the quality.

   
[Read On](https://www.loginradius.com/engineering/blog/test-cases-for-registration-and-login-page/)
A short introduction
Tags: presentation
Published: 2020-08-21 10:34:24

---
title: A short introduction
published: true
date: 2020-08-19 00:00:00 UTC
tags: [ 'presentation' ]
canonical_url: https://victorcamnerin.com/articles/a-short-introduction/
---

My name is Victor Camnerin. I'm a proud father of two and happily married. Right now we're living in Oskarshamn, Sweden.

I'm a web developer and designer primarily focusing on frontend and UX. For the last three years, I've been working at [Angry Creative](https://angrycreative.se). One of the leading WordPress and WooCommerce agencies here in Sweden.

With an education in Graphic Design and Communication and some five years experience in web development, I'm a pretty faceted developer. I love learning and taking on new design and development challenges.

Please [contact me](/contact) if you're interested in working together. Since I'm working full time at [Angry Creative](https://angrycreative.se) all major inquiries will be redirected that way.

Until next time. Take care!
GitHub Actions: an intro
Tags: github
Published: 2020-08-20 18:08:46

---
title: GitHub Actions: an intro
published: true
date: 2020-08-19 00:00:00 UTC
tags: github
canonical_url: https://mozzy.dev/posts/github-actions/
---

There are quite a few build and deploy options available to developers these days. Previously, I have wrote about using a combination of [Team City and Octopus Deploy](http://mozzy.dev/posts/continuous-delivery-for-dotnet-revisited/). These are still good tools, but will likely require a bit of setup and probably require a VM.

A more recent trend is to have your actions linked to your repository, where you can have it all self contained and in one place. There are pros and cons to both, but I'm gonna show you how you might do that with GitHub Actions.

## dotnet

I work mostly with .NET, so lets take a look at the workflow for that. With .NET Core you can now use Linux (and macOS) as your build target. Here we're using `ubuntu-latest`.

We're also setting the relevant `DOTNET_VERSION` and running our commands, `dotnet build` and `dotnet publish`. Problems with the build will be visible within GitHub and you can follow along with the progress.

Finally, we're pushing our published version of the app to Azure Web Apps using a publish profile. You could also choose to generate a NuGet package and push to a feed for distribution.

{% gist https://gist.github.com/tcmorris/dada56a630316670a064882a2753f04f.js %}

Note, you can also build [.NET Framework apps](https://github.com/Azure-Samples/dotnet-sample/blob/master/.github/workflows/aspnet.yml), that will look a little different but the concept is the same. You'll target `windows-latest` as that is a prerequisite for .NET Framework, and the commands will be `msbuild`.

## node.js

If you've got a FE repo, then you'll likely want to use npm to compile some assets and package them up. Here's how you can do that.

We've set up our `NODE_VERSION` and then run the commands, `npm install` and `npm build`. At that point, we might want to package up the assets or deploy as an application.

{% gist https://gist.github.com/tcmorris/a779e0c62f9db194b7a15bdef0ec696e.js %}

## other

There are lots of other options available to you, without going into all of them here, I encourage you to take a look through the [docs](https://docs.github.com/en/actions/language-and-framework-guides) and see what you might want for your needs.

If you're interested in what's installed on the runners, then take a look at [this repo](https://github.com/actions/virtual-environments) which contains the full list of software and spec for each.

The approach here can also be used for similar tools such as [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) or [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/). Choose what fits the bill for you.

Have fun!
How to find or get a reference to the closest parent DOM element in JavaScript?
Tags: javascript
Published: 2020-08-19 00:00:00

---
  title: How to find or get a reference to the closest parent DOM element in JavaScript?
  published: true
  tags: JavaScript
  date: Wed Aug 19 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/find-closest-parent-element-dom-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-47c98c0d92b6088bb861234920a0aa3d.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/find-closest-parent-element-dom-javascript)
  
Suppose you have an element and want to get a reference to the closest parent element up the DOM tree.

To achieve that you can use the `closest()` method on a specific element and pass the selector string. The method returns a reference to the first closest parent element matching the selector.

Consider this HTML,

```html
<section>
  <div class="article">
    <div class="heading-section">
      <h1 id="main-heading">This is a big heading</h1>
      <p id="sub-heading">A sub heading</p>
    </div>
  </div>
</section>
```

Here we have an `h1` tag with `id="main-heading"` and we want to get a reference to the `div` tag with `class="article"`.

Let's write the code for that.

First, Let's get the reference to our `h1` tag.

```javascript
// reference to h1 tag
const h1 = document.querySelector("#main-heading");
```

Now let's use the `closest()` DOM element method and pass the selector string for the parent tag that is the `.article` class name as an argument to it.

```javascript
// reference to h1 tag
const h1 = document.querySelector("#main-heading");

// get reference to parent element
// with class name article
const article = h1.closest(".article");

console.dir(article); // article reference
```

- If there is no element with `.article` class name, the method returns null.

### Feel free to share if you found this useful 😃.

---
Postgres 2020 Q3 Release
Tags: postgres, database
Published: 2020-09-09 14:37:34

---
title: Postgres 2020 Q3 Release
published: true
date: 2020-08-19 00:00:00 UTC
tags:  
- postgres
- database
canonical_url: https://magistratehq.com/blog/postgres-2020-q3-release/
---

Another patch for postgres has landed. This patch moves the latest secure version to pg 12.4, 11.9, pg 10.14 and pg 9.6.19. The highlight of this release is fixing CVE-2020-14349 and CVE-2020-14350, which allowed unintended privilege escalation under certain conditions.

For more details, check out the [official release](https://www.postgresql.org/about/news/2060/).

To learn more about Postgres 12 specific changes, [click here.](https://www.postgresql.org/docs/12/release-12-4.html)

To learn more about Postgres 11 specific changes, [click here.](https://www.postgresql.org/docs/11/release-11-9.html)

To learn more about Postgres 10 specific changes, [click here.](https://www.postgresql.org/docs/10/release-10-14.html)

To learn more about Postgres 9.6 specific changes, [click here.](https://www.postgresql.org/docs/9.6/release-9-6-19.html)

If you are a [Magistrate](https://magistratehq.com) customer, just update your magistrate package in your package manager and you'll have the new code to inform you if your postgres server is patched or not.
Day 198: Move
Tags: hiphop, code, coding, lifelongdev
Published: 2020-08-18 22:55:07

_liner notes_:
- Professional : Pretty much spent the day, getting ready to move into my van officially. Going to get some work done a little later.

- Personal : Last night, finished packing up to get ready for the big move.

![Large rocks on both sides in the forest with a small stream running through the middle in Ice Age Trail, Wisconsin](https://dev-to-uploads.s3.amazonaws.com/i/mvmxlm2fqu4t0rlg68mt.png)

So, I grabbed some food and found a nice spot. It's a spot I've been thinking about parking my van for a minute. Every time I would drive by before, I would think, 'I bet that's a good spot to park' haha I'm here and we'll see if I'm right. Since I spent my day mostly packing my van, I'm going to do some work. My fridge seems to be working fine running off my portable battery. Going to see how long it lasts.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube isXd-748v9E %}
[Day 5] Installing MongoDB
Tags: ubuntu, mongodb
Published: 2020-08-18 22:19:16

Hello guys!

After short & unexpected break, I'm back and ready to set up yet another thing on my VPS — today it's a database.

## Why MongoDB?

I have two main reasons behind that choice:

1. I don't have much experience with MongoDB;
2. Which I want to use with GraphQL, also pretty unknown for me at the moment.

## Installing MongoDB

I followed the official tutorial provided by MongoDB, available [here](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/). I need to install MongoDB in version 4.0 or above, otherwise, GraphQL won't work. Current documentation for MongoDB suggests installing version 4.4, so I will go with that.

Most important steps of install process:

```ssh
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - # add Mongo's key to APT

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list # add MongoDB 4.4 to list of APT sources

sudo apt update # update packages

sudo apt install mongodb # install MongoDB

sudo systemctl start mongod # start MongoDB service

sudo systemctl enable mongod # allow MongoDB to self-start after server is rebooted
```

After all these steps, MongoDB is installed, running in the background and ready to be started after machine reboot. I checked that by typing in `mongo` into open SSH console.

---

That's all for today! In the next post I will talk about how I secured database.

## References

* https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
* https://docs.mongodb.com/realm/graphql/

---

Cover image: <span>Photo by <a href="https://unsplash.com/@jankolar?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jan Antonin Kolar</a> on <a href="https://unsplash.com/s/photos/database?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>
Here We Go
Published: 2020-08-18 21:53:11

This is my first time writing something publicly in years. It is not ordered or designed. The prompt popped, it was low barrier and, since I'm writer-curious, decided to go ahead and write something.

Since the expectation is that zero people will see it, I'm not going to worry about what it ultimately becomes (lies: I edited this line twice before moving on from it).

I'm a computational scientist by training and an aspiring data scientist in practice. Trying to make the transition in a directed fashion currently.

I hope to be positioned to help leverage humanity's ever-expanding computational capacity to facilitate insights into the biosciences.

This is actually how I speak. I know.
Releasing JavaScript Libraries with release-it
Tags: javascript, webdev, npm, github
Published: 2020-08-18 21:48:16

*Originally published at [shipshape.io](https://shipshape.io/blog/releasing-javascript-libraries-with-release-it/)*

We maintain many open source projects at Ship Shape, and are constantly looking for better ways to handle processes like testing and linting, CI,
code coverage metrics, live previews etc., but one of the most ubiquitous needs across all of our packages is a consistent release pipeline. 
Until recently, we didn't have a real set standard. We would use `npm version` and `npm publish` directly in some places, we would manually
push tags with `git push --tags`, and we were doing every step of the release pretty manually.

Once we discovered [release-it](https://github.com/release-it/release-it), we were able to finally have a standard way of doing all the manual release bits in one easy command.
It allows us to bump the package version, generate a changelog, commit, tag, push commits, push tags, release on GitHub and release on npm all with a nice step-by-step CLI command.

![Running release-it on ember-shepherd to show changelog generation and version bumping](https://shipshape.io/img/blog/releasing-javascript-libraries-with-release-it/release-it.png)

To simplify the setup process even further, we have been using [create-rwjblue-release-it-setup](https://github.com/rwjblue/create-rwjblue-release-it-setup) by the incomparable [@rwjblue](https://twitter.com/rwjblue). Which does the following:

* Adds `release-it` config to package.json
* Installs required dependencies
* Adds a CHANGELOG.md
* Adds a RELEASE.md
* Updates your repository's labels with rwjblue's "go to" defaults

This gets us up and running with `release-it` in a single command:

```bash
# in a yarn repo
yarn create rwjblue-release-it-setup

# in an npm repo
npm init rwjblue-release-it-setup
```

We are then up and running with `release-it` and are ready to release our packages! There are a lot of config options for `release-it`, if you have more custom needs, but
this should handle the basic case. Enjoy releasing your packages!
Publishable Enum in Ruby on Rails with PostgreSQL
Tags: rails, enum, postgres
Published: 2020-08-18 21:46:59

---
title: Publishable Enum in Ruby on Rails with PostgreSQL
published: true
description: Publishable Enum in Ruby on Rails using PostgreSQL enums
tags: rails, enum, postgresql
canonical_url: https://majesticlabs.dev/publishable-enum-in-ruby-on-rails-with-postgresql/
//cover_image: https://dev-to-uploads.s3.amazonaws.com/i/b5k1sh49tnu97xea0h2q.png
---
![Publishable/Unpublishable](https://dev-to-uploads.s3.amazonaws.com/i/b5k1sh49tnu97xea0h2q.png)

There are many options to add publishing ability to your Rails model. The good reference is: https://naturaily.com/blog/ruby-on-rails-enum

Let's assume we have an `Article` model and we want to make it `publishable`.

### Add activerecord-postgres_enum to your Gemfile

`gem 'activerecord-postgres_enum'` 

You need this [solution](https://github.com/bibendi/activerecord-postgres_enum) if you want to use `schema.rb`.

### Let's create a Publishable module

`app/models/concerns/publishable.rb`

```ruby
module Publishable
  extend ActiveSupport::Concern
  STATUSES = %w[draft reviewing published unpublished].freeze
end
```

### Create PostgreSQL enum

`rails g migration add_content_status_type`

```ruby
class AddContentStatusType < ActiveRecord::Migration[6.0]
  def change
    create_enum :content_status, Publishable::STATUSES
  end
end
```

This will create the PostgreSQL ENUM type.

### Now it's time to add your status to Article model.

`rails g migration add_status_to_articles status:content_status`

This will create a migration to add `status` to the `Article` model.

I recommend defining the default value as the following:
`add_column :articles, :status, :content_status, default: 'draft'`

Also, if you need to make various queries to your model based on the status, add an index:
`add_index :articles, :status`

Add the publishing ability to your article:

```ruby
class Article < ApplicationRecord
  include Publishable
end
```

We are still missing all Rails scopes and other enum features.

### The updated version of Publishable concern

```ruby
module Publishable
  extend ActiveSupport::Concern
  STATUSES = %w[draft reviewing published unpublished].freeze

  included do
    enum status: STATUSES.zip(STATUSES).to_h
  end
end
```

This adds all Rails scopes and magic. For example:
* `Operator.published`
* `operator.published?`
* `operator.published!`

Happy Hacking!
Resume Blog
Tags: csharp, gamedev, computerscience
Published: 2020-08-18 21:36:51

Skills
   My skills a programmer vary, although my main focus is to become a video game developer, I know languages such as HTML/CSS, JavaScript, Swift, and C#. I am more specialist in C# as I have more years and experience with it. One of the critical skills that every programmer should have, in my opinion, is being able to critically think on the spot, to be able to handle the problems that every programmer faces when creating any kind of software.

Best Projects
   One of my best projects has to be creating my own website but also being able to create my own small video game, although I am creating on the go to learn more and more in what C# can do and its limits, I am creating an app that I am hoping will become my greatest project and hoping it can do great into the world we live in.

Leadership Activities
   The usual activities that I apply into is joining in a social group, volunteering in different projects whether they pay or not(it is about gaining experience rather than gaining money at the moment), and work as a team as much as possible we all know each other's strengths and weaknesses and be able to have that respect from one another with the work that we do.

Dream Job
   One of my dream jobs is to one day work in any game company as a programmer to gain the experience for me to be able to create my own company and able to manage and run it the way, I presume, should be run, as of lately a lot of game companies want to abuse a game developers passion in making games by paying them less that what they are actually worth, passion isn't supposed to be taken advantage of because it shows how much hardworking they are willing to do and the better an employee is treated I believe the employees will have that passion ignite more than its potential.
Nand 2 Infinity: A New Video Series
Tags: learning, computers, electronics, logicgates
Published: 2020-08-18 21:32:54

I am working on a youtube video inspired by Nand 2 Tetris. In it, I am planning to explore how computers work, starting with the lowest level. I have so far made one video. If you are able, please tell me how I could do better.
{% youtube qC6EyM0U8H4 %}
Allow IP Address of employees from work from home using Putty Terminal
Tags: linux
Published: 2020-08-18 21:31:28

iptables -A INPUT -s { employee_ip_address } -j ACCEPT

to know your public ip address, google "whats my ip address"

My Public IP Address is 49.145.34.209 

type this command in PuttyTerminal
    - iptables -A INPUT -s 49.145.34.209 -j ACCEPT