teleren/devto huggingface dataset:
DailyUI #004 - Calculator (CodePen)
Tags: codepen, css, design, 100daysofcode
Published: 2021-08-15 00:46:24

DailyUI Challenge #004 - I made clone of the Google Calculator app, only the UI with a blinking cursor animation, might add functionality later on.

Font:
- Open Sans

[Color Scheme](https://coolors.co/2d3033-202124-e8eaed-174ea6-88b2f5-b7b7b7):
- #2D3033 - top half background and button hover color
- #202124 - bottom half background
- #E8EAED - white input text and number color
- #174EA6 - blue strip on the right of numpad
- #88B2F5 - operator icon color
- #B7B7B7 - gray navbar text and calculated result color

## Blinking Cursor Animation:

### HTML

The part we want to animate is right after the input.
![HTML Snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7w8nvp3r5h5ucpbbz06.png)

### CSS

In the CSS for after the input, set the content empty and a very thin border to the right with your choice of color.

For each rendering engine's keyframe, set the border color at the beginning and end (`0%, 100%`) of the animation to be transparent and at the very middle (`50%`) of the animation to be your choice of color. The `50%` is when you _see_ the cursor blink.

For each rendering engine's animation, we set the blink animation to a 1 second duration, the timing-function to [step-end](https://www.quackit.com/css/css3/properties/css_animation-timing-function.cfm), and the iteration-count to infinite because we want it to continuously blink.

![CSS Snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/devgaucl906ci4wti5zw.png)

## CodePen

{% codepen https://codepen.io/anniedotexe/pen/yLbwdVw %}
1# Fundação AWS com Terraform
Tags: aws, terraform, cloudnative, devops
Published: 2021-08-15 00:14:49

A ideia aqui e ter uma serie de boas práticas para quem está iniciando e quer estruturar do zero sua fundamentação cloud.

Se pudesse dar um conselho para quem está começando a migrar para nuvem ou criando uma aplicação Cloud Native nova sem dúvida seria estruture bem suas contas de providers!

Alguns acordos do que vamos utilizar aqui: 

​	·    AWS, AWS e AWS

​	·    Terraform (https://www.terraform.io/) 

Por que AWS?

​	·    Tenho mais experiencia

​	·    Simples

​	·    Tinha que escolher alguma para facilitar nos exemplos

 Por que Terraform? 

​	·    Tenho mais experiencia

​	·    Não confundir cloud native com aws native


Sobre o que é Cloud Native >> https://www.infoq.com/br/articles/cloud-native-panel/

Sobre o que é o IAC >> https://www.infoq.com/br/news/2020/02/honeycomb-infrastructure-as-code/

Quando comecei na AWS era tudo mato e não existia nenhum serviço global para gerenciar as contas, então era supernormal criar contas máster para tudo. 

Alguém tocou no coração do PO para priorizar a tratativa dessa dor latente a todos os usuários AWS da época e foi criado o AWS Organizations.

![Texto  Descrição gerada automaticamente](https://i.pinimg.com/originals/0c/c8/d5/0cc8d54d38a1cee45ed9b6ea5be5efda.jpg)

No próximo vamos conversar sobre boas práticas, criação de conta, criação de subcontas.

 \#vlwflw
How to get the count of a specific keyword or term from the contents of a file in the Linux terminal?
Tags: resource
Published: 2021-08-15 00:00:00

---
  title: How to get the count of a specific keyword or term from the contents of a file in the Linux terminal?
  published: true
  tags: Resource
  date: Sun Aug 15 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-count-of-specific-word-from-file-linux
  cover_image: https://melvingeorge.me/_next/static/images/main-3c10c0e2acfb42e7e40dec09c8de4d51.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-count-of-specific-word-from-file-linux)
  
To get the count of a specific keyword or a term from the contents of a file, we can use the `cat` command followed by the `path` to the file, then the `|` operator (aka pipe operator), then the `grep` command, then the keyword you want to search for and finally the `-c` flag (count flag) in the Linux terminal.

### TL;DR

```bash
# Get the count of a specific
# word from the contents of a file
cat <PATH_TO_FILE> | grep <YOUR_SEARCH_TERM> -c
```

For example, let's say we have a file called `myFile.txt` which has some content like below,

**Example Content**

```txt
Wikipedia is a free content, multilingual online encyclopedia 
written and maintained by a community of volunteer contributors 
through a model of open collaboration, using a wiki-based editing system.

Wikipedia was launched on January 15, 2001, by Jimmy Wales 
and Larry Sanger; Sanger coined its name as a blending of "wiki" and "encyclopedia". 
Initially available only in English, versions in other languages were quickly developed. 

Its combined editions comprise more than 57 million articles, 
attracting around 2 billion unique device visits per month, 
and more than 17 million edits per month (1.9 edits per second).
```

Now, we want to find the number of times a specific word occurred or count of the word `Wikipedia` from the contents of the `myFile.txt` file. We can do that using the `cat` and `grep` commands like this,

```bash
# Get the count of a specific
# word from the contents of a file
cat myFile.txt | grep Wikipedia -c
```

The output of running the above command may look like this,

![output of running the command to count a specific keyword](https://melvingeorge.me/_next/static/images/output-count-specific-word-linux-be4c0e13d9bad3da32e92d54902d8918.png)

As you can see that the word `Wikipedia` has a count of `2` in the above output.

See the execution of the above command live in [repl.it](https://replit.com/@melvin2016/get-the-count-of-specific-word-from-contents-of-file-linux#main.sh).

That's all 😃!

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

---
On Ugly Face of Hardcoded Values [RE#5]
Tags: article, design, productivity, programming
Published: 2021-08-15 03:33:32

---
title: On Ugly Face of Hardcoded Values [RE#5]
published: true
date: 2021-08-15 00:00:00 UTC
tags: article, design, productivity, programming
canonical_url: https://babakks.github.io/article/2021/08/13/re-005-on-ugly-face-of-hardcoded-values.html
series: "Regular Encounters" 
---

Recently I’ve been working on a service maintenance/migration problem and needed to change a few configuration parameters (names of several RabbitMQ queues/exchanges.)

Things were going smooth until when I found there’s no way to nicely apply such changes on tge production, because some developer, at some point hardcoded the names into the code base. She either decided these parameters are never going to change or to parameterizing them contributes to unnecessary complexity–I hope the former was the case. 🤦

Besides taking the precious time of fellow developers and waste their focus/energy, hardcoding ties your hands in emergency/disaster recovery. You never know what’s going to be happen in the next incident. The moral of the story, don’t leave hardcoded values as your heritage.

* * *

**_About Regular Encounters_**  
_I’ve decided to record my daily encounters with professional issues on a somewhat regular basis. Not all of them are equally important/unique/intricate, but are indeed practical, real, and of course,_ **_textually minimal._**
There's no reason not to use a linter
Tags: linter, staticanalysis, codereview
Published: 2021-08-21 19:47:21

---
title: There's no reason not to use a linter
published: true
date: 2021-08-15 00:00:00 UTC
tags: linter,staticanalysis,codereview
canonical_url: https://jhall.io/archive/2021/08/15/theres-no-reason-not-to-use-a-linter/
---

A [linter](https://en.wikipedia.org/wiki/Lint_(software)) is a program that anylizes your source code to detect common bugs or other areas for improvement.

Most modern languages come with a wide variety of linters and other static analysis tools available. [Pick one](https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis). Or pick ten.

If you’re not already doing so, simply adding a linter as the first check in your CI or build pipeline is usually the simplest, cheapest single step you can do to improve code quality, as it can provide a sort of machine-operated code review for you.

While what’s available depends on each language, in general you can, and should, find linters to detect and warn about bugs such as:

- SQL injections
- Common memory leaks
- Uninitialized or unused variables

Additionally, you may want to use linters to detect more stylistic problems that commonly lead to bugs or confusing code:

- Shadowed variables
- Use of conventional naming
- Spell checking of comments or inline documentation
- Unnecessary type conversions
- Excessive indentation
- Unnecessary or redundant conditionals

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
How to Start a Custom Software Development Company in 2021?
Tags: customsoftware
Published: 2021-08-14 23:32:14

ViseTech is a [Custom Software Development Company](https://visetech.org/2021/05/21/custom-software-development-company/)  which is serving its clients in different states of the US, UK, and Canada since 2007 with a fully devoted team. We assist entrepreneurs, solopreneur and online beginners, how to start, run, and grow their own business online, taking the less financial risk and more chances for profit.
With our hands-on experience in block chain, AI/ML, IoT and Cloud, we deliver creative custom software development services to our customers. Leveraging our consulting capabilities, in-depth domain knowledge and technical prowess, we can design & build beautiful and scalable custom software applications for new business, mid-size companies and enterprises

**ViseTech (Us Software Agency)**

Our [Custom Software Development Company](https://visetech.org/2021/05/21/custom-software-development-company/)  always delivers fully functional website and visually eye-catching web products moreover we offer our web services and solutions, which helps you to develop and grow your business your way.
Our in-house team from our “US Software Agency” is always ready to bring your ideal business into reality and spread it to the right people in time and on budget. You can get all the efficient and cost-effective services of program development in one place.
Quick tutorial on how to use MongoDB & Mongoose on nodejs (get & post request)
Published: 2021-08-14 23:31:54

1. install mongoose: npm install -S mongoose

2. connect mongoose: const mongoose = require('mongoose');

3. connect: mongoose.connect(server/databaselocation)

```javascript
const mongoose = require('mongoose');

const mongoURI = 'mongodb://localhost:9999/test';

const db = mongoose.connect(mongoURI, { useNewUrlParser: true });

db
  .then(db => console.log(`Connected to: ${mongoURI}`))
  .catch(err => {
    console.log(`There was a problem connecting to mongo at: ${mongoURI}`);
    console.log(err);
  });

module.exports = db;
```

set up model: mongoose.model('collectionName', {name: String})

```javascript
const mongoose = require('mongoose');

const attendeeSchema = new mongoose.Schema({
  firstName: String,
  lastName: String,
  email: String,
  shirt: String,
  skillLevel: String
});

const Attendee = mongoose.model('Attendee', attendeeSchema);

module.exports = Attendee;
```


make get request to the collection
```javascript
app.get('/attendees', (req, res) => {
  Attendee.find(function(err, Attendee) {
    res.send(Attendee);
  })
});
```
make post request to the collection
```javascript
app.post('/attendees', (req, res) => {
  var post = new Attendee ({
    firstName: req.body.firstName,
    lastName: req.body.lastName,
    email: req.body.email,
    shirt: req.body.shirt,
    skillLevel: req.body.skillLevel
  })
  post.save(function (err, post) {
    if (err) {
      return next(err)
    }
    res.send(201)
    console.log('successfully updated')
  })
});
```

Quick tutorial for Mongoose: https://www.youtube.com/watch?v=5e1NEdfs4is
Level Up with JavaScript
Tags: javascript, webdev, beginners, tutorial
Published: 2021-08-14 23:12:07

## Welcome to Level up with JavaScript

In this blog series tutorial, you will be introduced to some of the basic JavaScript programming concepts.

This is geared toward beginners and anyone looking to refresh their knowledge.


To get started, here is an example of a basic JavaScript program called "Hello World".


```JavaScript
function greetMe(yourName) { 
    alert("Hello " + yourName); 
} 
greetMe("Zach");

"Hello Zach"

``` 

Now that you have seen what JavaScript is and an example of how to write a simple program, let's level up!


## Comments, Declaring Variables, Storing, Assigning, and Initializing Values

### Comments

Comments are notes about your code for you or other developers. 

JavaScript will ignore everything after a double forward slash for in-line, and between a forward slash + asterisk for multiline.


```JavaScript
// This is an inline comment 

/* This is a
multi-line comment */

``` 

### Declaring Variables

Variables allow computers to store and use data. 

JavaScript uses these eight data types: undefined, null, boolean, string, symbol, bigint, number, and object.

These variables must be declared by the "var", "let", or "const" keyword.

Variables can have numbers, letters, dollar signs, or underscores. They cannot contain spaces or start with numbers.

Semicolons are used at the end of statements. They are sometimes optional in JavaScript because of automatic semicolon insertion. 

However, I would advise always including them until you are more experienced.



```JavaScript
var level;

``` 

### Storing Values

Values can be stored as a variable with the assignment operator (=). 

In this example, I declare the variable "level" and set it to the value 1.

Now each time "level" appears in the code, the program will treat it as 1.

```JavaScript
var level;
level = 1;

``` 

### Assigning Values

Next, the assignment operator can be used to assign the same value from the previous variable to another variable. 

With the below example, now JavaScript_level and level are both the same value of 1.


```JavaScript
var level;
level = 1;
var JavaScript_level;
JavaScript_level = level;

``` 

### Initializing Values

Initialize allows us to assign an initial value to a variable as it is declared.

This is done on the same line that the variable is created.

```JavaScript
var level = 1;

```


### Thank you for reading my blog! This is the first of my series on JavaScript so if you would like to read more, please follow!





### See the [<strong>Next Level Here</strong>](https://dev.to/devcronin/level-up-with-javascript-level-2-1pba)




## [<strong>Support and Buy me a Coffee</strong>](https://www.buymeacoffee.com/ZachCronin)
Basic query for PostgreSQL to remember
Published: 2021-08-14 22:37:42

Basic query:
```javascript
SELECT column, column, column
FROM table
WHERE table.column = ${whatever}
```

Query with nested array with join table:
```javascript
SELECT column1, column2, json_agg(json_build_object('key', value) AS name_your_key
FROM table1
LEFT JOIN table2
ON table1.id = table2.table1.id
WHERE table1.id = ${whatever}
GROUP BY column1, column2
```
how to start writing API request
Published: 2021-08-14 22:32:07

In order to request data from API, we need to set up an express to do get request

1. npm install express

2. create file name index.js for my main server foler

3. const express = require('express')
to call express

4. const db = require('../databasefolder')
call db folder & file

5. start express by writing
const app = express();
const port = 1004;

port can be any 4 digit numbers

6. app.listen(port, () => console.log(`Successfully connected to the port ${port}`))

7. write your get, put, post requests

ex.
```javascript
app.get('/products', (req, res) => {
  let { page, count } = req.query;
  if (page === undefined) {
    page = 0;
  };
  if (count === undefined) {
    count = 5;
  };
  db.getProducts(page, count, (err, result) => {
    if (err) {
      res.status(400)
      console.log(err);
    }
    res.status(200)
    res.send(result);
  })
});

app.get('/products/:product_id', (req, res) => {
  const { product_id } = req.params;
  db.getCurrentProduct(product_id, (err, result) => {
    if (err) {
      res.status(400)
      console.log(err);
    }
    res.status(200)
    res.send(result);
  })
});
```
PostgreSQL query (pool &client)
Published: 2021-08-14 22:24:00

1. great tutorial to check pg's client: https://www.youtube.com/watch?v=ufdHsFClAk0&t=723s
2. great tutorial to check pg's pool: https://www.youtube.com/watch?v=GTeCtIoV2Tw

Client & Pool makes us easy to retrieve, update or write data into PostgreSQL database.

When using it

1. call pg into file:

```javascript
const { Pool, Client } = require("pg");
```

2. create client or pool:

```javascript
const pool = new Pool({
  user: "postgres",
  host: "localhost",
  database: "productDB",
  password: "password",
  port: 5432,
  max: 20,
});
```

3. if API is connected, create query (I'm trying to get {count} number of rows in {page}. OFFSET allows me to start from specific row, so I can multiply my page & count to start from that row.
**REMEMBER TO: ORDER BY (sort) because OFFSET needs to have static rows of data to track it's position.

```javascript
const getProducts = async (page, count, callback) => {
  const queryString = `SELECT id, slogan, description, category, default_price FROM products ORDER BY id ASC LIMIT ${count} OFFSET ${count * page};`
  await pool.query(queryString, (err, res) => {
    if (err) {
      console.log(err);
    }
    callback(null, res.rows);
  });
};
```

** If I want to use join table method, here is cool link to check out: http://sqlfiddle.com/#!15/70cd7/12

if I want to set up value as objects inside of an array:

ex.
```javascript
{
    "id": 11,
    "name": "Air Minis 250",
    "slogan": "Full court support",
    "description": "This optimized air cushion pocket reduces impact but keeps a perfect balance underfoot.",
    "category": "Basketball Shoes",
    "default_price": "0",
    "features": [
  	{
            "feature": "Sole",
            "value": "Rubber"
        },
  	{
            "feature": "Material",
            "value": "FullControlSkin"
        },
  	// ...
    ],
}
```

I can write it like this:

```javascript
SELECT products.id, products.name, products.slogan, products.description, products.category, products.default_price, json_agg(json_build_object('feature', features.feature, 'value', features.value))
  AS features
  FROM products
  LEFT JOIN features
  ON products.id = features.product_id
  WHERE products.id = ${product_id}
  GROUP BY products.id, products.name, products.slogan, products.description, products.category, products.default_price`
```
why you should not use console.log( ) for debugging ?
Tags: javascript, beginners, npm, node
Published: 2021-08-14 21:07:37

###Node.js `console.log` and `console.error`

This built-in console module in Node.js lets you write log messages to stdout and stderr using the log and error functions.

It might appear simple and tempt you to use.

Lots of people prefer to use the console module.

But, this is not the best practice.

#But why ?

Lets say, you want to debug or log a response from an API

#app.js

```
const axios = require('axios');

 axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
    // do something with response data
  })
  .catch(function (error) {
    console.log(error);
    // do something with error
  });
```
Once you done with your debugging after developement phase, you need to remove the console.log() or comment it during production phase like follows.

#app.js

```
const axios = require('axios');

 axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    // console.log(response); <----- line commented
    // do something with response data
  })
  .catch(function (error) {
    // console.log(error); <----- line commented
    // do something with error
  });
```

Now imagine a larger code base with 1000s of files.

Its a tedious process to comment and uncomment, right ?

#Lets make debugging simple with `The debug Module`

###Step 1

`npm install debug --save`

Now import and use the debug() replacing the console.log() or console.error() and set the `environment variable` as `dev`

#app.js

```
const axios = require('axios');
var debug = require('debug')('dev') // dev is env variable

 axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    debug(response);
    // do something with response data
  })
  .catch(function (error) {
    debug(error);
    // do something with error
  });
```
Now run the code by setting the environment variable during `Developement phase`
```
$ DEBUG=dev node app.js

//response data or error will be printed

```

Simply, during `Production phase` remove environment variable and run code as follows
```
node app.js

// nothing gets printed
```
**Support Us on** [Buy Me a Coffee](https://www.buymeacoffee.com/dogealgo)
What is an idempotent function?
Tags: computerscience, theory, go
Published: 2021-08-14 16:40:39

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

An **idempotent** function in computing is a function that you call more than once with the same input parameters, it will have no additional effect.

It comes from mathematics which looks like this:

**f(f(x)) = f(x)**

Let's let's check an example in Go!

```go
package main

import (
	"fmt"
	"strings"
)

func main() {
	definition := "iDeMpoTeNt"

	fmt.Println(strings.ToUpper(definition)) // f(x)
	fmt.Println(definition)
	fmt.Println(strings.ToUpper(strings.ToUpper(definition))) // f(f(x))
}
```

```bash
// Output:
IDEMPOTENT
iDeMpoTeNt
IDEMPOTENT
```


by calling `strings.ToUpper()` on `definition` variable at first, it will make it uppercase. But calling it again **with "definition"** makes no other additional effects, therefore it is **idempotent**. 

You can try it yourself on [the Go Playground!](https://play.golang.org/p/bJIH6u0wLBr)

## Update: Why **idempotency** is useful?

Special thanks to [Casper](https://dev.to/cappe987) in the [comment](https://dev.to/cappe987/comment/1h81k) for sharing a great 15 min long [podcast](lispcast.com/what-is-idempotence/) from Eric Normand about idempotence and why it is useful. I think he had an example rich explanation, and it's best for you to listen to his words!