teleren/devto huggingface dataset:
JavaScript Functions
Tags: javascript, beginners
Published: 2023-02-20 15:13:40

- Function Statement aka Function Declaration:

The <u>syntax of writing function</u> is called as **Function Statement or Function Declaration.**
```
function fooBar() {
    console.log("Hello World!")
}
```

- Difference between Function Parameters and Arguments

If we add <u>variables inside round brackets</u> in <u>Function Declaration</u> then those variables are called as **Parameters**, and they are <u>copy</u> of the sent variable through function call.
If we call the function and along with it we pass a variable inside round brackets of function call then those variables are called as **Arguments.**

> 📌<u>**Note:-**</u> We can keep the names of parameter and argument same, but to avoid confusion we usually name it differently.


```
// Parameter
function fooBar(parameter) {
    console.log("Hey Foo Bar, it's me ", parameter)
}

// Argument
let argument = "John Doe"
fooBar(argument)
```


- Anonymous Function

When we create a <u>function but without name</u> is called as **Anonymous Function.**
```
setTimeout(function() {
    console.log("Hello World!")
})
```


- Function Expression

It is almost same as creating <u>Anonymous Function</u> but not only creating it, also <u>assigning it to a Variable</u> means **Function Expression.** After assigning the function to the variable, the function act as a <u>**value**</u> and it is <u>not added</u> into the <u>Global Scope</u>. We can also create a <u>Named Function</u> and <u>assign it to a variable</u> then it is called as **Named Function Expression.**
```
// Function Expression
let foo = function() {
    console.log("Hello World!")
}

// Named Function Expression
let bar = function foo() {
    console.log("Hello World!")
}
```


- First Class Functions

<u>Functions</u> has ability to be used like <u>Values</u> is called as **First Class Functions**. Functions can be <u>returned as  values</u> from a function or can be send as <u>arguments</u> to a function. **First Class Functions** are also known as **First Class Citizens.**

```
// Function returned as Value
function foo() {
    return function() {
        console.log("Hello World!")
    }
}
let helloWorld = foo()

// Functions sent as Argument
function foo(funcParam) {
    bar()
    console.log("Here we are in Foo!")
}

function bar() {
    console.log("Hello World!")
}

foo(bar)
```

> Thanks for reading, will cover Arrow Functions in next blog 😉
Python if-else Statements Tutorial
Published: 2023-02-20 15:13:15

if(**Conditional**) statements are an essential part of programming as they allow you to control the flow of execution based on certain conditions. In Python, **`if-else` statements** are used to execute different blocks of code depending on the truth value of a given expression. In this tutorial, we'll learn how to use `if-else` statements in Python.

## [**Python if-else statements**](https://www.programdoc.com/python/if-else) Syntax
```py
if condition:
    # execute this block of code if condition is True
else:
    # execute this block of code if condition is False
``` 

`condition` is an expression that returns a boolean value (`True` or `False`). If `condition` is `True`, the code inside the `if` block is executed. If `condition` is `False`, the code inside the `else` block is executed.

## Example

Let's take a simple example to understand how `if-else` statements work in Python:

```py
age = 22

if age >= 18:
    print("You are old enough to vote!")
else:
    print("You are not old enough to vote yet.")
``` 

Output:
```py
You are old enough to vote!
```
## Nested if-else Statements

We can also have nested `if-else` statements in Python, where an `if` block can contain another `if-else` block:

```py
age = 24

if age >= 18:
    if age == 18:
        print("Congratulations! You have just become eligible to vote.")
    else:
        print("You are old enough to vote!")
else:
    print("You are not old enough to vote yet.")
``` 

Output:
```py
You are old enough to vote!
```

## Multiple Conditions with elif

We can use the `elif` keyword to test multiple conditions in Python:

```py
score = 88

if score >= 90:
    grade = "A"
elif score >= 80:
    grade = "B"
elif score >= 70:
    grade = "C"
elif score >= 60:
    grade = "D"
else:
    grade = "F"

print("Your grade is " + grade)
``` 

Output:
```py
Your grade is B
```

