teleren/devto huggingface dataset:
Making HTTPD Service Idempotent Using Ansible
Tags: httpd, ansible, linux, devops
Published: 2021-03-26 02:28:46

Hello Readers😊,

After Reading This Article, You will be able to make the httpd service idempotent using Ansible. You can Read my previous article to know more about Ansible.
Link: https://dev.to/piyushbagani15/ansible-in-action-how-aws-is-solving-challenges-using-ansible-oll


So, without any further delay let’s get started.
#What is Idempotence??

In general, Idempotence is “the property of certain operations in mathematics and computer science that can be applied multiple times without changing the result beyond the initial application”. In Ansible it means after running a playbook to set things to a desired state, further runs of the same playbook should result in no changes.

Let’s say we ran an ansible-playbook previously and did some changes afterwards but if some service like httpd is started in previous run is started, according to particular task written then it won’t restart in next run and hence the changes made had no effect on the system. Also When we run ansible-playbook for restarting the service of httpd. It will again restart the service at the target node but we want the service to only restart when I make any change to configuration files otherwise it will not restart the service of httpd and save the compute resources.

To solve this kind of Use case we use handlers and notify in Ansible.
##Handlers in Ansible

Sometimes you want a task to run only when a change is made on a machine. For example, you may want to restart a service if a task updates the configuration of that service, but not if the configuration is unchanged. Ansible uses handlers to address this use case. Handlers are tasks that only run when notified.

So We can Write the Ansible Playbook to demonstrate the use of handlers and making httpd service idempotent.
You can see the ansible-playbook by clicking on the link provided below.
Link: https://github.com/PiyushBagani15/Ansible_handlers
After Running this playbook, it is clearly visible that We can restart the httpd service in an idempotence nature.

I am attaching some images to see how this playbook runs.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3l23rbyh17syhruv7vnp.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0fztwqtr74w981qpuh8.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/879vb3t4iplgfu33b841.png)
Mainly,We have configured Apache Webserver using Ansible and made the httpd service idempotent. The Final Result we get after visiting the WebPage is as follows:
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gd1nlfhxjqgcz59dxb5n.png)
##So, That’s It. Thank You Everyone for Reading.
##Keep Learning, Keep Hustling🎯
A short guide to Object creation pattern in JavaScript
Tags: webdev, javascript, programming, codenewbie
Published: 2021-03-26 02:14:58


Object creation mechanisms increase the flexibility and reuse of existing code. Here in this post, we will see the Object Creation Pattern in JavaScript. 

---

Some patterns to create an object are: 

- Factory pattern
- Constructor pattern
- Prototype pattern
- Constructor / Prototype pattern

--- 

## Factory Pattern

The factory pattern uses a function to abstract away the process of creating specific objects and returning their reference. It returns a new instance whenever called. 

```javascript
function createFruit(name) {
    const obj = new Object(); 
    obj.name = name; 
    obj.showName = function () {
        console.log("I'm " + obj.name); 
    }
    return obj; 
}

const fruitOne = createFruit('Apple'); 
const fruitTwo = createFruit('Orange'); 

fruitOne.showName(); // I'm Apple
fruitTwo.showName(); // I'm Orange

```

--- 

## Constructor Pattern

In the constructor pattern, instead of returning the instance from the function, we use the new operator along with the function name. 

```javascript
function createFruit(name) {
    this.name = name; 
    this.showName = function () {
        console.log("I'm " + this.name); 
    }
}

const fruitOne = new createFruit('Apple'); 
const fruitTwo = new createFruit('Orange'); 

fruitOne.showName(); // I'm Apple
fruitTwo.showName(); // I'm orage
```

--- 

## Prototype Pattern

The prototype pattern adds the properties of the object to the properties that are available and shared among all instances. 

```javascript
function Fruit(name) {
    this.name = none; 
}

Fruit.prototype.showName = function() {
    console.log("I'm " + this.name); 
}

const fruitOne = new Fruit('Apple'); 
fruitOne.showName(); // I'm Apple

const fruitTwo = new Fruit('Orange'); 
fruitTwo.showName(); // I'm Orange

```

