teleren/devto huggingface dataset:
What is IIFE in JavaScript.
Tags: javascript, webdev, beginners, iife
Published: 2023-04-17 10:05:17

In this article you will learn about the IIFE in javaScript.
All beginners level developers should know atleast this knowledge about the IIFE. 

IIFE, or Immediately Invoked Function Expression, is a self-executing anonymous function in JavaScript. As the name suggests, it is a function that is invoked immediately after it is defined, without the need for an explicit function call.

The syntax for defining an IIFE is as follows:


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

In this example, we define an anonymous function, wrap it in parentheses to make it an expression, and then immediately invoke it using the () at the end.

What is the Benefits using IIFE.

The primary benefit of using IIFE is that it helps to avoid polluting the global namespace with variables and functions. By wrapping code inside an IIFE, we create a private scope where variables and functions declared inside it are not accessible outside of it. This is useful for preventing naming collisions with other variables and functions defined in the global scope.


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

In this example we are creating a IIFE function. Inside this we are created a count variable and increament function. This increament function increments the value of counter.
After this we are calling a increament function and then print the counter value and what's the output of this yes 😁 you are right it's 1.

But what happened if we try to print outside of the function.
It's getting a ReferenceError because IIFE not saves data globally. It's safe data inside his private scope so we can't use outside of this function.

I hope you understand what is IIFE and Why this it is used.
If you like this article so don't forget to comment below 👇 of this article.
Future Leadership
Tags: leadership, future, ethics, storybytes
Published: 2023-04-17 09:37:09


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wrkws11wkoqzxsyyxh6a.png)
During the last 16 months, interviews with more than 140 CEOs were conducted globally, including representatives from Audi, MasterCard, Unilever, Best Buy, Oracle, Kaiser, Verizon, and many other notable companies. These interviews aimed to research the latest book, “The Future Leader,” which delves into the qualities required for effective leadership in 2030 and beyond. One of the critical questions posed to these CEOs concerned the most significant trends that will shape the future of leadership. Based on their responses, six key trends have been identified that will significantly impact future leaders for the next decade and beyond. The trends are the Pace of Change, Ai & Tech, Globalisation, New Talent Landscape, Purpose & Meaning, Morality & Ethics. All these trends prepare leaders to manage their capability to cope with the future, and none of them is inevitable. The days when the leader “knew it all” are counted since this evolution drives at such a pace that we won’t be able to catch up all the time. As a Leader, it’s high time we prioritise knowing ourselves before addressing others’ behaviours. Behavioural change isn’t easy, but it is an important key that helps leaders unlock and adapt to the future we can build together.
fsocket open php/laravel
Tags: php, laravel, socket
Published: 2023-04-17 09:55:45

To check if server can be connected to:

```php
$a = '';
        $link = "www.google.com";
        $fp = fsockopen($link, 80, $errno, $errstr, 30);
        if (!$fp) {
            $a = "$errstr ($errno)<br />\n";
        } else {
            $out = "GET / HTTP/1.1\r\n";
            $out .= "Host: $link\r\n";
            $out .= "Connection: Close\r\n\r\n";
            // fwrite($fp, $out);
            // while (!feof($fp)) {
            //     echo fgets($fp, 128);
            // }
            $a.=$out;
            fclose($fp);
        }

        dump($a);
```

Op if success:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptjnnvcx2rw3fzxkl3c4.png)
Get started with React Hooks, Components and styles
Published: 2023-04-17 09:51:34

Are you facing challenges in understanding React Hooks and Components and Styles? Don't give,  up you are in the correct direction.

When I joined the Information Technology, I had no idea of what was transpiring , I chose to work as a front-end developer. I got interested in studying React JS even though I didn't understand anything, it took me also a month in trying to understand React and its basics and concepts. 