## Explore Other Related Articles
[Python set tutorial](https://dev.to/max24816/python-set-tutorial-hcp)
[Python tuple tutorial](https://dev.to/max24816/python-tuple-tutorial-3m62)
[Python Lists tutorial](https://dev.to/max24816/python-lists-tutorial-2g43)
[Python dictionaries comprehension tutorial](https://dev.to/max24816/python-dictionaries-comprehension-tutorial-3bda)
[Python comparison between normal for loop and enumerate](https://dev.to/max24816/python-comparison-between-normal-for-loop-and-enumerate-p4a)
Paracetamol.ts💊| #14: Explica este código TypeScript
Tags: typescript, javascript, spanish, webdev
Published: 2023-02-20 15:07:05

## **<center>Explica este código TypeScript</center>**
#### <center>**Dificultad:** <mark>Básico</mark> </center>

```ts
const f1 = (a = 0, b = 0):[number, number] => {
  return [a, b]
}

console.log(f1()) // 🤔
console.log(f1(1,2)) // 🤔
```

- A. `[number, number]`, `[1, 2]`
- B. `ReferenceError`, `[1, 2]`
- C. `undefined`, `[1, 2]`
- D. `[0, 0]`, `[1, 2]`

Respuesta en el primer comentario.

---
Facebook bio
Published: 2023-02-20 11:59:37

[Facebook bio](https://socialwordplay.com/) is a great way to express yourself and showcase your personality. For boys, it can be a challenging task to write an interesting and unique bio that represents their individuality. A good bio can make you stand out and attract more friends and followers on Facebook. Here are some tips on how to write an awesome bio for boys:

Be concise: Your bio should be short and to the point. Try to sum up your personality and interests in just a few sentences.

Show off your skills: If you have a talent or a skill that you're proud of, don't hesitate to mention it. It could be anything from playing the guitar to programming.

Highlight your interests: List your favorite hobbies and interests. It will give people an idea of what you enjoy doing in your free time.

Use humor: Don't be afraid to add a touch of humor to your bio. A witty one-liner or a funny quote can make you more relatable and approachable.

Be original: Avoid clichés and generic statements. Be creative and write something that sets you apart from others.

Include a call-to-action: Encourage people to connect with you by adding a call-to-action. It could be as simple as asking them to message you or follow you on Instagram.

Remember, your Facebook bio is a reflection of your personality. So, make sure it accurately represents who you are and what you stand for. By following these tips, you can create a bio that is unique, interesting, and memorable.
Deploy Nextjs app to github-pages with Github Actions
Published: 2023-02-20 14:47:39

Github made super easy to deploy nextjs app to github pages using Github Actions.

First let's create a [nextjs app](https://nextjs.org/docs/getting-started): `npx create-next-app@latest`. Follow all the steps to setup a new nextjs app.
Then go to [github.com](https://github.com/) and create a new repository. I named my `nextjs-my-app`, you can name it whatever you want. Follow the steps to push an existing repository from the command line.
Now go the repository settings:
1. Go to Settings

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i69081erhhxafr3venty.png)
2. From left side navigation go to Pages

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpoj6krh9ey9lr60zmhb.png)
2. On Build and deployment section for the source choose: Github Actions (beta)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ky1bh6u23fl01gpof82.png)
3. Nextjs config section will show up. Click on configure.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66zu4avbbvv9g9s3vjwu.png)
4. Commit `nextjs.yml` auto generated file.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkkbjqi0cz28pv58vgrk.png)
5. In few seconds you will see that deployment is done.
6. To see nextjs app live go to : https://[username].github.io/[repository-name]/ For me is: [https://mentorkadriu.github.io/nextjs-my-app/](https://mentorkadriu.github.io/nextjs-my-app/)
The Scary Side of Frameworks/Languages
Tags: beginners, programming, discuss, codenewbie
Published: 2023-02-20 14:45:54

Since I started getting into web development, I’ve always wanted to learn Next.js/React.
But there was a problem…
*I thought it was too hard*

But 2 days ago, I decided that I should put in some effort to start learning Next.js/React.
Now, 2 days later, I’ve created a cool blogging website using Next.js and React following the official Next.js tutorial.

**You can learn any language or framework if you put in some effort and really want to learn it!**

## What frameworks/languages do you think are too hard or can’t be bothered to learn?
ทำ Software ไม่ได้มีแต่การปั่น Feature หรอกนะ
Published: 2023-02-20 14:43:05

สวัสดีครับ เนื่องจากวันที่ 19 กุมภาพันธ์  2566 ที่ผ่านมา พี่ปุ๋ยชวนไป(โดนฆ่า)พูดที่งาน National coding day จัดโดยสมาคมโปรแกรมเมอร์ไทย ที่ Bitec

เนื้อหาไม่ได้มีอะไรมาก เป็นการพูดคุยเกี่ยวกับเรื่องที่พบเจอได้ทั่วๆไปในการพัฒนา Software จนมันกลายเป็น meme ที่เอามาล้อกันสนุกสนาน แต่น้ำตามันตกอยู่ข้างใน

แน่นอนว่ากว่าผมจะรู้ว่าต้องพูดอะไร ก็ตอนที่ขึ้นเวทีไปแล้วนั่นเอง

แต่นั่นไม่ใช่ประเด็น จนต้องเอามาเขียน ที่ผมอยากจะเขึยนก็คือ ตอนปิดท้ายผมรู้สึกว่าตัวเองพูดรวบรัดไปหน่อย รู้สึกว่าสื่อสารออกไปได้ไม่ครบถ้วน เลยมาเรียบเรียงขยายความใหม่ น่าจะดีกว่า

เริ่มที่รูปนี้ จากใน Slide นั่นแหละ

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

คำถามคือ เราปล่อยให้ Bug มันขยายร่างขึ้นไปเรื่อยๆได้ยังไง
หรือผมลองตั้งคำถามใหม่
เราตั้งใจปล่อยให้บั๊กมันโตขึ้นเรื่อยๆหรือเปล่า?
มี Developer คนไหนตั้งใจ commit code ที่เป็น Bug เข้าระบบบ้าง
มี Tester คนไหนตั้งใจเขียน test case ที่ไม่มีวันทดสอบผ่านบ้าง
มี Designer คนไหน ตั้งใจสร้างของที่มันทำจริงๆไม่ได้ ใส่เข้าไปใน Figma บ้าง
มี Infra คนไหน ตั้งใจวางขั้นตอนให้มัน deploy ยากๆบ้าง
มี User คนไหน ตั้งใจให้ requirement ที่ไม่มีวันทำได้จริงบ้าง
และ อื่นๆอีกมากมาย

ผมคิดว่าจริงๆแล้ว ก็ไม่มีใครอยากทำร้ายกันหรอก ทุกคนก็อยากทำสิ่งดีๆทั้งนั้น ถ้างั้นแล้ว ปัญหามันมาจากอะไรล่ะ

ผมเดาว่า เป็นเพราะ ทุกคนมีเป้าหมายที่แตกต่างกัน เมื่อต่างคนต่างมุ่งหมายที่จะกระทำเป้าหมายของตัวเองให้สำเร็จเท่านั้น

ซึ่งมันเป็นเป้าหมายเดียวกันกับ software ที่กำลังทำกันอยู่หรือไม่?

ทำไมบั๊กมันถึงเติบโตขึ้นได้เรื่อยๆ สาเหตุหนึ่ง ก็เพราะว่าเรามี deadline ที่จะต้องทำ feature ทั้งหมดให้เสร็จตามที่ commit ไว้
ดังนั้น หลายๆครั้ง เราก็เลือกที่จะละเลยเรืองบางเรื่องไปก่อน เพื่อที่จะส่งมอบงานได้ทันเวลา
แล้วการต้องส่งมอบให้ได้ทันเวลา โดยที่ระบบมีปัญหา ใช้งานไม่ได มันเป็นเป้าหมายของใครกันล่ะ? ไม่น่ามีนะ
และเราก็ได้เรียนรู้ครั้งแล้วครั้งเล่าว่าธรรมชาติของการทำ Software มันไม่ได้เป้นแบบนั้น

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

ผมคิดว่า DevOps หรือ practice หลายๆตัวมันก็เกิดมาจากจุดนี้แหละ นั่นคือ ไม่ว่าคุณจะอยู่ตรงไหนของการทำ Software คุณจะต้องตระหนักรู้ถึงการที่ software ของคุณน่ะ มันจะถูกเอาไป Operate อย่างไร เราต้องทำอะไรหรือเตรียมตัวอย่างไรเพื่อ support สิ่งนั้น แล้ว practice หรือ tools ต่างๆ ค่อยตามมา

ขอให้สนุกกับการทำ Software มีความสุขทั้งฝั่งผู้ใช้งาน และฝั่งผู้พัฒนา ครับ
JavaScript ⭐ libraries are tools 🛠️ for developers
Tags: javascript, webdev, programming, beginners
Published: 2023-02-20 14:40:07

## Introduction


- [JavaScript](https://www.youtube.com/watch?v=9EZ0TpuHYvI) Libraries are incredibly useful tools for developers. 

- They provide an extensive range of features and capabilities that can be used to create a wide variety of applications and websites.
 
- With the correct library, you can significantly reduce development time by taking advantage of pre-built components, frameworks, and libraries instead of writing everything from scratch.

- One great example is [ReactJS](https://youtu.be/VrkvIdvl29Y) Library which is one of the most popular JavaScript libraries today due to its flexibility in creating powerful web apps with minimal effort. 

- It comes with several helpful features such as component-based architecture which allows developers to quickly build complex user interfaces without having to start from scratch every time they need a new feature or functionality added to their app or website.

- It also provides virtual DOM support so that changes made in the code are reflected immediately on the screen instead of needing manual updates each time something changes within your application's structure or design elements. 

- Finally, there’s VueJS Library a lightweight yet powerful library designed specifically for building fast single-page applications (SPAs). 

- It uses an intuitive API along with reactive data binding techniques that make it easy for developers who don't have much experience using JavaScript Libraries but still want access to all the benefits they offer when developing SPAs quickly and efficiently without sacrificing performance quality either way!



###### 7 JavaScript Libraries ⭐ For Supercharging Your Next Project 💫

🎥 {% youtube ygJK4WBDMzA%}


#### Bonus 10 JavaScript Games to learn-Totally Cool & Fun 🚀✨🔥

###### 

🎥 {% youtube 9EZ0TpuHYvI%}


### Connect with Me 😊

#### 🔗 Links

[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/mahmoud-el-kariouny-822719149/)

[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Mahmoud42275)
Verify if your code is running in AWS Lambda / Serverless
Tags: lambda, aws, serverless, node
Published: 2023-02-20 14:19:20

Are you developing a Node.js app to be deployed on AWS Lambda? If so, you may need to detect whether your code is running in the AWS Lambda environment or not. One way to do this is by examining the LAMBDA_TASK_ROOT environment variable. In this post, we'll explore how you can use this variable to detect if your Node.js app code is running on AWS Lambda.

### What is **LAMBDA_TASK_ROOT**?

**LAMBDA_TASK_ROOT** is an environment variable that is automatically set by AWS Lambda for all Node.js functions. This variable contains the path to the directory where the code for the Lambda function is located. In other words, it points to the root directory of the Lambda function.

### How to detect if your code is running on AWS Lambda?

To check if your Node.js app code is running on AWS Lambda, you can examine the LAMBDA_TASK_ROOT environment variable. Here's an example:

```typescript
if (process.env.LAMBDA_TASK_ROOT) {
  // Running on AWS Lambda
} else {
  // Not running on AWS Lambda
}
```

This code checks if the **LAMBDA_TASK_ROOT** environment variable is set. If it is, it assumes that the code is running on AWS Lambda. If it's not set, it assumes that the code is not running on AWS Lambda.

It's important to note that this method is not foolproof. In some cases, the **LAMBDA_TASK_ROOT** environment variable may not be set even if the code is running on AWS Lambda. However, for most cases, it should be reliable.

If you encounter any issues, you can explore other environment variables that are set by AWS Lambda, such as **AWS_LAMBDA_FUNCTION_NAME**, **AWS_REGION**, and **AWS_EXECUTION_ENV**, among others.
How to handle exceptions in Java ?
Tags: java, exceptions, backend, beginners
Published: 2023-02-20 14:01:16

Exceptions are used in Java to handle errors and unusual situations that may occur during program execution. To handle exceptions these execeptions, you can use a combination of try, catch, and finally blocks.

The try block contains code that may throw an exception so if an exception is thrown, the program executes to insructions in the catch block  which contains the code for handling the exception, otherwise the catch block is skipped if no exception is thrown.

Here's an example of a try-catch block:

```try {
// code that might throw an exception
} catch (ExceptionType1 e1) {
    // code to handle ExceptionType1
} catch (ExceptionType2 e2) {
    // code to handle ExceptionType2
} finally {
    // code that will always be executed, regardless of whether an exception is thrown or not
}```

In this example, if an exception of type ExceptionType1 is thrown in the try block, the program will jump to the first catch block and execute the code there and if an exception of type ExceptionType2 is thrown, the program will jump to the second catch block and execute the code there. But if no exception is thrown, the program will skip both catch blocks and execute the finally block.

The finally block is optional, but it is useful for cleaning up resources, such as closing files or releasing locks, that were acquired in the try block.

It's important to remember that catch blocks are executed sequentially, so arrange your catch blocks in the order of the most specific to the least specific to be sure that the most specific catch block for the corresponding exception is executed.



This article was originally posted on www.devcorner.blog
Computer Vision: from 0 to HERO (3-dars)
Tags: uzbek, ai, machinelearning, computerscience
Published: 2023-02-20 14:01:09

**Python versiyalari**


![Versions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lltgnffpahfq59wik5je.png)

2020-yil 1-yanvardan boshlab Pythonning `python2 ` versiyasi qoʻllab-quvvatlash rasman toʻxtatildi. Ushbu sinf uchun barcha kodlar Python 3.7 dan foydalanadi . Ushbu qoʻllanmani davom ettirishdan oldin oʻrnatish koʻrsatmalaridan oʻtganingizga va virtual muhitni toʻgʻri oʻrnatganingizga ishonch hosil qiling. `python3` ni ishga tushirish orqali muhitni faollashtirgandan so'ng, Python versiyangizni buyruq satrida tekshirishingiz mumkin `python --version`.

Pythonning barcha versiyalari va ular haqida ko'proq ma'lumot olish uchun pythonning rasmiy saytida o'qishingiz mumkin:

[Bu yerda](https://www.python.org/doc/versions/)
Amazon Managed Blockchain
Tags: devops, aws, webdev, blockchain
Published: 2023-02-20 13:55:32

Amazon Managed Blockchain is a fully managed service that allows customers to create and manage scalable blockchain networks using popular open-source frameworks such as Hyperledger Fabric and Ethereum. It makes it easy for businesses to set up, operate, and scale blockchain networks with just a few clicks.

Here are some of the key features and benefits of Amazon Managed Blockchain:

Fully Managed Service: Amazon Managed Blockchain is a fully managed service that takes care of the heavy lifting associated with setting up and managing blockchain networks. This includes deploying and configuring nodes, managing network membership, and maintaining the infrastructure.

Scalability: Amazon Managed Blockchain is designed to scale to meet the needs of enterprise-grade blockchain applications. Customers can create networks with thousands of nodes, and the service automatically scales up or down to handle changes in network traffic.

Integration with AWS Services: Amazon Managed Blockchain integrates with other AWS services such as Amazon S3, Amazon CloudWatch, and Amazon CloudTrail, making it easy to build end-to-end blockchain solutions.

Open-Source Frameworks: Amazon Managed Blockchain supports popular open-source blockchain frameworks such as Hyperledger Fabric and Ethereum. This allows customers to use existing blockchain applications and tools, as well as to benefit from the extensive developer communities around these frameworks.

Security and Compliance: Amazon Managed Blockchain provides a range of security features, including network isolation, encryption of data at rest and in transit, and secure identity and access management. It also helps customers meet compliance requirements by providing audit trails, tamper-evident logs, and configurable network policies.

Pay-as-you-go Pricing: Amazon Managed Blockchain offers a pay-as-you-go pricing model, allowing customers to pay only for the resources they use. There are no upfront fees or minimum commitments.

Overall, Amazon Managed Blockchain is a powerful service that can help businesses take advantage of the benefits of blockchain technology without the complexity and cost of managing their own infrastructure. It provides a range of features and benefits that can make it easier to create, manage, and scale blockchain networks, and integrate them with other AWS services
A web developer’s guide to Google Cloud
Tags: googlecloud, webdev, cloud, devops
Published: 2023-02-20 13:46:37

Google Cloud is a powerful platform that can provide web developers with a wide range of tools and services to build, test, and deploy web applications. Here is a guide to Google Cloud that can help web developers get started with this platform.

Set up a Google Cloud account: The first step to getting started with Google Cloud is to sign up for an account. You can do this by visiting the Google Cloud website and creating an account. You will need to provide some basic information such as your name, email address, and billing information.

Understand the basic services: Google Cloud offers a wide range of services, so it’s important to understand what each one does. The main services that web developers will use include:

Compute Engine: This is a service that lets you create and manage virtual machines in the cloud. You can use it to run your web applications and host your website.

App Engine: This is a fully managed platform for building and deploying web applications. You can use it to build and host your web applications without worrying about the underlying infrastructure.

Cloud Storage: This is a service that lets you store and retrieve data in the cloud. You can use it to store your website content, user data, and other files.

Cloud SQL: This is a managed relational database service that lets you create, manage, and scale MySQL, PostgreSQL, and SQL Server databases in the cloud.

Use Google Cloud Console: Google Cloud Console is a web-based tool that lets you manage your Google Cloud resources. You can use it to create and manage virtual machines, set up and manage databases, deploy your web applications, and monitor your services.

Deploy your web application: Once you have created your virtual machines, set up your databases, and stored your files in the cloud, it’s time to deploy your web application. You can use a variety of tools and services to deploy your web application, including App Engine, Kubernetes Engine, and Cloud Run.

Monitor and optimize your web application: Once your web application is up and running, it’s important to monitor its performance and optimize it for better user experience. You can use a variety of tools and services to monitor and optimize your web application, including Stackdriver, Cloud Trace, and Cloud Debugger.

In conclusion, Google Cloud is a powerful platform for web developers that provides a wide range of tools and services to build, test, and deploy web applications. By understanding the basic services, using Google Cloud Console, deploying your web application, and monitoring and optimizing it, you can take full advantage of this platform to build high-performance web applications