teleren/devto huggingface dataset:
How to install terraform using ansible pull
Tags: ansible, terraform
Published: 2020-12-03 03:46:36

---
title: How to install terraform using ansible pull
published: true
description: ansible pull based installation of app
tags: #ansible #terraform
//cover_image: https://direct_url_to_image.jpg
---

Recently, i have learnt how to use ansible pull from youtube videos, and tried practically.

I have created terraform installation ansible playbook, that will execute with ansible pull.

By executing below playbook from anywhere, that will connect to AWS EC2 instance and it will pull terraform installation and will install terraform automatically in aws ec2 instance, and it will create a cron job as well.

Create a pre-requiste playbook as below.

main.yaml
```
---
- hosts: servers
  remote_user: centos
  become: true
  become_method: sudo
  gather_facts: no
  tasks:
    - name: Install pip on the servers
      yum:
        name: python-pip
        state: latest
        update_cache: true
      become: true

    - name: Install pip3 on the servers
      yum:
        name: python3-pip
        state: latest        
      become: true

    - name: Ensure ansible is installed on servers
      pip:
        name: ansible

    - name: Executing ansible-pull on servers
      command: ansible-pull -U https://gitlab.com/hemanth22/ansible-pull-terraform.git

```
inventory
```
[servers]
34.221.246.71
[servers:vars]
ansible_python_interpreter=/usr/bin/python
ansible_ssh_private_key_file=~/.ssh/filename.pem
```

ansible.cfg
```
[defaults]
log_path = /var/log/ansible.log
command_warnings = False
system_warnings = False
action_warnings = False
```

Command to install execute ansible pull.

`ansible-playbook main.yml -i inventory`
How to Dockerize a NodeJs App
Tags: docker, beginners, javascript, node
Published: 2020-09-21 13:44:10

Docker is an essential tool when it comes to the deployment and delivery of an Application. 
>The main idea of docker is to create a package of your code along with dependencies into a unit called a container. It's a way to package software so that it can run on any hardware

[To know more about docker](https://www.docker.com/why-docker)

[To know more about the Installation process of Docker Desktop](https://docs.docker.com/get-docker/)

This blog covers the steps of adding docker to your application.

Before moving forward we need to understand 3 important components of docker.
* DockerFile **is a blueprint to create a Docker Image**
* Docker Image **is a template to run docker Containers**
* Docker Container **is a running process/application**

I have a simple Node JS application with an index file which exposes a get API which sends a response message of
 ```Docker is easy to learn 🐳``` and runs on port 8080.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ivb5hkmk28bmzrq6u1qi.png)

The First step is to create a docker file in the root folder of the Project.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9cn29k93zc0snpkwentm.png)

In the docker file, the very first instruction is `FROM` used for installing NodeJs Base Image which helps in setting up an environment to run NodeJs Application.

The next instruction `WORKDIR` is used to set the working directory of a Docker container.

`COPY` uses two arguments the source and destination path which copies the package.json file to the current working directory.

`RUN` opens a terminal session and install dependencies listed in package.json.

`COPY . .`  Copies local file to the Working directory

> A .dockerignore file needs to be created similar to .gitignore 
 inorder to exclude node_modules folder.

`ENV` instruction is used to set the environment variable.

`EXPOSE` instruction informs Docker that the container listens on the specified network ports at runtime.

`CMD` final instruction tells the container how to run the application.

> Every instruction in the docker file is considered as a layer, the layers are cached when nothing is changed in the Dockerfile 


The next instruction is to create a docker image that can be created using the following command.
``` docker build -t  username/imagename . ```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ff0giy1jo2maik6ydapj.png)

All instructions in the DockerFile are executed to form the Image ID which is used to run a container.

The final step is to run the Docker Container with the help of the following command 

```docker run -p local-port:container-port image-id``` 

> -p flag is used for port forwarding.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/l0rjus8joc06kfvsla0h.png)

Now if we check the ``` http://localhost:5000 ``` We can find our application up and running

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jes7p7imslsr71vzl37u.png)


Thats all folks !!!
Creating a Google Hangout Bot with Express and Node.js
Tags: express, node, hangout
Published: 2020-09-22 10:28:27

---
title: Creating a Google Hangout Bot with Express and Node.js
published: true
date: 2018-06-06 00:00:00 UTC
tags: Express,NodeJS,Hangout
canonical_url: https://www.loginradius.com/engineering/blog/creating-a-google-hangout-bot-with-express-and-node-js/
---