Here is how l finally got to understand all about React.
I went through the following tutorilas
**
Understanding React JS and and components**
[](https://www.youtube.com/watch?v=dGcsHMXbSOA)

Understanding React Hooks
https://www.youtube.com/watch?v=LlvBzyy-558

I firstly got intereste in Using Tailwind CSS to style my components. Tailwind tutorials I used:  
https://www.youtube.com/watch?v=bxmDnn7lrnk
Power-Up Your Skills with this Apache AGE Cheat Sheet for PostgreSQL
Tags: apacheage, graphdatabase, postgres, database
Published: 2023-04-17 09:28:18

I have gathered some handy PostgreSQL commands and queries which will help you work with postgresql quickly and effectively.
**Basic Commands:**
Connect to a PostgreSQL server using the psql command:
`psql -U [username];`

List postgres databases:
`\l`

Exit the PostgreSQL shell:
`\q`

Connect to a specific database:
`\c <database_name>`

List all tables in the current database:
`\dt`

**Managing databases:**
Create a new database:
`CREATE DATABASE <database_name>`

Drop a database:
`DROP DATABASE <database_name>;`

Change the owner of a database: 
`ALTER DATABASE <database_name> OWNER TO <owner_name>;`

Rename a database:
`ALTER DATABASE <old_database_name> RENAME TO <new_database_name>;`

Change the encoding of a database:
`ALTER DATABASE <database_name> SET ENCODING <encoding>;`

Grant privileges to a user on a database:
`GRANT <privilege> ON DATABASE <database_name> TO <username>;`

**Managing tables:**
Create a new table:

```
CREATE TABLE <table_name> (
    <column1> <data_type1>,
    <column2> <data_type2>,
    ...
);
```
Create a new table with primary key and foreign key constraints:
```
CREATE TABLE <table_name> (
    <column1> <data_type1> PRIMARY KEY,
    <column2> <data_type2>,
    ...
    FOREIGN KEY (<column_name>) REFERENCES <referenced_table>(<referenced_column>)
);
```

Add a new column to an existing table:
```
ALTER TABLE <table_name>
ADD COLUMN <column_name> <data_type>;
```

Drop a column:

```
ALTER TABLE <table_name>
DROP COLUMN <column_name>;
```

Insert a new row into a table:

```
INSERT INTO <table_name> (<column1>, <column2>, ...)
VALUES (<value1>, <value2>, ...);
```

Delete rows from a table:
```
DELETE FROM <table_name>
WHERE <condition>;
```

**Managing indexes:**
Creating an index with the specified name on a table:
```
CREATE [UNIQUE] INDEX index_name
ON table (column,...)
```

Removing a specified index from a table:
```
DROP INDEX index_name;
```

**Querying data from tables**
Retrieve all columns from a table:
`SELECT * FROM <table_name>;`

Retrieve specific columns from a table:
`SELECT <column1>, <column2>, ... FROM <table_name>;`

Retrieve distinct values from a column:
`SELECT DISTINCT <column_name> FROM <table_name>;`

Sort data by one or more columns:
```
SELECT <column1>, <column2>, ...
FROM <table_name>
ORDER BY <column_name> ASC/DESC;
```

Retrieve data from multiple tables using INNER JOIN:
```
SELECT <table1.column1>, <table2.column2>, ...
FROM <table1>
INNER JOIN <table2> ON <table1.column_name> = <table2.column_name>;
```

Use GROUP BY to group data based on a column:
```
SELECT <column1>, <aggregate_function>(<column2>)
FROM <table_name>
GROUP BY <column1>;
```
My Software Development Journey Begins
Tags: beginners, career
Published: 2023-04-17 09:11:21

So, I have been coding relentlessly for the past three months, and I've been able to see some significant progress. Just check out this Github contribution graph. Isn't it beautiful? Especially considering it's just April.

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

During my high school days, I was really into computers, and I would pass my computer classes. It was just one of those subjects that came easy to me. I decided to pursue a Computer Science degree after completing high school, and I soon found out that Computer Science was not a bed of roses. After receiving a C in my 'Introduction to Programming' unit and struggling with grasping topics like looping and recursion, I slowly lost my passion for computing. From that moment on, I got this idea in my mind that software development and coding were just not for me, and I was okay ending up as a project manager who did as little coding as possible.

But somewhere towards the end of 2022, I made a resolution that I was going to understand this coding thing that I had found so complicated for the past two years. I remembered that I had promised myself when I had just finished high school that I would become a 'Successful Software Engineer'. I even put a sticker on my childhood bedroom. How could I betray myself like this?

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

Anyway, long story short, I am back on my grind, and I will not stop until I land a job as a software engineer. I have a bunch of projects lined up for this year, and I plan on taking them on slowly but consistently. By the end of the year, I want to be proud of the amount of effort I would have put in.

Lastly, I also know that becoming a successful software engineer is not just about coding skills. Soft skills such as communication, teamwork, and problem-solving are also important in this field. I am focused on developing both technical and soft skills to become a well-rounded software engineer.

> "Believe you can and you're halfway there." - Theodore Roosevelt
Help: Implementing Authentication in RESTful API
Published: 2023-04-17 09:08:59

Hello fellow developers! 👋

I am a freshly graduated software developer, I am currently working on creating a RESTful API using Node.js with Express and PostgreSQL. I am almost done with the endpoints, but now I am looking to implement an authentication process so that users can have the option to log in when using my API in their frontend applications.

However, I am feeling a bit lost on where to start with authentication in my API. I am using an MVC architecture, and I'm not sure where to implement and write the authentication code. Should I create a completely separate file to handle authentication? I would greatly appreciate any advice or guidance on how to proceed with implementing authentication in my API.

My Github Repo if you want to have a look at my code:[https://github.com/vincenzochiovaro/Mealtime-backEnd](https://github.com/vincenzochiovaro/Mealtime-backEnd)

Thank you in advance for your help, and I apologize for any confusion or lack of experience in this area.
Gestire la cache di npm e considerazioni per Docker
Tags: npm, docker, linux
Published: 2023-04-17 09:06:54

Quando si richiede di installare un pacchetto npm, questo viene scaricato da internet e salvato nella cartella di cache, se non è già presente, e poi installato nell'applicazione che lo richiede.
Dalla versione 5 di npm, la gestione della cache è _self-healing_ per cui dovrebbe riconoscere eventuali pacchetti incompleti, danneggiati o obsoleti e, in tal caso, scaricarli nuovamente cercando anche di risolvere automaticamente le dipendenze nel modo migliore.
Tuttavia in alcuni casi, anche per risolvere problemi di installazione, è utile pulire la cache di npm con il comando:

```bash
$ npm --global cache verify
Cache verified and compressed (~/git/.npm/_cacache)
Content verified: 9127 (1525196266 bytes)
Content garbage-collected: 3491 (5398705346 bytes)
Index entries: 9129
Finished in 34.248s
```

La cartella della cache normalmente è `~/.npm` (nell'es. sopra è `~/git/.npm`) ma è possibile spostarla.
Possono esserci diversi motivi per cui si potrebbe voler controllare il percorso della cache:

1. la cartella può arrivare a occupare uno spazio considerevole e si potrebbe volerla spostare.
1. si vuole usare una cartella di cache condivisa tra più host per velocizzare le installazioni.
1. si vuole una cache condivisa tra gli utenti della stessa macchina.

Il comando per spostare la cartella di cache è:

```bash
npm config set cache nuovaCartella --global
```

Al posto di modificare la configurazione del file di configurazione di npm, è anche possibile impostare il percorso della cache in una variabile di ambiente:

```bash
export npm_config_cache=/path/to/cache
```

Dopo aver spostato la cache, lanciare il comando di verifica:

```bash
npm --global cache verify`
```

E' possibile vedere la configurazione attuale con il comando:

```bash
npm config list
```

Il comando di verifica non cancella pacchetti scaricati ma non più usati, perciò si potrebbe voler cancellare tutta la cache con il comando:

```bash
npm cache clean
```

## Considerazioni per Docker

Se stiamo usando Docker, è possibile impostare la cartella della cache con:

```bash
docker run -e npm_config_cache=/path/to/cache mydockerimage:tag
```

In questo modo, il comando `docker run` consente di eseguire un container Docker configurato per utilizzare una specifica directory per la cache dei pacchetti npm.
Controllando dove i pacchetti vengono salvati, si può condividere la cache tra diversi container o host, ad esempio per ridurre il tempo di download dei pacchetti npm o per evitare di scaricare i pacchetti più volte.
Inoltre, ci permette di usare la stessa cartella di cache anche quando si avvia il container con un utente diverso da quello attuale (ogni utente ha la sua cartella di cache).
ABEND dump #4
Tags: news
Published: 2023-04-17 08:53:00

Hi there!

It’s been a while since the last ABEND dump. Want to check the previous issue? Read it here: [ABEND dump #3](https://bitmaybewise.substack.com/p/abend-dump-3)

---

## [HTTP/2 requires headers to be lowercase](https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2)

![surprised deadpool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mrcqq6vdgx0suodzvdhr.gif)

This is more of a surprise than a rant, but, who would think that HTTP/2 would require headers to be exchanged all in lowercase when it has been indifferent up to now?!

According to the [RFC section 8.1.2](https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2):

> A request or response containing uppercase header field names MUST be treated as malformed (Section 8.1.2.6).

How did I stumble upon that? Like almost everything in life, many things happen by accident, and it was not different in this case. Last December I was playing with the prometheus/client_ruby, and decided to raise a pull request to fix an example when rack started shouting at me—surprise surprise—about the Content-Type header having uppercased letters, which lead me to another pull request to fix it.

So folks, be mindful from now on when dealing with your HTTP headers in your clients and servers.

## [How to Produce and Learn at the Same Time](https://codefol.io/posts/how-to-produce-and-learn-at-the-same-time/)

> Don’t do a ridiculously excellent job. That would take way more work and way more time.

> A pretty good job, communicated well, is usually more valuable to the company than the best work of their best engineers.

## [Culture Trumps Strategy, Every Time](https://hbr.org/2011/03/culture-trumps-strategy-every)

> Culture is the set of habits that allows a group of people to cooperate by assumption rather than by negotiation. Based on that definition, culture is not what we say, but what we do without asking.

## [Prometheus: The Documentary](https://youtu.be/rT4fJNbfe14)

A nice documentary about how Prometheus was born.

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

---

If you liked this post, consider subscribing to my newsletter [Bit Maybe Wise](http://bitmaybewise.com/).

You can also follow me on [Twitter](https://twitter.com/bitmaybewise) and [Mastodon](https://mastodon.online/@bitmaybewise).
Resource Load Management-Overview
Tags: opengauss
Published: 2023-04-17 08:47:49

**Overview**

**Function**
openGauss manages resource load to balance system resource usage for jobs.

**Related Concepts**
**Resource management**

openGauss manages system resources, including CPU, memory, I/O, and storage resources. It allocates system resources in a proper way to prevent system efficiency deterioration or system running problems.

**Cgroup**

Control groups (Cgroups) are a mechanism provided by the Linux kernel to restrict, record, and isolate physical resources (such as CPU, memory, and I/O resources) used by process groups. Cgroups have strict restrictions on Linux system resources. If a process is added to a Cgroup, it can use only restricted resources. For details about Cgroup principles, see the product manual corresponding to your OS.

**Resource pool**

Resource pools are a configuration mechanism provided by openGauss to divide host resources (memory and I/O resources) and control SQL concurrency. Resource pools are bound to Cgroups. In this way, you can manage the resource loads of jobs in a specific resource pool.
SQL Rewriter: SQL Statement Rewriting
Tags: opengauss
Published: 2023-04-17 08:44:09

**Overview**

SQL Rewriter is an SQL rewriting tool. It converts query statements into more efficient or standard forms based on preset rules to improve query efficiency.

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

**Usage Guide**
**Prerequisites**
The database and connection are normal.

**Example**
Use the **tpcc** database as an example:

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

**queries.sql** is the SQL statement to be modified. The content is as follows:

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

The result is multiple rewritten query statements, which are displayed on the screen (the statements that cannot be rewritten are displayed as null), as shown in the following.

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

**Obtaining Help Information**
Before using the SQL Rewriter tool, run the following command to obtain help information:

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

The following information is displayed:

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

Passwords are entered through pipes or in interactive mode. For password-free users, any input can pass the verification.

**Command Reference**
Table 1 Command line parameters

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

Troubleshooting
**·** If the SQL statement cannot be rewritten, check whether the SQL statement complies with the rewriting rule or whether the SQL syntax is correct.
Stripe fees calculator
Tags: opensource, payment, stripe
Published: 2023-04-17 08:42:06

Stripe is super easy to integrate, and its pricing appears straightforward. As a result, most businesses get started very quickly on Stripe because everyone loves speed and simplicity. Yet, many small to medium-sized businesses always keep talking about Stripe fees.

We did a deep dive and understood that some of the actual pain points for such businesses were:

Problem 1: Not being able to breakdown fee components of Stripe and attribute it at per transaction level

Problem 2: Lack of visibility on which feature of Stripe is costing more

Problem 3: Not being able to spot the breakeven point to adopt a secondary payment processor

So, we embarked on a journey to find a solution.

[Here's the analysis and the model](https://hyperswitch.io/blog/stripe-fees-how-much-is-too-much-clgjfmbdn2631453tnn08ksy0wx), let me know what you think
Prima Persona V2 A free landing page to display your projects, work, contact or any link in light and dark mode support.
Tags: astro, tailwindcss
Published: 2023-04-17 08:35:46

Introducing  ⇢ Prima Persona V2 ⏤ A landing page to display your projects, work, contact or any link, light and dark mode support. 

Built with Astro, Tailwind CSS and MDX

100% Free

>Get it on https://lexingtonthemes.com/info/primapersona/

Pages 1
Sections 1
Components 10+
User if they are already logged in. Can't open Login Page in Next.js
Tags: webdev, javascript, beginners, programming
Published: 2023-04-17 08:35:07



To prevent a logged-in user from accessing the login page in Next.js, you can create a custom _app.js file and use the useEffect hook to redirect the user if they are already logged in.

````
import { useEffect } from "react";
import { useRouter } from "next/router";
import { useAuth } from "../hooks/auth"; // your authentication hook

function MyApp({ Component, pageProps }) {
  const { user } = useAuth(); // get the user from your authentication hook
  const router = useRouter();

  useEffect(() => {
    if (user) {
      router.push("/dashboard"); // redirect to the dashboard page if the user is already logged in
    }
  }, [user, router]);

  return <Component {...pageProps} />;
}

export default MyApp;
````