teleren/devto huggingface dataset:
Async patterns in node js
Published: 2021-12-30 06:23:12

A code in node js should be nonblocking to avoid halting the execution of lines of code ahead of it. Implementing functionality that could take time is done asynchronously in order to take the execution part of that function out of the main loop.
There are three asynchronous patterns:

**1. Callbacks**
A callback is a function that is passed as an argument to another function and should be invoked whenever the asynchronous work is finished.

```
const { readFile } = require('fs')
console.log('start of program')
readFile('./myFile.txt', 'utf-8', (err, myfile) => {
  if(err) {
console.log(err)
    return
}
console.log(myFile)
})
console.log('End of program')
```
the readfile function is asynchronous and therefore the program will move on to the next instruction while the function continues to run in the background.
The output is as follows:

```
start of program
End of program
content inside the text file myFile
```
2. Promises 
The promise object represents the eventual completion of async operations, regardless of the results(success or failure). It is also defined as a proxy for a value not necessarily known at the time it is created.

```
const { readFile } = require('fs')
const readMyFile = (path) => new Promise((resolve, reject) => {
  readFile(path, 'utf-8', (err, context) => {
    if (err) {
      console.log(err)
      return
}
else {
   console.log(context)
}

})
})
readMyFile('./files/myFile.txt')
.then((result) => console.log(result)
.catch((err) => console.log(err)
```
A promise can exist in either one of these states:
_**Pending**_ - this is the initial state where it is neither resolved or rejected.

_**Fulfilled**_ - The promise will be in this state if the operation has been completed successfully.

_**Rejected**_ - the state when the operation has failed.

## Promisify
This function is defined in Node's util module as a standard and its goal is to convert callback to promise.

```
const { readFile } = require('fs')
const util = require('util')
const readMyFile = util.promisify(readFile)

async function start() {
  try {
      const myText = await readMyFile('./myFile', 'utf-8')
      console.log(myText)
   }
 catch (error) {
   console.log(error)
   }
}

```
3. Async / Await
A method in which the parent method is declared with the async keyword and inside it await keyword is permitted.
Pukhraj Stones and Its Benefits in Your Life
Published: 2021-12-30 06:18:38

Yellow sapphire Stone which is also famously called kanakapushyaragam stone, Pukhraj stone in India, is an image of mental fortitude and intelligence. Since it carries success to an individual's life, it's an extremely valuable stone that is the reason it's exceptionally popular.

Various sorts of gemstones are accessible on the lookout and they have their own strength. Pukhraj Stone is the most well known of these stones. Every gemstone has its own impact and its own profound characteristics.