--- 

## Constructor / Prototype pattern

This is a combination of the constructor and prototype patterns. The constructor pattern defines object properties, while the prototype pattern defines methods and shared properties. 

```javascript
function Fruit() { }

Fruit.prototype.name = name; 
Fruit.prototype.showName = function () {
    console.log("I'm " + this.name); 
}

const fruit = new Fruit(); 
fruit.name = 'Apple'; 
fruit.showName(); // I'm Apple

```

--- 

😎Thanks For Reading | Happy Coding😊


<a href="https://buymeacoffee.com/rahxuls" target="_blank">
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1616209806065/A24KTdOi6.png?auto=compress">
</a>
GTA V Loading Time Fix Explained- AKA Why Big O Matters
Tags: webdev, tutorial, javascript, career
Published: 2021-03-26 01:29:11

You may have heard in the news how a single programmer was able to reduce the loading time on GTA V online by 70%. In this video I explain how he did it and summarize what was wrong with GTA's code.

I hate a lot of the Leetcode style coding interviews companies use like most software engineers, **but this is a good example of why knowing even some basic data structures and algorithms is pretty important.**

The bigger issue in this case is that nobody at Rockstar games took a few hours to fix this simple issue despite having 7 years to do it.

{% youtube JYC3BqDBKRo %}

If you are interested in another practical example to get yourself motivated learn data structures and other CS fundamentals, you can check out my video showing how switching 1 line of code can speed up this example code by 30X in this article:

