teleren/devto huggingface dataset:
How to Decode Modbus Protocol
Tags: modbus, comport, monitoring, modbusprotocol
Published: 2019-01-24 11:01:29

---
title: How to Decode Modbus Protocol
published: true
description: Modbus is a protocol designed to allow communication between network-attached serial devices or applications.
tags: Modbus, com port, monitoring, Modbus protocol
---
Modbus is a protocol designed to allow communication between network-attached serial devices or applications. The protocol was introduced by the Modicon corporation in 1979, primarily to enable communication in their programmable logic controllers.

Modbus has become a widely used protocol, in part because it is an open protocol that manufacturers can use with no licensing cost. In fact, it is the de-facto standard communication protocol deployed in the manufacturing and industrial fields. A Master/Slave paradigm forms the foundation of the Modbus protocol. Communication is accomplished by a Master device which makes requests of Slave devices that then return an appropriate response to the Master.

Modbus networks are usually configured with one Master device which can be communicating and receiving responses with from 1 to 247 Slave devices. The Modbus protocol is used extensively in industrial automation implementations, enacting communication between the many sensors and controllers that make up such systems. Large facilities often employ multiple Modbus networks to address separate industrial processes or production lines.

![Alt text of image](https://i.ibb.co/PNGyCsx/10.jpg)

The [Modbus RTU](https://www.virtual-serial-port.org/article/modbus-decoder/) (remote terminal unit) and Modbus ASCII are the two main modes of data transmission used in the protocol. They differ in that the Modbus ASCII is more easily understood by humans as the messages it produces are in ASCII format. Modbus RTU trades the readability of its messages for more efficient data transmission.

The ability to decode and understand the messages generated by the protocol are the primary means of troubleshooting problems encountered with the Modbus network or its connected devices.


The decoding process performs a conversion of the message format used by the Modbus serial devices into information which can be understood by human system administrators. In order for IT personnel to understand the messages being produced by the Modbus network, it is essential to use a Modbus message decoder. This tool can be a tremendous asset when optimizing or debugging the network.

Problems may eventually impact your [Modbus network implementation](https://www.eltima.com/article/modbus-tester-guide/), and possessing the capacity to accurately decode Modbus messages is critical to your ability to decisively take action and solve the problem. A high-quality Modbus message decoder is an essential tool for individuals working with networks or devices that use the Modbus protocol. Serial Port Monitor is such a tool and can help you quickly identify the exact issues affecting your Modbus network.

All step by step instructions can be read [here](https://www.virtual-serial-port.org/article/modbus-decoder/).
Juggling server tasks with screen
Tags: opensource, productivity, devops, linux
Published: 2019-01-24 09:46:48

---
title: Juggling server tasks with screen
published: true
description: 
tags: opensource, productivity, devops, linux
---

Let’s say you have a server where you need run a script that will create a backup file which will take 40 minutes, install some software for 15 minutes, and finally while all of this is happening, you need to investigate the log files.

A first approach would be to just open a new terminal windows for each task and create a new ssh connection on each. While this works fine, a big problem is that if your connection breaks, the processes are terminated.
A second approach may be to run the first two in the background and then explore your logs

```
nohup sh backup_db.sh &>/dev/null &
nohup sh install.sh &>/dev/null &
tail /var/logs/my_logs
```

This will make sure that even if you connection breaks, the processes will keep running, but you’ll either have no output data, or have to check some logs somewhere to see if how the processes finished.

Screen comes to the rescue. Screen basically creates a terminal within a terminal. When you type on an empty prompt `screen`, you then see another empty prompt just like the one you had before, but this new prompt is different: it is not tied to your session and connection, but to the screen process in the OS.

What this means is that if you can now type `sh backup_db.sh`, start seeing messages from your script telling you about the progress of the backup, and then press `ctrl + a ctrl + d` (detach), and everything will be quiet again. You would have returned to the prompt where you typed screen in the first place.

You shut down your computer, go home, have some dinner, drink a beer, ssh from your laptop, and re attach to screen with `screen -r`, and you’ll be back to the log messages sent by the backup script who has been working all this time for you.

Back to the original problem. The way I would handle the tasks at hand would be the following:

```
# Start screen
> screen

# Run backup scrip
> sh backup_db.sh

# Create a new screen
# ctrl + a ctrl + c

# Install software
> sh install.sh

# Detach from screen
# ctrl + a ctrl + d
```

And finally I'd be free to investigate that weird bug in the logs. After a while, when I want to checkout on the processes, I would just type `screen -r` to re attach and `ctrl + a ctrl + n` to cycle through the opened screens.
Ecto drop Postgres database on AWS RDS
Tags: aws, elixir, ecto, postgres
Published: 2019-01-24 06:59:03

---
title: Ecto drop Postgres database on AWS RDS
published: true
description: 
tags: aws, elixir, ecto, postgres
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pkmrttsv1152s7kwgpl9.jpg
---

Lets say during your development cycles, you have screwed your postgres database and the easiest way to get out of the mess is to drop the database and restart fresh. In this example we will look at a [Phoenix](https://phoenixframework.org/) project that uses a Postgres database.


### Warning
To make it clear, dropping the database is a bad idea if you haven't taken snapshots. Dropping deletes all data; so do it only in non-prod.

### Problem: Dropping a database fails due to immortal rdsadmin 
```
mix do ecto.drop, ecto.create, ecto.migrate
```
This nicely works on your local postgres instance.
However, if the database is on AWS RDS, you'll be greeted by this interesting message.

```
$ mix ecto.drop
** (Mix) The database for SuperPetStore.Repo couldn't be dropped, reason given: ERROR:  55006: database "petdb" is being accessed by other users
DETAIL:  There is 1 other session using the database.
LOCATION:  dropdb, dbcommands.c:840
```

If you look at the number of connections 

```
> select * from pg_stat_activity;
```
Sure enough, there will be one persistent connection from `rdsadmin`. It is AWS RDS user that takes care of backup, updates and maintenance. This connection gets in the way of dropping the db and starting afresh.

```
> use postgres;
You are now connected to database "postgres" as user "petuser"
Time: 0.078s
postgres> drop database petdb;
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
database "petdb" is being accessed by other users
DETAIL:  There is 1 other session using the database.

Time: 5.031s (5 seconds), executed in: 5.030s (5 seconds)
postgres>
```

### pg_terminate_backend
```
select pg_terminate_backend(pid) from pg_stat_activity where datname='petdb';drop database pipeops;
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
+------------------------+
| pg_terminate_backend   |
|------------------------|
| True                   |
+------------------------+
SELECT 1
DROP DATABASE
Time: 0.118s
```
First `pg_terminate_backend` allows you to terminate the `rdsadmin` account and shoving in the `drop` statement in the same line gets the job done before `rdsadmin` spawns up and connects to `petdb`.

With the database gone, you can now run ecto to create the db afresh!

### Wait. What does the picture above have to do with this post?
Not a single thing. This is a picture I took at Siena. ❤️ Italy, can't wait to go back!
Future of Software 
Tags: africadev
Published: 2019-01-24 06:33:22

---
title: Future of Software 
published: true
description: How will software change African 
tags: #africadev 
---

The truth, I have always wanted  to become a software developer that made a difference regardless of my financial status now. Just,  I need a partner who can work together with me to make African a better place in terms of technology.

Only 25% of young people in Africa mostly Nigeria really know what software development is and it's very bad as our economy is dying
Docker cross repository push
Tags: docker, aws, ecr
Published: 2019-01-24 05:38:10

---
title: Docker cross repository push
published: true
description: 
tags: Docker, AWS, ECR
---
![header](https://thepracticaldev.s3.amazonaws.com/i/aes0ixj8nlw39n6p9ibv.jpg)
I just found dev.to and immediately fell in love with the retro 🤣 look! Instead of putting in much thought, I started brain dumping - mainly about things that did not work on the first go. No effort has been made to be helpful - typos, errors, misinformation  may lay ahead. Welcome to the Internet!



### Problem: Need to push a docker image from one AWS account to another

ECR is the docker repository as a service provided by AWS. To have better separation of your environment, you would typically have a prod account and one or more non-prod accounts. Your CI pipeline would be running in your non-prod account allowing you to rapidly iterate and build new images. Once your testing cycle completes, you would want to promote this image to the production account. Below are the set of commands needed to promote your release candidate from non-prod to production.

#### Login to your docker registry of source account
```
aws ecr --profile dev --region us-east-1 get-login --no-include-email | bash
```
Pretty straight forward. Make a cli call which returns the `docker login` command which is piped to execute in bash. `dev` is the aws profile for the account which contains the docker image.


#### CI produced docker image

```
docker pull 123456789012.dkr.ecr.us-east-1.amazonaws.com/img:aa567e02ae7477a6b022da30fa50137a252dd143
```
In 123456789012.dkr.ecr.us-east-1.amazonaws.com, `123456789012` stands for the account number of aws account where our docker image lives.
Lets say you have done your testing and you are now satisfied to promote this to prod.

#### Switch repository and try to push

Login to prod
```
aws ecr --profile prod --region eu-west-1 get-login --no-include-email | bash
```

Try to push
```
docker push 234567890121.dkr.ecr.us-east-1.amazonaws.com/img:ab77ad7b362d7552bc2c7a69f2650a5b50bcdcc1
```

And ... 
```
The push refers to repository [234567890121.dkr.ecr.us-east-1.amazonaws.com/img]
tag does not exist: 234567890121.dkr.ecr.us-east-1.amazonaws.com/img:aa567e02ae7477a6b022da30fa50137a252dd143
```

#### Uh oh forgot to tag
This was not very obvious to me. But docker, awesome as it is, gives you the nice error message above telling exactly where things are going wrong. To push to the prod registry, you'll need to tag the image accordingly.

```
docker tag 123456789012.dkr.ecr.us-east-1.amazonaws.com/img:aa567e02ae7477a6b022da30fa50137a252dd143 234567890121.dkr.ecr.us-east-1.amazonaws.com/img:aa567e02ae7477a6b022da30fa50137a252dd143
```

#### Push away
Finally push the image and you are done.
```
docker push 234567890121.dkr.ecr.us-east-1.amazonaws.com/img:ab77ad7b362d7552bc2c7a69f2650a5b50bcdcc1
```

Congratulations, you have promoted the image!

#### Wait. What does the picture above got to do with this post?
Not a single thing. This is a picture I took at [Siena] (https://en.wikipedia.org/wiki/Siena). ❤️Italy, can't wait to go back!
Beyond Static Typing
Tags: dlang
Published: 2019-01-24 05:27:55

---
title: Beyond Static Typing
published: true 
description: 
tags: dlang 
---

I've made a couple of posts about D and there is actually a common theme. My case for D goes beyond a static scripting language. If you read my covariance article what you see is a technique to getting more out of static typing. 

{% link https://dev.to/jessekphillips/covariance-and-multiple-interface-inheritance-4n3f %}

But D does not stop there, it provide arbitrary compile time execution of code. It has expanded in how much of the language is accessible at compile time with specific limitations on system calls (disk access).

There has been some very nice utility to compile time libraries like pegged and regular expressions. But this facility can also be used to write static unit tests. Now as cool as that sounds how do I explain how different this is from a unit test library that validates after compiling.

This is tricky because D facilitates verification in a number of different ways. Unit test blocks are built to the language, in and out contracts, class inveriants. When you consider all the places and features covered in the language have additional times to execute and stop a build the better.

I don't believe TDD produces good design, I practice DRCT (Design by Runs at Compile Time).
When to snapshot ?
Tags: help, discuss, javascript, testing
Published: 2019-01-24 02:54:22

---
title: When to snapshot ?
published: true
description: 
tags: #help, #discuss, #javascript, #testing
---

I am having hard time understanding valid use cases for [Jest snapshot testing](https://jestjs.io/docs/en/snapshot-testing).
There are lots of opinionated posts explaining snapshot testing.
Have you used snapshot tests in your projects ? If yes, for what kind of components (functional vs stateful with lots of logic, components that are edited frequently vs components that aren't)? If no, why?
Should employers provide time for learning/training?
Tags: discuss, career, learning
Published: 2019-01-24 02:04:17

---
title: Should employers provide time for learning/training?
published: true
description: Should employers provide learning time or is that something that should be done in your own time?
tags: #discuss, #career, #learning
---

An excerpt from The Clean Coder by Robert C. Martin reads:

>Your career is your responsibility. It is not your employer's responsibility to make sure you are marketable. It is not your employer's responsibility to train you, or send you to conferences, or buy you books ... It is also not your employer's responsibility to give you the time you need to learn. Some employers may provide that time ... they are doing you a favor, and you should be appropriately appreciative.

What do you think? Should employers provide learning time or is that something that should be done in your own time?
Dark Theme for Dev.to
Tags: showdev, productivity
Published: 2019-01-24 01:44:38

---
title: Dark Theme for Dev.to
published: true
description: Dark Theme Userstyle for Dev.to 
tags: showdev,productivity
cover_image: https://thepracticaldev.s3.amazonaws.com/i/twp98g52r3u4uwvm1wfy.png
---

_Screenshots are at the bottom of the post_

# Foreword
**This is a temporary solution until the official dark theme is released, for this reason the code is not organized and ordered and you may find some component/pages with the light theme.**

# Why a dark theme?
> If you only knew the power of the Dark Side...
> – Darth Vader

Joking aside, there are so many **benefits** to using a dark theme, like:
- Less invasive night reading
- Helps you focus more on text
- Prevents you from fatiguing your eyes for long periods in front of your computer
- And many other benefits (that you can google)

Personally I'm addicted to dark themes, I could be a vampire 🧛‍♂️

# How to use it?
To use it you should install a userstyle manager compatible with https://userstyles.org, my personal recommendation is Stylus
![Stylus logo](https://thepracticaldev.s3.amazonaws.com/i/na6o81jmht1mz9z5wx6q.png)

Stylus is a userstyles editor and manager compatible with **Mozilla Firefox**, **Google Chrome** and **Opera**, which can be downloaded in the respective stores:
- Mozilla Firefox: https://addons.mozilla.org/en-US/firefox/addon/styl-us/
- Google Chrome & Opera: https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne

After installing Stylus, just **go to the theme page** and click the button that says **"Install Style"**

**Theme Page:** https://userstyles.org/styles/168140/dev-to-dark-mode

![Install Theme](https://thepracticaldev.s3.amazonaws.com/i/6otn21sp14hciga38w05.png)

Done! Now you can go back to Dev.to and enjoy the dark theme ☕

# Screenshots
**Main Page:**
![Dev.to Main Page](https://thepracticaldev.s3.amazonaws.com/i/li3ofh2ecqlk1wwq9b9s.png)
**Tag Page:**
![Dev.to Tag Page](https://thepracticaldev.s3.amazonaws.com/i/rrlf8a22w8rpsbk1d5sk.png)
**Profile Page:**
![Dev.to Profile Page](https://thepracticaldev.s3.amazonaws.com/i/i3239o9896zpl4bh7vne.png)
**Post Page:**
![Dev.to Post Page](https://thepracticaldev.s3.amazonaws.com/i/sok321rlti8182pdlgep.png)

# Conclusion
If you find bugs you can leave a comment or contact me on [Twitter](https://twitter.com/mercxry_), I do not ensure to update the theme regularly and promptly but I will try to keep it working.

You can now contribute on Github: https://github.com/mercxry/dev.to-dark-theme

## Credits
I was inspired by this GitHub issue: https://github.com/thepracticaldev/dev.to/issues/1413
What is the best tool for blogging?
Tags: discuss
Published: 2019-01-24 01:09:56

---
title: What is the best tool for blogging?
published: true
tags: discuss
---

Hey guys, I'm thinking about retaking my blog and repost here something that I can write. My blog was made with Jekyll but I'm looking for something new, besides I don't wanna use Wordpress because I hate Php (I'm sorry). Another Idea that I have is changing the actual theme but honestly, I don't know

What is the best tool for blogging or for creating a blog?

Thanks.
TIL: The hr element is more than a horizontal line
Tags: html, webdev
Published: 2019-02-16 22:19:04

---
title: TIL: The hr element is more than a horizontal line
published: true
tags: html, webdev
canonical_url: https://www.stefanjudis.com/today-i-learned/the-hr-element-is-more-than-a-horizontal-line/
---

You may have use the `hr` element for styling when you needed a horizontal line in your designs. Today I came across a tweet by [Will Boyd](https://mobile.twitter.com/lonekorean/status/1086727522144931840) sharing that the `hr` elements comes with semantic meaning! 😲

From [the spec](https://html.spec.whatwg.org/multipage/grouping-content.html#the-hr-element):

> The hr element represents a paragraph-level thematic break, e.g. a scene change in a story, or a transition to another topic within a section of a reference book.

Good to know!
Day 23: Swift macOS password manager for people who hate the cloud
Tags: macos, swift, passwordmanager, cloud
Published: 2019-01-23 23:31:54

---
title: Day 23: Swift macOS password manager for people who hate the cloud
published: true
description: Follow along as I make a 100% cloudless and 100% native password manager for macOS. That's 200% raw password managing power.
tags: macos, swift, password manager, cloud
series: Making a swift MacOS password manager for people who hate the cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q6r73zbfbm3mpfs98bu5.jpg
---

[<- For Day 22 go here](https://dev.to/swlkr/day-22-swift-macos-password-manager-for-people-who-hate-the-cloud-2ih3)

📅 01/23/2019
🚀 [7 days until launch](https://www.producthunt.com/upcoming/all-your-passwords)
🔥 22 day streak
💰 $5.00 price (no more .99, I hate that tactic)
🤑 $0 revenue
📈 0 customers
⌚️ 37 hours spent
💻 102 files changed, 249709 insertions(+), 549 deletions(-)
🏁 Today's goal: **Logo (again)**

**8:15 AM**
Update on the logo situation, after some hardcore [dribbbling](https://dribbble.com) and after realizing I essentially made a weird knock-off swastika, I've come up with something that is a rip-off of someone else's work, but I changed it a little bit (the story of my life)

![](https://thepracticaldev.s3.amazonaws.com/i/lfy3g8d8yu6typ7w9nzg.png)

I think this may be good enough… I mean I'm running out of time. So this is the part where I start using this thing every day and effectively switch from 1password and find out which features are missing and which ones I really *need*.

**4:27 PM**
Tried to get this thing archived today, didn't know what I was doing, still don't. I got a little closer each time I tried, first I didn't even have a "Hardened Runtime" which is something that sounds pretty secure and cool. I also appear to be missing a valid developer profile or at the very least I've misnamed it since it seems to fail when I'm trying to validate my archive. The joys of distributing macOS apps. I'll probably figure this out tomorrow and give you the skinny.
Deadline versus Lifeline
Published: 2020-11-08 00:49:43

---
title: Deadline versus Lifeline
published: true
tags: 
canonical_url: http://andrewmiracle.com/posts/deadline-vs-lifeline/
---

We are stuck goals and milestones in a modern age, where everything is moving fast and millenials are expected to meet very high expectations, this is not our point though

Have you ever given a developer a job to do for you with an ETA. this applies to most creatives, artist, music producers, carpenters etc.

Are you a **deadline** or **lifeline** person : This comparison will help you find out

### Deadline

- sticks to the timeline and delivers before time
- Sticks to a particular process/strategy and gracefully follows it through

### Lifeline

- Good at emergency deliveries, tight delivery expectations
- Hacks processes to produces optimal results, most cases short term.

This makes me reflect between Mourinho and Pep Guardiola, two wonderful personalites, winners they are, however I would categorize one as a Lifeline person and another one as a deadline person

In the startup world, you require a mix of both, roll out a feature immediately, so that the VC and users would be happy, experiencing the potential of that feature, then gradually iterating through the process to optimize and fine tune delivery and results.

Who are you ? Deadline : Lifeline