teleren/devto huggingface dataset:
MQTT: An Intro to the IoT Messaging Protocol | Part 1
Tags: iot, mqtt, beginners
Published: 2022-07-05 19:01:53

## Introduction to MQTT

> “MQTT is a Client Server publish/subscribe messaging transport protocol. It is light weight, open, simple, and designed so as to be easy to implement. These characteristics make it ideal for use in many situations, including constrained environments such as for communication in Machine to Machine (M2M) and Internet of Things (IoT) contexts where a small code footprint is required and/or network bandwidth is at a premium.“ -- Citation from the official [MQTT 3.1.1 specification.](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html)

The abstract of the MQTT specification does a good job describing what MQTT is all about. It is a very light weight and binary protocol, and due to its minimal packet overhead, MQTT excels when transferring data over the wire in [comparison to protocols like HTTP](https://www.hivemq.com/blog/mqtt-vs-http-protocols-in-iot-iiot/). Another important aspect of the protocol is that MQTT is extremely easy to implement on the client side. Ease of use was a key concern in the development of MQTT and makes it a perfect fit for constrained devices with limited resources today.

Watch this video to understand the main features and characteristics of the MQTT protocol.

{% embed https://youtu.be/r89uHL2wj5Q %} 

> Read the [next post of this series](https://dev.to/hivemq/mqtt-publish-subscribe-pattern-explained-part-2-2268), which introduces the publish and subscribe pattern and the differences between MQTT and a message queue.

[Click here](https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt/) to read the original post.

Get your copy of [MQTT Essentials eBook](https://www.hivemq.com/download-mqtt-ebook/?utm_source=content+syndication&utm_medium=devto&utm_campaign=MQTT+Essentials) to understand the protocol in detail without having to read the entire specification.
Swiss army knife of Linux
Tags: linux, cloud, aws, devops
Published: 2022-07-05 19:00:52

BusyBox - The Swiss Army Knife of Embedded Linux

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides minimalist replacements for most of the utilities

Here is how to launch a simple web server using  busybox on port 8080, just run

busybox httpd -f -p 8080


https://manpages.ubuntu.com/manpages/trusty/man1/busybox.1.html#:~:text=BusyBox%20combines%20tiny%20versions%20of,%2C%20util%2Dlinux%2C%20etc. refer for more info
Go Course: Why learn Go?
Tags: go, tutorial, beginners
Published: 2022-07-05 18:54:54


Before we start this course, let us talk about why we should learn Go.

### 1. Easy to learn

![easy-to-learn.png](https://raw.githubusercontent.com/karanpratapsingh/portfolio/master/public/static/courses/go/getting-started/why-learn-go/easy-to-learn.png)

Go is quite easy to learn and has a supportive and active community.

And being a multipurpose language you can use it for things like backend development, cloud computing, and more recently, data science.

### 2. Fast and Reliable

![fast-and-reliable.png](https://raw.githubusercontent.com/karanpratapsingh/portfolio/master/public/static/courses/go/getting-started/why-learn-go/fast-and-reliable.png)

Which makes it highly suitable for distributed systems. Projects such as Kubernetes and Docker are written in Go.

### 3. Simple yet powerful

![simple-yet-powerful.png](https://raw.githubusercontent.com/karanpratapsingh/portfolio/master/public/static/courses/go/getting-started/why-learn-go/simple-yet-powerful.png)

Go has just 25 keywords which makes it easy to read, write and maintain. The language itself is concise.

But don't be fooled by the simplicity, Go has several powerful features that we will later learn in the course.

### 4. Career opportunities

![career-opportunities.png](https://raw.githubusercontent.com/karanpratapsingh/portfolio/master/public/static/courses/go/getting-started/why-learn-go/career-opportunities.png)

Go is growing fast and is being adopted by companies of any size. and with that, comes new high-paying job opportunities.

I hope this made you excited about Go. Let's start this course.

---

_This article is part of my open source [Go Course](https://www.karanpratapsingh.com/courses/go) available on Github._

{% github karanpratapsingh/go-course %}
Go Course: What is Go?
Tags: go, tutorial, beginners
Published: 2022-07-05 18:51:47


Go (also known as _Golang_) is a programming language developed at Google in 2007 and open-sourced in 2009.

It focuses on simplicity, reliability, and efficiency. It was designed to combine the efficacy, speed, and safety of a statically typed and compiled language with the ease of programming of a dynamic language to make programming more fun again.

In a way, they wanted to combine the best parts of Python and C++ so that they can build reliable systems that can take advantage of multi-core processors.

---

_This article is part of my open source [Go Course](https://www.karanpratapsingh.com/courses/go) available on Github._

{% github karanpratapsingh/go-course %}
Protect your business from online assaults by taking a cyber security course from A2n Academy.
Tags: cybersecurity, cybersecuritycourse, cybersecuritytraining
Published: 2022-07-05 18:33:36

Cyber security sounds hard, yet it is one of the most trending topics in the industry. Hence, it is important for every individual who is a part of the cybersecurity domain or a cybersecurity aspirant, to be updated with the latest trends. But, the cyber security domain is filled with so much news that it’s difficult to filter out which are the relevant ones to learn cybersecurity and stay updated.
We assist you in choosing perfect **[cyber security training](https://www.a2nacademy.com/course/cyber-security-course)** to acquire knowledge and develop command in this domain.

Learn to establish a digital immune system and lay a solid foundation in the field of cyber security to prevent assaults and interruptions of the business process. The A2N Academy's online **[cyber security course](https://www.a2nacademy.com/course/cyber-security-course)** will go through the key ideas that will enable you to become an expert in the field.

Benefits of Cyber Security Course 
Recognize the many forms of cyberattacks
Study security control design.
investigate and deal with assaults
Threats posed by malware and vulnerability analysis
Session espionage
Different security procedures with live projects
How to Build Transport Website Using Html CSS JavaScript
Tags: css, javascript, beginners, tutorial
Published: 2022-07-05 18:22:29


{% youtube 55n9hx6QmVA %}

How to Build Transport Website Using Html CSS JavaScript

This video will show you how to make a responsive transport website using html css javascript.

[Live Website](https://codewithsadee.github.io/transportio)
[Github Repo](https://github.com/codewithsadee/transportio)

---

HI 👋
I'm Sadee (webdev)
In this channel I make videos about Complete Responsive website.
You can checkout my channel 👇

📺 My Channel : [codewithsadee](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g)
🔔 Subscribe : [subscribe now](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g?sub_confirmation=1)

---

🔗 Essential links
-----------------------------
[Starter file](https://drive.google.com/file/d/1-ftkseSnC8HXppEp1s125PJk4JF3I62t/view?usp=sharing)

---

⏱️ Timestamps
-----------------------------
0:00 - Demo
3:46 - File structure
4:12 - Project initial
10:30 - Header
26:46 - Hero section
34:58 - About section
46:54 - Service section
56:26 - Feature section
1:04:42 - Project section
1:15:41 - Blog section
1:22:52 - Newsletter section
1:27:51 - Footer
1:37:12 - Media queries

---

[![Become a patreon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnjl14kdm5qf08hu5lop.png)](https://www.patreon.com/bePatron?u=62535867)
Set up Serilog in .NET 6 as logging provider
Tags: csharp, dotnet, net6
Published: 2022-07-05 18:18:07

Serilog is a robust API for logging with many configurations and sinks (outputs) and it is straightforward to get started in any .NET version.

> Originally posted at https://rmauro.dev/setup-serilog-in-net6-as-logging-provider/

With `.NET 6` the way we used to configure `Serilog` as a logging provider in .NET 5 it is gonne (no more, no way sir, no no, good bye), it's no longer there.   
Bootstraping a `.NET 6` application is difference from older version but still pretty easy.

> Like many other libraries for .NET, Serilog provides diagnostic logging to files, the console, and [**elsewhere**](https://github.com/serilog/serilog/wiki/Provided-Sinks). It is easy to set up, has a clean API, and is portable between recent .NET platforms. _Unlike_ other logging libraries, Serilog is built with powerful _structured event data_ in mind.

_Words from_ [https://serilog.net/](https://serilog.net/)

Let's set up **Serilog** as **Logging Provider** in the native logging system in `.NET` so you can use the Microsoft `ILogger` interface.

```csharp
namespace Microsoft.Extensions.Logging
{
    public interface ILogger<out TCategoryName> : ILogger
    {
    }
}
```

_Microsoft ILogger<T> interface_

## Enough with the words - show me the code

In the `Program.cs`add these code changes.

```csharp
using Serilog;

//create the logger and setup your sinks, filters and properties
Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .CreateBootstrapLogger();

var builder = WebApplication.CreateBuilder();
//after create the builder - UseSerilog

builder.Host.UseSerilog();

//redacted code
```

_Program implementation with Serilog_

With the changes made until here we can inject the `ILogger`interface and use **Serilog** as a _log provider_.

## Breaf Explanation

Set up the global variable _Serilog.Logger_ with the sink `Console` and bootstrap a logger.

```csharp
//create the logger and setup your sinks, filters and properties
Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .CreateBootstrapLogger();
```

Them we have added `Serilog` as Logging Provider in native logging system.

```csharp
builder.Host.UseSerilog();
```

## Output

![Set up Serilog in .NET 6 as logging provider](https://res-1.cloudinary.com/dgoa5llvh/image/upload/q_auto/v1/ghost-blog-images/serilog-sample-output.png)
_Serilog Output Sample_

Again - All done here. If you like it **Subscribe** for more.

> Originally posted at https://rmauro.dev/setup-serilog-in-net6-as-logging-provider/
Looking for the latest news? Check out Proper News Time!
Tags: news
Published: 2022-07-05 18:13:19

This is [ProperNewsTime.com](https://propernewstime.com/) (PNT). We curate breaking news from thousands of sources and showcase some of it here on our website. In addition, we also have an app with other fun features that make it easier than ever before to stay informed and entertained during your busy day.

If you are a news lover and want to keep up with the latest news, you should check out Proper News Time, the web’s #1 source for keeping up with the world around you! Whether it’s local, national, or international news that interests you, Proper News Time has it all! With original stories written daily by our staff writers and reporting directly from top news agencies worldwide, such as Reuters and AP, Proper News Time will keep you informed and in the know on everything happening today! When you visit Proper News Time, we promise you’ll be back tomorrow!

## Are you a news lover

I do, and I like new experiences. That’s why I’m a big fan of travel. Few things in life are more exciting than taking off on an adventure to someplace you haven’t been before. This site is exactly what it sounds like—it publishes articles and videos related to travel, one of my favorite subjects in life. Whether you want travel tips or want to read about someplace new and exciting, Proper News Time has plenty to offer. And if you’re not, there’s no need to worry because they also have sections dedicated to tech, science, health, money, and sports. The great thing about Proper News Time is that they don’t focus solely on covering breaking stories—they also feature a section called Letters from Readers. They allow people from all over the world to submit questions about their local area or just general travel questions they might have.
Top 7 Featured DEV Posts from the Past Week
Tags: top7
Published: 2022-07-05 17:55:21

---
title: Top 7 Featured DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week
tags: icymi 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---

_Every Tuesday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week._ 

## Reflecting and learning

@princewhyte2 looked back on everything they've learned so far as a programmer and summarized what they wish thy knew when they were starting out. Super helpful!

{% embed https://dev.to/princewhyte2/what-every-newbie-developer-should-know-mic %}


## Let's talk about <!DOCTYPE html>!

@aman894 helps us understand the importance of the <!DOCTYPE html> statement. Congrats to them on their first post on DEV!

{% embed https://dev.to/aman894/what-the-hell-is-doctype-html-32om %}


## Visualizing pattens

Congrats to @eevajonnapanula for this awesome #showdev post — and more importantly, for their new sweater design site!

{% embed https://dev.to/eevajonnapanula/how-i-created-neuleart-cgp %}


## "Git commit messages are how we communicate to our future selves." 

@simeg explains why git commit messages are important and how you can improve yours. 

{% embed https://dev.to/simeg/write-git-commit-messages-that-your-colleagues-will-love-1757 %}


## Accessibility: the what, why and how

Thank you to @yuridevat for explaining what accessibility is, why it's important and how we can achieve accessible design.

{% embed https://dev.to/yuridevat/accessibility-the-what-why-how-3034 %}


## Docker Primer

@roselinebassey explains the basics that can help you get started with Docker. We all could benefit from this sound advice at one point or another!

{% embed https://dev.to/roselinebassey/introducing-docker-concepts-containers-and-more-17hc %}


## Fun with design

@riapacheco shows us how to create a line chart "in a style that's all the rage in cryptocurrency dashboard design and optimized for user interaction."

{% embed https://dev.to/riapacheco/making-pretty-responsive-charts-with-angular-v14-and-ng2-charts-v310-4ibh %}


_That's it for our weekly Top 7 for this Tuesday! Keep an eye on dev.to this week for daily content and discussions...and be sure to keep an eye on this series in the future. You might just be in it!_
3 JS Interactions
Tags: javascript, alert, prompt, interactions
Published: 2022-07-05 17:51:35

## 1. alert
shows a message.

`alert("Hello");`

!["JavaScript alert"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7vt5ss5camuy64we9oah.png)
 

## 2. prompt
shows a message asking the user to input text or null.


`var name = prompt("What is your name?");`

!["JavaScript prompt"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v19ee4ip7qij2t3b4qf0.png)

> Note: You can add an optional second parameter, the initial value for the input field.

`var name = prompt("What is your name?", "John");`

!["JavaScript prompt with default value"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55g315ukqhioz3g9xog7.png)

## 3. confirm
shows a message and waits for the user to press "OK" or "Cancel". It returns "true" for OK and "false" for Cancel.

`var confirmation = confirm("Are you sure?");`

!["JavaScript confirm"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgdlyb54bzxfjd0fng99.png)
Portals & useRef in React
Published: 2022-07-05 17:37:48


_During my foundational time, I'm going to write notes on what I studied and learned._

These notes were taken while watching the Front End Masters course "Complete Intro to React, v7" by Brian Holt.

## What is a portal?
A portal is a mount point, separate from the actual DOM which the app is put into (root in index HTML), for the React app. 

A common use case for this is a modal (a child window that pops up). 

## Adding the portal
First, add the modal into index.html with a separate mount point
```
<!-- above #root -->
<div id="modal"></div>
```
Make a new file called Modal.js
```
import React, { useEffect, useRef } from "react";
import { createPortal } from "react-dom";

const Modal = ({ children }) => {
  const elRef = useRef(null);
  if (!elRef.current) {
    elRef.current = document.createElement("div");
  }

  useEffect(() => {
    const modalRoot = document.getElementById("modal");
    modalRoot.appendChild(elRef.current);
    return () => modalRoot.removeChild(elRef.current);
  }, []);

  return createPortal(<div>{children}</div>, elRef.current);
};

export default Modal;
```
The div container is what renders inside of the Portal. 

Need to render to the portal spot on the DOM.

Need to remove the div afterwards. You do this by returning a function. This function will get invoked when the Modal goes away. 

## What is a ref?
You use ref when you want to refer to the same thing across all things rendering. 

It is essentially a pointer to an object with a current property, and when you update the ref, you update the current property.

It will never cause your component to re-render because it is completely separate from the component render cycle, unlike state variables.

##Adding code for modal toggle
```
// at the top
import Modal from "./Modal";

// add showModal
state = { loading: true, showModal: false };

// above render
toggleModal = () => this.setState({ showModal: !this.state.showModal });

// add showModal
const { animal, breed, city, state, description, name, images, showModal } =
  this.state;

// add onClick to <button>
<button onClick={this.toggleModal} style={{ backgroundColor: theme }}>
  Adopt {name}
</button>;

// below description
{
  showModal ? (
    <Modal>
      <div>
        <h1>Would you like to adopt {name}?</h1>
        <div className="buttons">
          <a href="https://bit.ly/pet-adopt">Yes</a>
          <button onClick={this.toggleModal}>No</button>
        </div>
      </div>
    </Modal>
  ) : null;
}
```
Leetcode Solutions: Last Stone Weight
Tags: leetcode, programming, python
Published: 2022-07-05 16:42:15

You are given an array of integers stones where stones[i] is the weight of the ith stone.

We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x <= y. The result of this smash is:

If x == y, both stones are destroyed, and
If x != y, the stone of weight x is destroyed, and the stone of weight y has new weight y - x.
At the end of the game, there is at most one stone left.

Return the weight of the last remaining stone. If there are no stones left, return 0.




```py
class Solution(object):
    def lastStoneWeight(self, stones):
        """
        :type stones: List[int]
        :rtype: int
        """
        
        stones = [-stone for stone in stones]
        
        heapq.heapify(stones)
        
        
        while len(stones) > 1:
            first  = heapq.heappop(stones)
            second = heapq.heappop(stones)
            
            if second > first:
                heapq.heappush(stones, first-second)
        
        
        return -stones[0] if len(stones) else 0
    
    

```
Python Exercise 21: list comprehensions
Tags: python, beginners, challenge
Published: 2022-07-05 16:36:31

## Question
You are given three integers (x,y,z) representing the dimensions of a cuboid along with an integer n .
- Print a list of all possible coordinates 
	- given by  (i, j , k) in a 3D grid 
	- where the sum of  i+j+k is not equal to n. 
	- i.e. can be greater than or smaller than n
- Here 0<=i<=x; 0<=j<=y; 0<=k<=z
- Please use list comprehensions
- Print the list in lexicographic increasing order.

## **Example**   
   
x = 1
y = 1
z = 2
n = 3  

- All permutations of (i, j, k)  are:   

```python
[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 0], [0, 1, 1], [0, 1, 2], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 1, 0], [1, 1, 1], [1, 1, 2]]
```
- Print an array of the elements that sum of i, j, k does not equal to n (The required output)

```python
[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 2]]
```

## My solution
- code

```python
	# make list of all x,y and z possible number
    x = int(input())
    y = int(input())
    z = int(input())
    n = int(input())
    x = [i for i in range(x+1)]
    y = [i for i in range(y+1)]
    z = [i for i in range(z+1)]
    # for each combination of i,j,k will form a sublist in the final_list, and sum of i,j,k will not equal to n
    final_list = [[i,j,k]for i in x for j in y for k in z if (i+j+k)!=n]
    print(final_list)
```

## Other solution
- a shorter version

```python
x = int(input())
y = int(input())
z = int(input())
n = int(input())
# for each combination of i,j,k will form a sublist in the final_list, and sum of i,j,k will not equal to n
final_list = [[i,j,k]for i in range(x+1) for j in range(y+1) for k in range(z+1) if (i+j+k)!=n]
print(final_list)
```
## My reflection
- The first time to try problem need to obtain variable form standard input
- good exercise. 
- The first time to use multiple for loop in list comprehension.

## Credit
challenge on [hackerrank](https://www.hackerrank.com/challenges/list-comprehensions/problem)
Move out of stock items to the end of the loop in WooCommerce
Published: 2022-07-05 16:36:00

Lot's of times your out of stock items are still bringing in SEO traffic so you want to keep them in your shop. If you have a large store, and products go in and out of stock all the time, it can be a UX nightmare for customers to constantly get shown out-of-stock products in their searches. 

The fix is to move the out-of-stock products to the end of the loop, with this custom snippet in your functions.php. We're using this exlusively on [Wine N Liquor](https://winenliquor.com/alcohol-delivery-nyc/) which has over 15,000 products on the store and hourly stock updates.

```
add_filter( 'woocommerce_get_catalog_ordering_args', 'seanaus120_first_sort_by_stock_amount', 9999 );
 
function seanaus120_first_sort_by_stock_amount( $args ) {
   $args['orderby'] = 'meta_value';
   $args['order'] = 'ASC';
   $args['meta_key'] = '_stock_status';
   return $args;
}
```

Currently in use at:
[Wild Posting](https://wildposters.com/wild-posting/)
[Gorilla Printing](https://gorillaprinting.com/wild-posting/)
[Wine N Liquor](https://winenliquor.com/alcohol-delivery-los-angeles/)
[Wheatpaste Posters](https://gorillaprinting.com/wheatpaste-posters/)
[Wheatpaste Posters](https://www.printingnewyork.com/product/wheatpaste-posters/)
[Poster Printing](https://wildposters.com/poster-printing-nyc/)
[Poster Printing NYC](https://www.printingnewyork.com/poster-printing-nyc/)
[OOH Marketing](https://wildposters.com/ooh-marketing/)
[Million Dollar Club](https://milliondollargiftclub.com/)
[Gift Ideas](https://milliondollargiftclub.com/gifts-for-the-impossible-man/)
[Dark Fibre](https://ucg.com.au/dark-fibre/)
[Hybrid Fibre-Coaxial](https://ucg.com.au/hybrid-fibre-coaxial/)
[Window Advertising](https://www.printingnewyork.com/window-advertising/)
[Window Graphics](https://wildwindowgraphics.com/)
[Window Wraps](https://wildwindowgraphics.com/window-wraps/)
[Window Stickers](https://wildwindowgraphics.com/window-stickers/)
evisio - Prioritize SEO results
Tags: seo
Published: 2022-07-05 16:31:13

evisio gives SEO teams a central hub for auditing, analyzing, organizing, and executing tasks so that more gets done in less time without anything falling through the cracks. As a client management platform, it crawls your client’s website, uses found crawl issues to automatically create tasks, and brings your team together to tackle projects. Simply log in to your evisio dashboard, select an SEO project, and pick up on a task where you left off.[](https://evisio.co)