Time Required: 20 minutes. Technologies: Express, Node.js, JavaScript. Prerequisites: Basic knowledge of Express, Node.js, and JavaScript. Node.js and npm are installed. This tutorial will go over how to build a bot that will respond to pings (i.e. @), and send messages to a chat…

   
[Read On](https://www.loginradius.com/engineering/blog/creating-a-google-hangout-bot-with-express-and-node-js/)
Just launched!! a11yresources - A growing list of accessibility tools & resources
Tags: a11y, inspiration, design, ux
Published: 2020-09-23 04:58:48

👋🏽 Hello Community!

Hannah here and I'm happy to be here sharing this awesome online resource that I've been working on. 

It started only as my online reference saved at my Notion's database becomes bigger and richer lists of all related to accessibility. That's when I decided to showcase it to the community and that's when a11yresources is born.

I'm still learning every day and committed on expanding a11yresources with more topics, categories, examples, and resources. Feel free to chat or contact me if you have any suggestions or any recommendations from the contact details I shared.

Feel free to share any resources, people to follow, and anything about accessibility to be included.

Thank you so much and thank you for your awesome support! As always!

Live on Product hunt! https://www.producthunt.com/posts/a11yresources

And you can head-out to http://a11yresources.webflow.io/ for more list of accessibility tools and resources :)

All the best,
Hannah
Is web security broken?
Tags: security, webdev, help
Published: 2020-11-26 08:38:38

Or just our approach to it?

Why does this subject, so fundamental, seem so hard?
- The internet, including DEV, is full of articles on security, JWT, cookies-good, cookies-bad etc.
- Some services (e.g. Azure Active Directory) seem to handle it all for you - but do they really? And when can you actually use this approach?
- Pretty much any article on the subject will come with a stream of comment and debate attached - doubt is sown...

What's a professional, let alone a beginner, to do?
Data URLs
Tags: dataurls, html, images
Published: 2021-05-20 17:20:37

---
title: Data URLs
published: true
date: 2021-05-20 17:00:58 UTC
tags: dataurls,HTML,images
description: How to add images directly to your HTML
canonical_url: https://blog.jws.app/2020/data-urls/
---

Previously, we talked about [CSS sprites](https://blog.jws.app/2020/css-sprites/) and a large benefit of it was that the user didn’t need to retrieve as many image files from the server.  This week, we are going to look at how to not need to retrieve **ANY** image files from the server.  The method is something called data URLs.  I used this concept five years ago with my [TNO encryption demo](https://github.com/steinbring/Keep-Calm-And-TNO).  Let’s take a look at a quick demo.

{% codepen https://codepen.io/steinbring/pen/PozeEbr %}

In the simple demo above, I base64 encoded a JPEG file and just included the full content of the file (using the `data:[<mime type>][;charset=<charset>][;base64],<encoded data>` syntax).  Let’s looks at one more example.

{% codepen https://codepen.io/steinbring/pen/MWeGrmJ %}

This one works the same basic way but instead of using a JPEG file, I’m using a PNG file.

So, why use this method?  The big reason is to have one fewer asset to load into the page.  You are still requiring the client to download the same amount of stuff but it is via one HTTP request instead of two.  I have also seen people use this method to more easily include graphics in HTML email messages.

Easy enough, right? 🙂  Have a question, comment, etc?  Feel free to leave a comment.


The post [Data URLs](https://blog.jws.app/2020/data-urls/) first appeared on [Blog.jws](https://blog.jws.app/).
How to for..of with your own objects in JS (iterable & iterator protocol) [LET'S CODE]
Tags: javascript, tutorial
Published: 2020-11-29 14:20:42

Generally and theoretically an iterator is an object that produces a sequence of values. Practically, an iterator can be used to loop over the items of a list. If we put both together, you could say that it _reproduces_ the list's sequence of items. And that's exactly what we're going to do with the doubly linked list from last time. Watch this episode of crayoncode and let's write some code together! ⌨️📐⚙️

{% youtube gjMD4SsGD9w %}

There are two important protocols that make for...of work: One is called _iterable_ and the other is called _iterator_.

The _iterable_ protocol states, that an _iterable_ object must have a function which is accessible through `Symbol.iterator`. This function does not take any parameters and returns a so-called `iterator`. 

An object is considered an `iterator` if it has a function called `next`. It also does not take any parameters and each time it's called, it must return an object of defined structure:

- The `value` property represents the current iteration's value, i.e. the element in the iterable structure (e.g. a list) the iterator is currently on.
- The `done` property tells the caller of the iterator if the iterator has reached the end of the iterable structure. If it is `true`, the `value` property can be omittted.

So, both of these protocols work closely together during the evaluation of a `for...of` loop.
Add Time from DevOps Dashboard with Timetracker 5.13
Tags: timetracking, productivity, devops, azure
Published: 2020-11-27 16:54:14

You can now not only start tracking from the work item context menu, you can also add time directly from there too!

With 7pace Timetracker’s 5.13 release, we’ve added the ability to “Add Time” on boards or queries.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ufedpm22cbj4sv2zx6zd.png)
*Click on the ellipses, highlight “7pace Timetracker” and then “Add Time”.*

Clicking “Add Time” will open the Add Time dialog, with the person field defaulting to the current user. For more information, click here.

We’re happy to report that 7pace Timetracker for DevOps Server (on-prem) now works correctly with HTTP (please use this method at your own risk with degraded security) in most modern browsers. You can find the post in our online community on this here.

We also fixed an issue where email notifications were not being sent when timesheets were submitted for approval or approved. (on-prem)

More details on all our current and past releases can be found [here](https://support.7pace.com/hc/en-us/sections/115000080746-Release-History).

**On-Prem Download**

Customers can [download](https://www.7pace.com/download) the latest release of 7pace Timetracker (on-prem) for DevOps Server for Windows.
______________________________________________________________
*[7pace Timetracker](https://www.7pace.com/) is the only integrated, professional time management solution for teams using Azure DevOps and GitHub.*

[![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0abhoy61sfwppfggxyhq.png)](https://www.7pace.com/)
SaaS: How to code the subscriptions business model. Elementary level
Tags: ruby, rails, saas, startup
Published: 2020-11-30 18:04:25

---
title: "SaaS: How to code the subscriptions business model. Elementary level"
published: true
description: 
tags: 
- ruby
- rails
- saas
- startup
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ms2kjkg8d68bsvez2y15.png
canonical_url: https://blog.corsego.com/how-to-code-the-subscription-business-model-saas-service-as-a-service-part-1
---

Software as a Service (SaaS) = leasing = access to software **with an end date**.

Client is `charged` to postpone the `end date`.

From this perspective, a "One-time payment" = subscription with lifetime access.

Minimalistic Database representation:

![subscription uml](https://dev-to-uploads.s3.amazonaws.com/i/mszx1pywcxv1fnn977ut.png)

### Example: Spotify subscription

In this case a user can buy a  `premium` subscription for `$12,11` for a limited time `1 month` to `remove adds`.

Here's how it will work:

```
# user.rb

#  email      :string
#  ends_at    :datetime

def premium_price
  # how much to charge for postponing ends_at
  # always keep money in integer. last 2 digits are cents
  1299.to_i 
end

def premium_interval
  # by how long to postpone the ends_at
  # monthly or yearly or forever
  1.month 
end

def active_subscription?
  ends_at > Time.now
end

def show_annoying_adds?
  # business logic
  unless active_subscription?
end
```

```
# charge.rb

# user_id     :integer
# amount      :integer # to track how much was paid at this moment of time

belongs_to :user
```

```
# charges_controller.rb

def create
  @charge.amount = current_user.premium_price

  # PAYMENT PROVIDER LOGIC GOES HERE

  if @charge.save
    current_user.update(ends_at: Time.now + current_user.premium_interval)
  end
end
```

This way whenever a user makes a payment and creates a `charge`, 
his subscription `ends_at` is set to a later date based on `premium_interval`.

Of course, in this simple example `charges` are not automatic and the user has to explicitly `create` a `charge`.

That's it! 🤠

Liked this article? Please follow me! It will really motivate me to post more fun stuff!
6 Tips for Becoming a Better Writer
Tags: writing
Published: 2020-12-01 18:34:32

Writing is best when it is easily understood by readers. Long sentences and fancy words do not make for a pleasant reading experience. Everything I write goes through an extensive editing phase to improve its readability.

Ernest Hemingway’s style was clear and direct. We can improve our own writing by applying some of his rules. Here are six tips you can start using today.

![Tip 1: Write for the average reader. The average person reads at a *tenth-grade level*. Text aimed at higher levels is confusing and tedious for many readers.](https://dev-to-uploads.s3.amazonaws.com/i/75br4mte4rgsbwh6he8x.png)

![Tip 2: Write like a regular person. Do not *utilize* big words when there are simpler alternatives. Prefer simple over complicated words, like “use” instead of “utilize”.](https://dev-to-uploads.s3.amazonaws.com/i/zrz7igmte6jt24e8ai1w.png)

![Tip 3: Use short sentences. *If you use a lot of very long sentences in your writing, your readers will have a hard time following them from beginning to end.* Split long sentences into many smaller ones.](https://dev-to-uploads.s3.amazonaws.com/i/os0awc6vvnaam8s6pvrc.png)

![Tip 4: Be bold. For a more assertive tone, *maybe* avoid weakening phrases. Remove qualifiers that make you sound unsure.](https://dev-to-uploads.s3.amazonaws.com/i/yua2v6inwi7heqr300nq.png)

![Tip 5: Show action. Rewrite all of your sentences that have *been written* in passive voice. Use active instead of passive voice.](https://dev-to-uploads.s3.amazonaws.com/i/y8dout3r0s63ok2c6ssg.png)

![Tip 6: Use fewer adverbs. While adding color, a lot of adverbs are *surprisingly* unnecessary. Most adverbs are not important and can be removed.](https://dev-to-uploads.s3.amazonaws.com/i/i5nj96ms42ivg4xda1xr.png)

![Bonus tip: Check your writing.](https://dev-to-uploads.s3.amazonaws.com/i/uf8q3e386i4pwi6c9an3.png)

[hemingwayapp.com](http://hemingwayapp.com) was inspired by Ernest Hemingway’s minimalist writing style.

I run my texts through it to learn which areas I need to rewrite. It shows which sentences are too long and which words have easier alternatives. After a few iterations, my posts and mails are much easier to read. It’s a fantastic tool I wouldn’t want to write without anymore. If you do any longform writing, give it a try. It is excellent for blog posts, emails, or documentation.

They have a paid downloadable version, but the free online version works just fine. As you use it, you will find that you get used to the patterns this leads you towards. Over time, your writing will naturally improve.
Create your first react native app with expo as a beginner.
Tags: react, javascript, tutorial, beginners
Published: 2020-12-02 07:04:32

In this post I will tell you how you can create your <strong>first React Native app with expo-cli</strong>.

As an advocate for <strong>cross platform development</strong> I am going to create a series of posts on React Native mobile app development and this post is a part of it.

Go to the app store in your mobile and download the expo app with the link given below,

[Expo app link](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en_IN)

![chrome-capture (54)](https://dev-to-uploads.s3.amazonaws.com/i/lemc30szhyuo8hwh8rg1.jpg)
   
After downloading it sign-up/sign-in into the app.

Then go to your terminal in your laptop and install expo-cli globally like below,


```js

npm install -g expo-cli

```

Then create your react-native-app with,

```js

expo init projectname

```
![Screen Recording 2020-12-02 at 12.02.04.45 PM](https://dev-to-uploads.s3.amazonaws.com/i/qf872rwjlx16hrdc4lyy.gif)

It will take some time to install all the dependencies.

Now after installing an expo app, cd into your project folder.

```js
cd project
```

Then run any one of the command given below based on your phone's operating system,

```js
npm run android
```

```js
npm run ios
```

After you run any one of the above commands, you will be redirected to a page like below.

![chrome-capture (23)](https://dev-to-uploads.s3.amazonaws.com/i/5yrul9gps3uqfc6v0fsv.gif)

You can either <strong>scan the QR code</strong> shown in the redirected with your expo app in your phone or <strong>plugin your mobile phone in to your laptop</strong> with an usb cable and the app will be built on your mobile and will display the app.js content in it.

And that's how easy it is to create a react native mobile app with expo and build it on to your mobile.

In my next post I will discuss about the React Native elements like View, Text etc.,

### Thank you for reading!!

<strong> <u>Check out my portfolio: </u> [Gautham's portfolio](https://gautham-portfolio.netlify.app/)</strong>

<strong> <u> Check out my blog: </u>[coding-magnified.tech](https://coding-magnified.tech)</strong>


### <u>My Other Articles: </u>

- [Universal CSS properties everyone must know](https://dev.to/gautham495/universal-css-properties-everyone-must-use-4kie)

- [Create-react-app](https://dev.to/gautham495/creating-a-new-react-app-with-create-react-app-4e9m)

- [Git for beginners](https://dev.to/gautham495/basic-git-knowledge-for-beginners-m4p)

- [Change headers in react with react-helmet](https://dev.to/gautham495/changing-headers-in-react-with-react-helmet-d0d)

- [Know How to apply box-shadow on all four sides.](https://dev.to/gautham495/know-how-to-apply-box-shadow-on-all-four-sides-43pn)
 
- [Simple CSS Selectors](https://dev.to/gautham495/simple-css-selectors-for-beginners-2i44).

- [CSS Pseudo Elements](https://dev.to/gautham495/css-pseudo-elements-for-beginners-53ob).
Project 1, Week 1, Day 3
Published: 2020-12-02 15:34:16

Some minor updates compared to yesterday. Was not able to get much done. I need to utilize the time after work a little bit better. So far all the work has been before I start with work.

[Pull Request](https://github.com/Cijin/project-we/pull/3)

I'm confident I can get this done this week. :)
How to make a Twitterbot?
Tags: python, twitter, beginners, heroku
Published: 2020-12-05 15:01:03

## 🚀  Installation

#### Clone the repo

```$ git clone https://github.com/chandrikadeb7/Girlscript-Twitter-Bot.git```

#### Install tweepy Python module

```$ pip install tweepy```

## 💡 Working

#### Sign up for a Twitter Developer Account

* Create a separate Twitter account for your bot.
* Sign up for Twitter Developer Account from this site - [Apply for a Twitter Developer Account](https://developer.twitter.com/en/portal/dashboard)
* Enter the necessary fields and await for email confirmation.
* Click on Create an app
* Enter the details and keep safe the access tokens generated.

#### Enter your generated access tokens and consumer keys in the file **credentials.py**

```
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
```

#### Edit the retweet and other details in the file **config.py**

```
# This is hastag which Twitter bot will search and retweet. You can edit this with any hastag .For example : '#javascript'
QUERY = '#anything'

# Twitter bot setting for liking Tweets
LIKE = True 

# Twitter bot setting for following user who tweeted
FOLLOW = True

# Twitter bot sleep time settings in seconds. For example SLEEP_TIME = 300 means 5 minutes.
# you can decrease it or increase it as you like.Please,use large delay if you are running bot all the time  so that your account does not get banned.

SLEEP_TIME = 300
```

## 🔑 Deployment

* Sign up for a free account in Heroku
* Click on New -> Create new app
* Enter the app-name in lower case and select your nearest region.
* Choose Heroku CLI for deployment. Follow the steps given in Deploy tab.
* Once the build is successful enable the Free Dynos option from Overview tab.

## 👏 And it's done!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gbpxhf4uk2s8podtb0a8.png)

## :eyes: Checkout?
[See here](https://github.com/chandrikadeb7/Girlscript-Twitter-Bot)
How to check if an element in DOM has a specific attribute using JavaScript?
Tags: javascript
Published: 2020-09-02 00:00:00

---
  title: How to check if an element in DOM has a specific attribute using JavaScript?
  published: true
  tags: JavaScript
  date: Wed Sep 02 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/check-if-element-has-a-specific-attribute-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-fc4fa6f9dafb4a997f94f97ce282fab3.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/check-if-element-has-a-specific-attribute-javascript)
  
To check if the element has a specific attribute in JavaScript, you can use the `hasAttribute()` method in the element.

Let's say you have an `h1` element with custom attribute `data-color="red"` like this,

```html
<h1 data-color="red">Heading</h1>
```

Now let's check is the `data-color` custom attribute is present in the `h1` tag element using the `hasAttribute()` method in it.

```javascript
// get the reference to the h1 tag element
const h1 = document.querySelector("h1");

// chcek if h1 tag has attribute : data-color
const isPresent = h1.hasAttribute("data-color");

console.log(isPresent); // true;
```

- The `hasAttribute()` method accepts a valid name of the attribute as a string.

- The method return boolean `true` is present and `false` is not present.

See live example in [JSBin](https://jsbin.com/mumukofunu/1/edit?html,js,console,output).

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

---