{% post https://dev.to/renaissanceengineer/real-world-data-structures-30x-faster-with-1-loc-2251 %}

I generally follow the 80/20 rule, even a small amount of time spent learning these CS fundamentals can dramatically improve the performance of your code.
DOM and the manipulation that comes with it// A beginners look at JS
Tags: javascript, beginners
Published: 2021-03-26 00:51:45

As I thought about what to write, I decided to write something that could possibly aid future developers that may need help with this topic. This will be the beginning of a series of JS beginner blogs that hopefully will help you get a little bit higher up that mountain that you CAN conquer. Ready? Let's do this!

The DOM...the document object model, chances are if you've messed with javascript you've definitely heard of it before. Often times it is said so much when talking about code as a beginner it's easy to just go along with discussions pretending that we really know what it is when in reality it can still be a bit foggy to us. As a fresh Bootcamp graduate, I can easily recall being in those shoes, but as I've given JS some serious bonding time I'm beginning to gain some familiarity with both the DOM and DOM manipulation that is made possible with javascript.

So...What is the DOM? I like to think of the DOM as the browser's copy of the HTML file that's in use. This copy allows for JS manipulation while keeping the original HTML file pure. For example, lets consider an HTML file:

![Screen Shot 2021-03-18 at 3.01.24 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mrue1kx39r5l671kttz3.png)

This code translates to this in a browser:![Screen Shot 2021-03-18 at 2.59.23 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/koyp3cqfe2isz2jl8ojp.png)

With this, we have a text box that allows us to put in some text, in this case, a phrase. The functionality we're expecting is when we press submit we add that text string to the page, hence the empty div with an id of "phraseHere".  In this case, the user will put "Hello World", but it should not affect the original HTML document.

![Screen Shot 2021-03-18 at 2.59.36 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7v73q3a9hfgqkevv8pp.png)

![Screen Shot 2021-03-18 at 2.59.44 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1yfkfj2drbzx0qbyge63.png)

Just like that we've added text to the DOM. We can see proof of this looking at the console:

![Screen Shot 2021-03-18 at 3.01.08 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1n7iot8q6ilfxrrxq4l.png)

So the next question is How did we accomplish this task? Tune in next week where we'll discuss an amazing function called .addEventListener(think of it like big brother for your HTML documents)
Fish-like Autosuggestion in Powershell
Tags: powershell, autosuggestion, shell, windows
Published: 2021-03-26 00:23:15

---
title: Fish-like Autosuggestion in Powershell
published: true
description: 
tags: powershell, autosuggestion, shell, windows
//cover_image: https://direct_url_to_image.jpg
---
_For a year, working on Windows laptops has been nonoptional for me. I've been desperately trying to make my environment as close as it is on Mac OS, with the added challenge to do it without the Windows Subsystem for Linux (WSL). So this relies heavily on Powershell._

One thing I like from the [fish shell](https://fishshell.com/) (and was reproduced in zsh by the [zsh-autosuggestion plugin](https://github.com/zsh-users/zsh-autosuggestions)) is the autosuggestion feature.  
It's that thing where when you start typing something and there is something that starts with the same letters in your history, it'll write it after the cursor in grayed colors. And it's awesome.

<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>

For Powershell, it´s called [predictive IntelliSense](https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/) in PSReadLine.

## Prerequisites

* Powershell 5.1 or higher

## Installation

1. First, install ´PSReadLine´ version 2.1.0
    ```
    Install-Module PSReadLine -RequiredVersion 2.1.0
    ```
1. Then, initialize it with the command below
    ```
    Import-Module PSReadLine
    Set-PSReadLineOption -PredictionSource History
    ```

And there it is!

## (Optional) Initialize it in your profile

1. Check if you already have a profile
    ```
    Test-path $profile
    ```
1. If false, create one
    ```
    New-item –type file –force $profile
    ```
1. If yes, edit it
    ```
    notepad $profile
    ```
1. Run this command and close your terminal
    ```
    Set-ExecutionPolicy RemoteSigned
    ```
1. Update your profile file like in step 3, and add those lines to it
    ```
    Import-Module PSReadLine
    Set-PSReadLineOption -PredictionSource History
    ```

And that's it!

![Autosuggest in Powershell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0yg202h1ju1o1cd4aeb.gif)
#DockerSP - Entendendo o ecossistema de containers além do Docker
Tags: docker, containers, containerd
Published: 2021-04-12 16:49:13

---
title: #DockerSP - Entendendo o ecossistema de containers além do Docker
published: true
date: 2021-03-26 00:20:12 UTC
tags: docker,containers,containerd
canonical_url: https://blog.lsantos.dev/dockersp-entendendo-o-ecossistema-de-containers-alem-do-docker/
cover_image: https://raw.githubusercontent.com/khaosdoctor/blog-assets/master/images/2021/03/Ew60WJeXIAAqZQa.jpg
---

Hoje tive o grande prazer de estar com a galera do [DockerSP](https://www.meetup.com/Docker-Sao-Paulo/) para falar um pouco mais sobre o ecossistema de containers! Neste vídeo vamos dar uma pincelada mais profunda sobre o que falei [neste post](https://dev.to/azure/controlando-containers-de-dentro-sua-aplicacao-com-containerd-201l), dando um pouco mais de contexto e história!

<!--kg-card-begin: html--><iframe width="560" height="315" src="https://www.youtube.com/embed/gAcTFfTL1NU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><!--kg-card-end: html-->
## Veja os slides
<!--kg-card-begin: html--><iframe frameborder="0" src="//speakerdeck.com/player/e21b68c7db134ade9b2dad81246a3e53?" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="border: 0px;background: padding-box rgba(0, 0, 0, 0.1);margin: 0px;padding: 0px;border-radius: 6px;box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px;width: 710px;height: 390px;"></iframe><!--kg-card-end: html-->
## Links de referência dos slides:

- [Artigo sobre uma história dos containers e todo o ecossistema](http://bit.ly/lsantos-containers)
- [Link para o artigo sobre containerd](http://bit.ly/lsantos-containerd)
- [Artigo sobre a história do Docker no FCC](http://bit.ly/fcc-docker)

Logo mais estarei colocando mais conteúdo aqui sobre como podemos conectar os mundos de containers e desenvolvimento!
CSS repeating-conic-gradient() function
Tags: codepen, css, frontend
Published: 2021-03-26 00:15:15

Trippy realistic metallic background built with new CSS function `repeating-conic-gradient()`. 

Check browser support here: <a href="https://caniuse.com/css-conic-gradients" target="_blank">https://caniuse.com/css-conic-gradients</a>

{% codepen https://codepen.io/nikolab/pen/oNBbEWJ %}
How to get the uptime of the system using Node.js?
Tags: node
Published: 2021-03-26 00:00:00

---
  title: How to get the uptime of the system using Node.js?
  published: true
  tags: Nodejs
  date: Fri Mar 26 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-the-uptime-of-system-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-6d751ec103017e6f1927fd6167c41a36.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-the-uptime-of-system-nodejs)
  
To get the uptime of the system, you can use the `uptime()` method from the `os` module in Node.js.

```js
/* Get uptime of system Node.js */

// import os module
const os = require("os");

// get the uptime of system
const uptime = os.uptime(); // 22345
```

- The method returns the uptime of the system or time awake in `seconds`.

See the above code live in [repl.it](https://replit.com/@melvin2016/get-uptime-of-system-nodejs).

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

---
How do we know if we're doing CI?
Tags: cicd, devops
Published: 2021-03-28 08:25:11

---
title: How do we know if we're doing CI?
published: true
date: 2021-03-26 00:00:00 UTC
tags: cicd, devops
canonical_url: https://jhall.io/archive/2021/03/26/how-do-we-know-if-were-doing-ci/
---

Martin Fowler’s widely-accepted [definition of Continuous Integration](https://www.martinfowler.com/articles/continuousIntegration.html) says:

> usually each person integrates at least daily

The ambiguity around “usually” and “at least” leaves this somewhat open to interpretation, and the common question:

> Is my team really doing CI?

Rather than dwelling on a specific definition of CI, I think it can be useful to focus on the _reasons_ we care about CI. There are many benefits you might gain from CI, but let’s look at one of the big ones. In [Extreme Programming Explained](https://amzn.to/3rdRXRI) Kent Beck explains one of the dangers of deferred integration:

> The integration step is unpredictable, but can easily take more time than the original programming. The longer you wait to integrate, the more it costs and the more unpredictable the cost becomes.

Why does deferred integration takes longer, and why is it unpredictable?

In a word: conflicts.

Not _just_ merge conflicts of the type git complains about, though, although those certainly are salient. You can also experience behavioral conflicts. An example might be Bob adding support for a new authentication provider, meanwhile Alice is removing authentication support entirely in a parallel branch. The two changes may have no lines, or even files, in common, so they may merge cleanly, but they clearly conflict.

With this in mind, I’d reframe the question. Rather than asking “Is my team really doing CI?” I’d ask “Is my team avoiding conflicts?”

If you’re the only developer working on a project, it may be sufficient to integrate weekly, for example. On the other hand, if you’re on an especially busy project, maybe integrating 10 times daily is not sufficient to avoid painful conflicts.
Recording screen, mic input and audio output with one app
Tags: mac, capture, screen, audio
Published: 2021-03-26 22:37:39

---
title: Recording screen, mic input and audio output with one app
published: true
date: 2021-03-26 00:00:00 UTC
tags: mac, capture, screen, audio
canonical_url: https://iliascreates.com/record-screen-audio-input-output/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6wn1srjmi1rx775862g.png
---

I’ve been for years a very happy user of [Kap](https://getkap.co/), a free open-source app to record the screen of my MacBook.

Recently I wanted to perform some interviews during a requirements gathering process for a new project at work. I needed a way to record my screen, my voice but also the voice of the interviewee. Essentially I needed to capture:

- Screen
- Audio input
- Audio output

So, as usual, I started with a simple [Google search](https://www.google.com/search?q=record+screen+audio+input+and+output+mac&sxsrf=ALeKk03pGfOhM0PDc64SpqsGcRIu_a3Tkw%3A1616781405527&ei=XSBeYLnAH4X0kwXXk4TYDw&oq=record+screen+audio+input+and+output+mac&gs_lcp=Cgdnd3Mtd2l6EAM6BwgAEEcQsANQurYQWLq2EGDGuhBoA3ACeACAAVuIAZ4BkgEBMpgBAKABAaoBB2d3cy13aXrIAQjAAQE&sclient=gws-wiz&ved=0ahUKEwj54uuKxM7vAhUF-qQKHdcJAfsQ4dUDCA0&uact=5) to see what is out there. I found many solutions that required downloading some apps (like [Soundflower](https://github.com/mattingalls/Soundflower), [LoopBack](https://rogueamoeba.com/loopback/) or [ScreenFlow](https://www.telestream.net/screenflow/)) and use some of them in combination with Quicktime Player, a native macOS app.

5 minutes had passed and I already felt overwhelmed. I thought this was gonna be easier. And then it hit me: _“Why haven’t you checked if Kap can do that?”_. Dah!

> All I literally had to do was to go to the preferences of the app and turn 2 toggles on.

1. Enable **Audio recording** from the General tab
2. Enable the **soundflower plugin** from the Plugins tab

Finito.

[![Kap general preferences tab](https://iliascreates.com/static/2d412def287cfcdf24aec2dedaad4a6b/f058b/general-preferences.png "Kap general preferences tab")](/static/2d412def287cfcdf24aec2dedaad4a6b/7321b/general-preferences.png)

[![Kap plugin preferences tab](https://iliascreates.com/static/85a426bb4392aabd111ef151615d868a/f058b/plugin-preferences.png "Kap plugin preferences tab")](/static/85a426bb4392aabd111ef151615d868a/7321b/plugin-preferences.png)
Django Class Views vs Function Views
Tags: django, python, functional, codenewbie
Published: 2021-03-25 23:26:08

Hello everyone and thank you for stopping by to see what it is I have to say. This is a topic I hear a lot about regarding to Django and I would just like to put my 2 cents in. 

# The DRY Concept

I'm starting off with this topic because it sets the tone for what I speak on next. A lot of you well developed developers know exactly what this means, but for those who don't... DRY - "Don't Repeat Yourself". Definition of insanity plays well with this concept if you'd ask me. I bring this topic up because its self explanatory. Don't repeat yourself when you are developing code if you can avoid it.

# Class Based Views
At the core, class based views are simply python classes. Django does an amazing job shipping a variety of "template" class based views that have configured functionality that you can reuse as much as you want. When creating forms in Django, especially if it is a form that's being used multiple times, there's no reason to recreate something you can make once. This approach also helps with responding to different https requests with different class instances instead of using conditionals inside a single function based view.

**Class Based Views Example**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mn7z9rtn5t7z8sfxdr84.png)

#Function Based Views
I won't rule out function based based views too much. Some people are more comfortable with writing their own functions instead of writing classes essentially. I will say function views are easy to implement, but that's about all I can really say about it. The main disadvantage is if you are working on a large project then you will see a lot of repetitive code within your views. 

**Function Based Views Example**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08w48uru35dedbfmd3g8.png)

#Conclusion
Now I know I can go deeper into this conversation with explaining pro's and con's using either method of creating your Django views, but I wanted to just point out the obvious that will be brought up in a conversation. As a junior developer I've always been told to keep things simple, but don't repeat yourself. When you keep things simple and create re-usable code you open up the door to having the flexibility to increase or decrease functionality. 

I hope you guys enjoyed this quick snippet and I thank you for taking the time out to see what I have to say. Let me know if you guys agree or disagree in the comments and let's talk more about it or hit me up on twitter(@jcyber101). Cheers!
Build problem of scss in Next
Published: 2021-03-25 23:23:56

Hi everyone,

I encountered a problem when I use npm run build within NEXT.js. I can not get index.css although I written the rule such as

path = require('path')

module.exports = {
sassOptions: {
includePaths: [path.join(__dirname, 'styles')],
},
}

Because of the above problem, I cannot generate css file, my website lost its style.

If you have any idea, please tell me how to fix this problem.
Thank you for your helping