Now if you are looking for **[pukhraj stone benefits](https://www.contourcafe.com/2021/01/04/price-of-pukhraj-stone/)**, this article will help you to find everything.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chr1ylnc615zhlvwbn6k.jpeg)

**Here are a some of the pukhraj stone benefits:**

● It brings wealth when kept at home. Additionally helps in accomplishing a great and serene psyche. In this manner the wearer can settle on better choices. Consequently it is one of the pukhraj stone benefits
● Yellow sapphire gemstone diminishes mental tension and stress. By and large, it affects the human body and wellbeing. Likewise, it creates body, knowledge and wellbeing. This builds steadfastness.
● Yellow sapphire stone gets security and flourishing connections.
● Since Pukhraj stone is viewed as a sidekick of Lord Ganesha, one who bears this gemstone accomplishes thriving and achievement.

**Know the amount Ratti (carat) yellow sapphire will suit you?**

Pukhraj stone is worn for different advantages from Jupiter. Jupiter is the biggest planet in the planetary group. This planet is a wellbeing variable and gets monetary solidness and confirmation life. This planet plays a fundamental part in building one's fortune.

The base load of a yellow sapphire stone ought to be 3.5 ratti (carat). Overweight yellow sapphire stone has a more prominent impact. Prior to wearing or buying it, an accomplished soothsayer should be counselled.

**Impact of Yellow sapphire stone on various zodiac signs**

Because of the limitless impacts of Pukhraj, the interest for this gemstone is exceptionally high. It is accessible in shades of light yellow to dim orange.

Pukhraj stone has various outcomes on various zodiac signs. Tell us the impact of the Pukhraj stone on various zodiac signs.

**When would it be a good idea for us to wear yellow sapphire?**

Wearing yellow sapphire is viewed as generally propitious on Thursday (Gurwaar), as per the Vedas. It is prescribed to wear the Pukhraj ring between 5 am and 7 am on Thursday mornings during Shukla Paksha (the waxing moon).

**Is yellow sapphire destructive?**

Pukhraj stone benefits are abundant. But has a great deal of force that will provide its wearer with a tonne of energy. When buying gemstones on the web, possibly buy them from a trustworthy webpage assuming that it suits you. Yellow sapphire can effectively affect a person whose Jupiter as the controlling planet is devastated.
ChristmasLight Css
Tags: codepen, css, html
Published: 2021-12-30 05:42:31


**Merry Christmas & Happy New year Everyone**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sth2alarcjgu8nsvuqh1.png){% codepen https://codepen.io/kirzin/pen/RwLQQMZ %}
How to Rice Windows.
Tags: windows, ricing, customization
Published: 2021-12-30 05:29:21

## _Ricing Windows_

![Desktop Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1p30bfgxqu3gmi849es.png)

##### Make your Desktop look sick & clean. 

---

Here is a list if software and applications that I have used to rice my desktop. 

<u>Web Browser</u> ▻ **Firefox**
<u>Music Streaming</u> ▻ **Spotify** 
<u>Messaging Platform</u> ▻ **Discord**
<u>Text Editor</u> ▻ **Visual Studio Code**
<u>Terminal</u>▻ **Windows Terminal**
<u>File Manager</u> ▻ **Files** 
<u>Wallpaper Manager</u> ▻ **Lively**
<u>App Launcher</u> ▻ **PowerToys Run**
<u>Status Bar</u> ▻ **PolyBar**
<u>Music Widget</u> ▻ **ModularPlayers**
<u>Dock</u> ▻ **Nexus**

---

Head over to my GitHub repository ↴

{% github  iDCoded/Windows-Rice%}
Top 5 Python Frameworks for Web Development in 2022
Tags: python, webdev, programming, machinelearning
Published: 2021-12-30 05:08:43

In this blog we are going to see top 5 best python framework for web development in 2022. Top & Trending Python Frameworks for Web Development in 2022. Let's Start Click Here to read this post:👇

[Top 5 Python Frameworks for Web Development in 2022](https://codexashish.com/2021/12/top-5-python-frameworks-for-web.html)


##New & Trending Topics:👇
[Top 10 Trending Technologies to Learn in 2022](https://codexashish.com/2021/12/top-10-trending-technologies-to-learn.html)
[Top 10 Programming Languages You Must Know In 2022](https://codexashish.com/2021/12/top-10-programming-languages-you-must.html)
[Top 5 CRYPTOCURRENCIES That Could Dominate In 2022](https://codexashish.com/2021/12/top-5-cryptocurrencies-that-could.html)
[Top 5 Python Frameworks for Web Development in 2022](https://codexashish.com/2021/12/top-5-python-frameworks-for-web.html)
[Machine Learning Complete Roadmap 2022](https://codexashish.com/2021/12/complete-roadmap-of-machine-learning.html)

##Complete Roadmap 2022:-👇
[Python Complete Roadmap 2022](https://codexashish.com/2021/12/complete-roadmap-of-python-programming.html)
[Machine Learning Complete Roadmap 2022](https://codexashish.com/2021/12/complete-roadmap-of-machine-learning.html)
[C++ Complete Roadmap 2022](https://codexashish.com/2021/12/complete-roadmap-of-c-programming.html)
[Java Complete Roadmap 2022](https://codexashish.com/2021/12/java-complete-roadmap-2022.html)
[Data Structure Complete Roadmap 2022](https://codexashish.com/2021/12/complete-roadmap-of-data-structure.html)


##Some Laravel Tutorial for developer:👇
[Laravel 8 Interview Questions and Answers in 2022 (Part #1)](https://codexashish.com/2021/12/laravel-8-interview-questions-and.html)
[Laravel 8 Interview Questions and Answers in 2022 (Part #2)](https://codexashish.com/2021/12/laravel-8-interview-questions-and_22.html)
[Advance Laravel 8 Interview Questions and Answers 2022](https://codexashish.com/2021/12/advance-laravel-8-interview-questions.html)
[Everything About Laravel 8 Composer 2022 | Composer in Laravel 8](https://codexashish.com/2021/12/everything-about-laravel-8-composer.html)
[Laravel Jetstream vs Laravel ui  vs Breeze](https://codexashish.com/2021/12/laravel-jetstream-vs-laravel-ui-vs.html)

##Python Concept and Projects:-👇
[Top 5 Python Frameworks for Web Development in 2022](https://codexashish.com/2021/12/top-5-python-frameworks-for-web.html)
[10 Best Python Libraries For Machine Learning](https://codexashish.com/2021/12/10-best-python-libraries-for-machine.html)
[Alarm Clock in Python with GUI](https://codexashish.com/2021/07/alarm-clock-in-python-with-gui.html)
[Tic Tac Toe Game Using Pygame in Python](https://codexashish.com/2021/06/tic-tac-toe-game-using-pygame-in-python.html)

**Thankyou for reading my blogs.**
#####My Website:👇
[CodexAshish](https://codexashish.com/)
Self-Taught Developer Journal, Day 28: TOP JavaScript Fundamentals Part 2 - Logical Operators and Conditionals
Tags: webdev, beginners, codenewbie, devjournal
Published: 2021-12-30 05:08:08

Today I learned...

### The || OR operator
* represented by two vertical lines
* if any of the values are true, it will return true 
* if the operand is not boolean, it is converted to a boolean for evaluation
* returns the first true value with the original value of the operand, does not continue to evaluate operands in the expression (also known as **"short circuit evaluation"**)
* return the last false value if all operands evaluated and are false
*A value is returned in its original form, not the conversion. 
In a chain of || OR, the first truthy value is returned or the last one if no truthy value is found.

### The && AND operator
* represented by two ampersands &&
* returns true if both operands are true and false otherwise 
* returns the **first falsy value**
* returns the **last value** if all values are true
* **&& (AND) has a higher precedence then || (OR)**

### The ! NOT operator
* represented with an exclamation !
* converts value to boolean then returns the inverse value
* **higher precedence then && (AND) and || (OR)**
* !! can be used to convert value to a boolean

### Switch Statement
An alternative to the if..else statements when checking for matching values of a single expression\value input.

    const color = 'blue';
    
    switch (color){ // expression or value
      case 'red':
        console.log('Color is red');
        break;
      case 'blue': // choice matches the expression/value 'blue'
        console.log('Color is blue');
        break;  // if the previous choice matches, stop executing the code block or it will continue to the next choice
      case 'green':
        console.log('Color is green');
        break;
      default: // will run if none of the choice matches, do not need a break statement because there are not more statements after to execute
        console.log('No matches');
    }

## Resources
[The Odin Project](https://www.theodinproject.com/paths/foundations/courses/foundations)
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals
Best Android Development Course 2022 Free + Paid
Published: 2021-12-30 04:51:12

Hello and welcome in this post we are going to discuss some of the best Android development courses for 2022. If you want to start your journey in Android development or if you want to advance your knowledge in Android development you can follow these courses. I have picked some of the best courses that are available online and listed them in this post. So let’s get started.
[Read Complete Article](https://crunchythings.xyz/best-android-development-course-2022-free-paid/)
Coding Time and Git Push and Commit Reminder
Tags: atlashackathon
Published: 2021-12-30 04:40:52

[Instructions]: # (To submit to the MongoDB Atlas Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
CTAP-reminder is a scheduling app to remind bootcamp students of their coding time and git push and commit. Integrated with wakatime, github and discord api. If their coding time or git push and commit is below the set standard, they will get a notification via the discord channel as a reminder along with information regarding their coding time and git push and commit. This application runs according to a predetermined time can be daily, weekly or tailored to your needs.


### Submission Category: 
Automation Innovation


### Link to Code
[github](https://github.com/h8-exploration/ctap-reminder)


### Additional Resources / Info
Coding time remainder preview

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7w0o3j3pfr037zqwvq1m.png)

Github commit and push reminder preview

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kezox3j58p7x6fnhi2z.png)

#### Deploy link
[link](https://dev.api.github.ajatdarojat45.id)

#### Tech Stack

- [mongodb](https://www.mongodb.com/)
- [express](https://expressjs.com/)
- [cron](https://www.npmjs.com/package/cron)
- [bull](https://www.npmjs.com/package/bull)
- [mongoose](https://mongoosejs.com/)
React Fundamentals
Published: 2021-12-30 04:28:28

Props and state
Both props and status are plain JavaScript objects. Although they
both have information that affects the render&#39;s output, they differ
in terms of components and their functionality. Props are sent to a
component similar to the function parameter where the state is
operated within the corresponding component of the variable
declared in a function. Or How will you pass data from parent to
child Or Can you change props? Or is Props readOnly

React Component Life Cycle
The lifecycle method is a special built-in response mechanism
that is used in DOM to manage components throughout their
duration. Each component of React has a life cycle. that we can
observe and manipulate in its three main stages. There are:
Mounting, Updating, and Unmounting.

Custom hook
A custom hook is a JavaScript function that we create ourselves.
when we want to share logic with other JavaScript functions. This
allows you to reuse some of the code as necessary in our
project.  
For example, we have an API, and we have to fetch this API
repeatedly in different components, here we can use a custom
hook for fetching API, and use the data whenever we need any
components.
Controlled and Uncontrolled components
In React Application, there was a controlled component, which
means the value of the input element can be controlled by React. 
We store the state of the input element inside the code. After
using event-based callbacks, any changes made to the input
element will be reflected in the code. In react applications, there is
an uncontrolled component, where the input element is handled
by the DOM. Among the uncontrolled elements, the input

elements work in the same way as the common HTML input form
elements.

Virtual Dom:
Virtual DOM is an in-memory representation of and Real DOM. In
react.js there was a virtual dom, which works instead of Real Dom.
Virtual Dom tracks our components, that if there was something
changed,  It happens between the render function. The whole process
is called reconciliation.
Public Media Solution Launches India’s First Media Marketplace For Selecting Media Channels On Demand
Published: 2021-12-30 04:13:42

The eCommerce platform allows customers to select individual media houses and dedicated packages to get their articles published

Public Media Solution (PMS), a noted PR and digital marketing agency, allows businesses to select print and digital media channels according to their preferences by launching India’s first [Media Marketplace](https://www.marketplace.publicmediasolution.com/). The platform aims at providing greater control and power to the brands for spreading their word and reaching out to their audiences.

The functioning of PMS Media Marketplace is similar to any eCommerce storefront. The platform provides users with the option of selecting digital and print media channels. On selecting the preferred channel, they can choose one or more media houses for getting their articles published. In the case of digital media, visitors can select from channels like The Outlook, Times Business News, [Asian News](https://asiannews.in/), ET Now, India.com, Fortune India, and more.

In the case of getting print media coverage, visitors can select one or more cities/states to circulate their articles. The Media Marketplace allows businesses and individuals to circulate print articles in all major states across the country via media houses like The Times of India, DNA, Loksatta, The Indian Express, The Hindu, The Economic Times, and more.

While PMS Media Marketplace helps businesses to get their own articles published, it also allows them to get their articles written by professionals. By paying nominal extra charges, businesses can get their PR articles covered by skilled and dedicated journalists.

The online platform also provides businesses with exclusive media packages ranging from ₹8,990 onwards. These packages allow brands to get their stories covered by over 80+ media houses across digital and print media platforms.

Moreover, the Media Marketplace allows users to gift media coverage to their loved ones. It allows them to buy a Media Marketplace Gift Card starting from ₹500 to get articles about their loved ones published on the chosen media channel(s).

Arsh Lakhani, the Head of Business Development at Public Media Solution believes that the Media Marketplace will make PR more accessible for businesses across the country. He says, “Especially in the case of startups and small businesses, getting a press release circulated is often a complicated process. By launching Media Marketplace with the best [PR agency in Pune](https://publicmediasolution.com/public-relation/), we aim at making the entire process simpler and more accessible. Our goal is to make the process of selecting media channels for publishing PR articles as simple as buying groceries from an online supermarket!”
Accelerate development of Kubernetes applications
Tags: devrel, kubernetes, gitops, gke
Published: 2021-12-30 03:35:13

Originally, Kubernetes was designed for the cluster administrator. But today it has moved from being an infrastructure tool to an entire platform for managing workloads. However, along with this evolution, the key layer, on top of the infrastructure is still missing!

In this video, I‘ve touched on an evolving trend in industry which is trying to glue this missing point. I've also included a short working demo of two very common use cases which a Kubernetes developer experiences day-to-day!

Hope you all find this useful!

{% youtube PlxNgIGdoO4 %}
Create kolom index untuk like di Postgresql
Tags: postgres, index
Published: 2021-12-30 03:23:02

Spesifikasi Percobaan:
- Centos 7
- PostgreSQL 12

Persoalan:
Query pencarian ke sebuah kolom (contoh: nama) memerlukan waktu yang cukup lama meskipun sudah dibuat index untuk kolom tersebut.
Contoh cuplikan query:
```
EXPLAIN ANALYZE SELECT nama from tabela where nama ilike '%abcdefg%';
...
Planning Time: 0.300 ms
Execution Time: 261.213 ms
```

Penyebab:
Index btree tidak bekerja untuk pencarian menggunakan like atau ilike (partial match). Index btree bekerja ketika menggunakan pencarian full match. Contoh: "...where nama ='abcdefg'..."

Solusi:
Install software contrib sesuai versi postgresql
```
yum install postgresql12-contrib
```

Create extension di database yang diinginkan
```
create extension pg_trgm;
```

Buat index di tabela
```
CREATE INDEX CONCURRENTLY idx_tabela1 ON tabela USING gin (nama gin_trgm_ops);
```

Explain analyze query sebelumnya
```
EXPLAIN ANALYZE SELECT nama from tabela where nama ilike '%abcdefg%';
...
Planning Time: 0.588 ms
Execution Time: 1.004 ms
```

Waktu eksekusi untuk pencarian seperti sebelumnya jauh lebih cepat. Selesai!

Referensi
https://niallburkley.com/blog/index-columns-for-like-in-postgres/
ENV var do's and dont's
Tags: ruby, beginners, productivity
Published: 2021-12-30 03:16:54

Goofus reads in his ENV vars at runtime and gets hundreds of bugsnag notifications and customer complaints.
```
class MyClass
  def my_method
    ENV['important_var'] + 1
  end
```
Gallant reads in his ENV vars with fetch at load time and the devops team notices the failed deployment and add the env var. His customers are happy.
```
class MyClass
  VAR = ENV.fetch('important_var')
  def my_method
    VAR + 1
  end
```
---
Goofus sets default values for environments in the classes and confuses his coworkers with conditionals.
```
class MyClass
  ENV['important_var'] ||= 'hello' if Rails.env.development?
  ENV['important_var'] ||= 'world' if Rails.env.test?
```
Gallant sets default values in the config/environments files. His coworkers know exactly where to look to understand the env.
```
# config/environments/development.rb
ENV['important_var'] ||= 'hello'

# config/environments/test.rb
ENV['important_var'] ||= 'world'
```
---
Goofus uses string values to represent boolean flags and keeps his coworkers guessing.
```
my_flag = ENV['MY_FLAG'] == 't' || ENV['MY_FLAG'] == 'true'
```
Gallant uses nil for false so that setting it to any string is true. His coworkers appreciate the flexibility.
```
my_flag = ENV['MY_FLAG'].present?
```
Adicionando Tailwind em um projeto com Rails 7
Tags: rails, ruby, braziliandevs, tailwindcss
Published: 2021-12-30 02:10:45

Se você for iniciar um projeto agora com o Rails 7 e quiser adicionar o tailwind basta:

```ruby
rails new name_of_project --css tailwind
```

Agora se você estiver trabalhando em um projeto com Rails 7 e quiser adicionar o tailwind depois de já ter criado o projeto:

```ruby
bundle add tailwindcss-rails
```

e depois

```ruby
rails tailwindcss:install
```

**Contato:**
Email: contato@diegonovais.com.br
LinkedIn: https://www.linkedin.com/in/diegonovais/
Github: https://github.com/dnovais
CRUD Operations with React and Node
Published: 2021-12-30 02:06:27



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2zds3o5t6qwcdo3umsk.jpg)
In this article, I will show you how to do a mern stack crud operation

First of all, we will look at how to install a React front-end project.

CRUD Operation:

       Step:1
Let’s start building the Front-end part with React. To create a new React App, enter the following code into the terminal and hit enter.
	Command: npx create-react-app my-app
	
	Step:2
Then go inside that folder and start the project and install the necessary packages And create as many components as needed.

       Step: 3
Then you have to create a project for the backend. There are some steps to be taken. First, you have to accept all the required packages with npm-init then you have to install node MongoDB express cors these important packages.




      Step:4
Then we can see that many APIs of crud operations have been created through the image above.


    JWT Token 
The common use case of the JWT token is that it is used for authorization. But the main purpose of the jwt token was to allow one of the two-part browsers and the server-side to work in a standard way.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7u45l8bt173i7ky3e2nx.png)