teleren/devto huggingface dataset:
hoisting in javascript
Published: 2023-03-03 16:34:10

---
title: hoisting in javascript
published: true
description: 
tags: 
# cover_image: https://media.licdn.com/dms/image/C4D12AQEizD2vA3npuA/article-cover_image-shrink_720_1280/0/1627537525920?e=2147483647&v=beta&t=7X0aDiUUGSuL4gB61fcp_e2IiE_RkFjpOWmbozXIExg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-03 16:28 +0000
---

Hoisting is a behavior in JavaScript where variable and function declarations are moved to the top of their respective scopes during the compilation phase, before the code is executed. This means that you can use a variable or function before it is declared in your code. However, only the declarations are hoisted, not the actual assignments or function expressions.


Here's an example of hoisting with variable and function declarations:

console.log(x); // Output: undefined
var x = 5;

foo(); // Output: "Hello, World!"
function foo() {
  console.log("Hello, World!");
}

In the above code, the console.log statement for the variable x outputs undefined. This is because the declaration of the variable is hoisted to the top of the scope, but the assignment happens later in the code. So, at the time of the console.log statement, x has been declared but has not yet been assigned a value.

Similarly, the foo() function declaration is hoisted to the top of the scope, so you can call it before it appears in the code. This will output "Hello, World!" to the console.

It's important to note that only function declarations and variable declarations using var are hoisted. Other types of variable declarations, such as those using let or const, are not hoisted. Additionally, function expressions (such as const foo = function() {...}) are also not hoisted.
Easily Find Deprecated Runtimes on Your Lambda Functions
Tags: serverless, aws, tutorial, beginners
Published: 2023-03-03 16:32:44

---
published: true
title: 'Easily Find Deprecated Runtimes on Your Lambda Functions'
cover_image: https://raw.githubusercontent.com/pchol22/kumo-articles/master/blog-posts/sls-mentor/runtimes/assets/cover.png
description: ''
tags: serverless, AWS, tutorial, beginners
series: sls-mentor
canonical_url:
---

_This article is part of a series about [sls-mentor][sls-mentor], the new open-source tool allowing you to audit your AWS serverless infrastructure._

## What are deprecated runtimes?

AWS Lambda has been around for a while now. It is a great service as it allows to run code on the cloud and is compatible with many programming languages. However, as time goes by, these languages evolve and are getting new upgrades, leaving behind the old versions. This is why AWS Lambda has deprecated some of the runtimes that were available at the beginning. In this article, we will see how to find these deprecated runtimes on your Lambda functions.

Currently, the list of deprecated runtimes is the following:

- python3.6 ❌
- python2.7 ❌
- dotnetcore2.1 ❌
- ruby2.5 ❌
- nodejs10.x ❌
- nodejs8.10 ❌
- nodejs4.3 ❌
- nodejs6.10 ❌
- dotnetcore1.0 ❌
- dotnetcore2.0 ❌
- nodejs4.3-edge ❌
- nodejs ❌

If any of your lambda functions are using one of these runtimes, you should update them to a newer version, for security and performance reasons.

## How to find deprecated runtimes on your Lambda functions

But a problem persists: how do I simply now which Lambda functions are using these deprecated runtimes? This is where [sls-mentor][sls-mentor] comes in. It is a CLI tool that allows you to audit your AWS serverless infrastructure. It can be used to find deprecated runtimes on your Lambda functions.

[sls-mentor][sls-mentor] is a CLI tool that basically works like a big cloud linter. One of its rules detects for you whether a Lambda function is using a deprecated runtime or not.

To try sls-mentor, you only need to run it in your terminal using npx:

```bash
npx sls-mentor
```

sls-mentor does much more than that! It allows you to audit your AWS applications against a set of rules based on best-practices, and it already supports more that 10 services, including S3, CloudFront, API Gateway, Lambda, and more.

{% cta https://github.com/sls-mentor/sls-mentor %} Find sls-mentor on Github ⭐️ {% endcta %}

## Need help?

If you need help using the tool, check our [website][website] or [github][github]. You can also contact me on [twitter][twitter], I will be happy to help you!

If you need more information on deprecated runtimes, check out the [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html).

[sls-mentor]: https://www.sls-mentor.dev/
[website]: https://www.sls-mentor.dev/
[github]: https://github.com/sls-mentor/sls-mentor
[twitter]: https://twitter.com/PierreChollet22
Dashboard for laptop monitoring!!!!
Tags: react, flask, node, javascript
Published: 2023-03-03 16:13:27

{% embed https://github.com/codeninjausman/react-monitor- %}

### Project setup
```
npm install
```

#### Compiles and hot-reloads for development
```
npm run dev
```

#### Compiles and minifies for production
```
npm run build
```

---


## Backend

---

#Cpu info api
{% embed https://gist.github.com/CodeNinjaUsman/2c97d32d36ba278dc5a2a5d3409913f1 %}
# To save data in db
{% embed https://gist.github.com/CodeNinjaUsman/aa502a423c0c5e7522f84a051550aa3a %}
#Api for recent changes in files
{% embed https://gist.github.com/CodeNinjaUsman/36bd268f4a5640e15d5ac896f3dbbce0 %}
Run by
```
python watchdog_api.py C:\
python watchdog_flask.py
python cpu_monitor.py
```



######Thanks..
**Attribution is not required, although it is really appreciated. 🙏🙏**
Paracetamol.ts💊| #24: Explica este código TypeScript
Tags: typescript, javascript, spanish, webdev
Published: 2023-03-03 15:59:00

## **<center>Explica este código TypeScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark> </center>
¿Que hay de malo con este código?

```ts
type Id = number | string
type Size = "small" | "medium" | "big"

interface Dog {
  id: Id;
  name: string;
  age: number;
}

interface Dog {
  id: Id;
  name: string;
  age: number;
  color: string;
  size: Size;
}

const cooker:Dog = { // este objeto esta bien o no? 
  id: 1,
  name: "boby",
  age: 2,
}

console.log(cooker)
```

- A. `Imprime cooker por consola sin ningún error`
- B. `Imprime cooker por consola pero con una advertencia`
- C. `Error, no imprime nada`
- D. `Ninguna de las anteriores`

{% spoiler **Respuesta** %} 

✅ B. `Imprime cooker por consola pero con una advertencia`

Pese a que hay más similitudes que diferencias entre un `type` y una `interface`, este ejemplo esta bueno para ver justamente eso, sus diferencias.

Como vemos tenemos dos interfaces `Dog`, podras pensar que esto puede dar un error, pero no es así:

**1ra diferencia:**
Podemos crear interfaces con el mismo nombre sin errores, de hecho la 2da interfaz `Dog` sobre escribe a la primera, siendo esta la que debemos usar.
Esto no es posible hacerlo con `types`, no podemos tener dos `types` con el mismo nombre.

`cooker` se imprime efectivamente, pero tenemos la advertencia de que no esta completo, faltan las propiedades `color` y `size`.

**2da diferencia:**
Las interfaces estan hechas para ser usadas con clases o para crear objetos, mientras que los `types` son más útiles para tipos primitivos.

{% endspoiler %}

---

Pueden ver el último reto acá:

{% link https://dev.to/duxtech/paracetamolts-23-explica-este-codigo-typescript-48ip %}
Understanding the Ternary Operator in C and C++
Tags: beginners, programming, cpp, tutorial
Published: 2023-03-03 15:48:51

##Introduction:
In C and C++, the ternary operator, also known as the conditional operator, is a unique feature that allows for concise and efficient conditional expressions.

##Assigning a value based on a condition
The ternary operator can be used to assign a value to a variable based on a condition. For example, let’s say we have two integers `a` and `b`, and we want to assign the value of the larger integer to another variable `max`. We can use the ternary operator to achieve this in a single line of code:

```
int max = (a > b) ? a : b;
```
This code first checks if `a` is greater than `b`. If it is, the value of `a` is assigned to `max`. Otherwise, the value of `b`is assigned to `max`.

##Returning a value based on a condition
The ternary operator can also be used to return a value from a function based on a condition. For example, let’s say we have a function `absolute value` that takes an integer as input and returns its absolute value. We can use the ternary operator to simplify the implementation of this function:

```
int absolute value(int x) {
    return (x < 0) ? -x : x;
}
```
This code checks if `x` is negative. If it is, the absolute value of `x` is returned as `-x`. Otherwise, the value of `x` is returned.

##Nesting the ternary operator
The ternary operator can also be nested to create more complex conditional expressions. For example, let’s say we have three integers `a`, `b`, and `c`, and we want to find the largest of the three. We can use nested ternary operators to achieve this:

```
int max = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
```
This code first checks if `a` is greater than `b`. If it is, another ternary operator is used to check if a is greater than `c`. If it is, the value of `a` is assigned to `max`. If `a` is not greater than `c`, the value of `c` is assigned to `max`. If `a` is not greater than `b`, another ternary operator is used to check if `b` is greater than `c`. If it is, the value of `b` is assigned to `max`. If `b` is not greater than `c`, the value of `c` is assigned to `max`.

##Conclusion
In conclusion, the ternary operator is a powerful tool in C and C++ that can simplify conditional expressions and make code more concise and efficient. By understanding how to use the ternary operator effectively, you can write cleaner and more readable code.

##THANK YOU FOR READING
I hope you found this little article helpful. Please share it with your friends and colleagues. Sharing is caring.
Please visit also my [website](https://www.oliver-joisten.se/blog/) to read more informative blogposts
Connect with me on [LinkedIn](https://www.linkedin.com/in/oliver-joisten/) to read more about C/C++, Git, Github, and more…!
Latest Development Trends in .NET Services
Tags: webdev, dotnet, dotnetcore, programming
Published: 2023-03-03 15:08:53

The [recent trends and advancements in .NET Services](https://blog.dreamztech.com/latest-development-trends-in-net-software-services/) that are likely to continue shaping the industry in the future:

1. **Cloud-Native Development:** There is an increasing trend towards building cloud-native applications using .NET Services. Developers are leveraging platforms such as Azure, AWS, and Google Cloud Platform to build applications that are scalable, secure, and highly available.
2.  **Microservices Architecture:** Microservices architecture is becoming increasingly popular, as it allows developers to build and deploy small, loosely-coupled services that can be scaled independently. .NET Services, including Azure Service Fabric and Kubernetes, are popular platforms for building Microservices-based applications.
3. **Containerization:** Containerization is an essential component of Microservices architecture, and it enables developers to deploy applications more quickly and easily. With .NET Services, developers can use tools such as Docker and Kubernetes to containerize their applications.
4. ** AI and Machine Learning: ** The integration of artificial intelligence and machine learning into .NET Services is an emerging trend, allowing developers to build intelligent applications that can learn from user behavior and provide more personalized experiences.
5. **Cross-Platform Development: ** With the increasing demand for cross-platform applications, .NET Services are becoming more versatile, allowing developers to build applications that can run on Windows, Linux, and macOS. Xamarin and .NET Core are popular frameworks for cross-platform development.

Overall, .NET Services are continuing to evolve, and the above trends are likely to shape the future of .NET development in the coming years. 

If you are looking for a top rated [.NET Development Company](https://dreamztech.com/hire-net-developers/) in USA, you should consider DreamzTech. [Hire .NET Developers](https://dreamztech.com/hire-net-developers/) expert in the latest .NET framework and technologies.
Refactoring To Improve Performance
Tags: refactoring, cleancode, performance
Published: 2023-03-03 15:08:27

We, as developers, get lost in getting a feature complete within a time-frame and negate performance most of the time. Currently, I am working on an application where I was requested to improve performance. A page was taking around 14-15s to get loaded. I brought it down to 4-5s although it is still a lot to wait. Here are some things that impacted performance of application and how I sorted it out

## Lazy-loading everywhere
We used Entity Framework as ORM. In order to process data, we had couple of foreach statements and nested loops . Inside loop, properties of referenced entities and collections were manipulated. Loading such data's eagerly reduced around 100 queries.

## Automapper used everywhere
Automapper was used extensively in our application. Suppose we had an Address Entity and it had reference to State entity which further had reference to Province entity , we mapped Address entity to AddressViewModel using automapper. Even when I needed detail of Address entity in AddressViewModel, it would map all details of references in AddressViewModel. One way to get rid of it was to configure Automapper in a way to exclude mapping references of entity but that would cause our application to break since it was used elsewhere. Mapping only required references helped to improve performance.

## Selecting every fields from Database
Even if only some fields in a table were needed, every fields were retrieved from database. Some of the columns stored large amount of data's which resulted in weak performance. Selecting only the required fields improved performance by some margin.

## Less Use of TryParse
In order to parse Enum from string or int , code used to wrapped inside Try/Catch block . If exception was caught, do something. Exceptions are meant to be unintentional but we depend on exceptions to perform an action. Changing those statements to use TryParse improved readability and performance slightly.

## Unaware of SelectMany querying pattern
Whenever we needed a reference inside collections , we did SelectMany . Our common misconception was SelectMany does a single query to database and retrieved data. Using a profiler showed more number of queries than expected. Suppose , we had 5 items in collection and we used SelectMany to get references inside a collection, it did 5 queries where only 1 was expected. At the end, our solution was to issue a single query to required reference table.

That's all for now. **Happy Coding !!**
This Week In Python
Tags: python, discuss, thisweekinpython
Published: 2023-03-03 15:07:20


**Fri, March 03, 2023**


This Week in Python is a concise reading list about what happened in the past week in the Python universe. 

**I have received some good suggestions for this week's content. Thank you.**

**Did I miss anything from the Python universe this week? What did you read or tried out?**


## Python Articles


- [Why Python keeps growing, explained](https://github.blog/2023-03-02-why-python-keeps-growing-explained/)
- [Python is two languages now, and that's actually great](https://threeofwands.com/python-is-two-languages-now-and-thats-actually-great/)
- [Python’s multiprocessing performance problem](https://pythonspeed.com/articles/faster-multiprocessing-pickle/)
- [How to write Python extensions in Rust with PyO3](https://www.infoworld.com/article/3687744/how-to-write-python-extensions-in-rust-with-pyo3.html)
- [Wasm Workers Server 1.0: support for Python and Ruby](https://wasmlabs.dev/articles/wasm-workers-server-1-0-0/)

## Projects


- [cdev-sdk](https://github.com/cdev-framework/cdev-sdk) – Serverless Development Framework
- [pygwalker](https://github.com/Kanaries/pygwalker) – Turn your pandas dataframe into a Tableau-style User Interface
- [feast](https://github.com/feast-dev/feast) – Feature Store for Machine Learning
- [dbdeclare](https://github.com/raaidarshad/dbdeclare) – Declarative layer for your database
- [starqueue](https://github.com/starqueue/starqueue) – database backed message queue for Python

**Did I miss anything from the Python universe this week? What did you read or tried out?**
What was your win this week?
Tags: discuss, weeklyretro
Published: 2023-03-03 14:49:20

Heyo!

Hope y'all all have fabulous weekends. 😀

Looking back on this past week, what was something you were proud of accomplishing?

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Watching [The Unbearable Weight of Massive Talent](https://www.nickcage.movie/) or some other awesome flick 🍿

---

![A clip from ConAir of Nick Cage walking out of a bus full of prisoners, smiling with his long hair blowing in the wind](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pfqjnz8cl795ajrlpdk.gif)
Sei programar mas não sou programador
Tags: programming, beginners, webdev, discuss
Published: 2023-03-03 14:39:21


Pouco tempo atrás vi um post sobre a diferença de saber programar e ser programador, e sim, são duas coisas diferentes.

## Meu novo foco

Eu sei programar mas não trabalho diretamente com programação, hoje optei por trabalhar com algo que não envolva 100% do tempo programação, hoje meu foco está em trabalhar com nuvem, primeiramente como arquiteto e futuramente como DevOps.

## Nuances da programação

Muitos devem pensar "Você não sabe como é prazeroso programar..." ou "Como é bom ver sua aplicação rodando do jeitinho que você pensou" Sim, eu sei, porém, até chegar nesse resultado algumas vezes o que não te contam é que você passou horas(até dias) quebrando a cabeça até rodar tudo redondinho.

Já passei madrugadas codando(Quase sempre, me entupia de café), algo que hoje não faço mais e nem faria, e sem falar que tinha momentos que era bastante estressante programar e mesmo em momentos que não estava programando meu cérebro não desligava. Em momentos como banhos e antes de dormir, meu cérebro sempre tava pensando em uma solução para resolver o problema no código, era sempre algo como "E se tentarmos dessa forma ou se utilizarmos essa variável?". Ou seja, nem tudo são flores na área de programação, não estou aqui dizendo que não é uma boa área de atuação, mas que não é esse glamour todo.

## Dica para pessoas que querem entrar nessa área

Para pessoas que pretendem entra na área de TI, programação Web não é o único nicho na nossa área, existem inúmeras áreas então se não quiser necessariamente ser programador Web, recomendo pesquisar as sub-áreas que vão de programação, data science, DBA, Suporte, Nuvem e etc.

Recomendo fortemente que comecem pela faculdade... Eu sei que tem alguns alecrins dourados que defendem que não precisa de faculdade para entrar na área de TI e eu sei que é verdade.

Porém, é a faculdade que vai te dar a base de tudo, dos componentes do computador, quais os protocolos são utilizados em uma troca de dados, o que é POO, o que é socket, o que é API, da programação básica até a avançada e etc, etc e etc.

O curso de programação seja ela JS, React, NodeJS, PHP e etc, ela pressupõe que você já possua esses conhecimentos, o que na maioria das vezes, as pessoas não tem. Uma última coisa é... não pense que estudando 6 meses programação, você já vai começar ganhando 3,4,5K são raros os casos, ou seja, vai ser preciso acumular experiência até chegar nesses valores. 

Lembrando que essa é apenas minha opinião, e você qual sua opinião?
How to Create Microsoft Azure Language Translator APIs Cognitive Service
Published: 2023-03-03 14:30:25


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

Azure Cognitive Services are cloud-based services with REST APIs, client library SDKs, and user interfaces available to help you build cognitive intelligence into your applications. You can add cognitive features to your applications without having artificial intelligence (AI) or data science skills. Cognitive Services comprises various Al services that enable you to build cognitive solutions that can see, hear, speak, understand, and even make decisions.

Translator is a cloud-based machine translation service you can use to translate text in with a simple REST API call. The service uses modern neural machine translation technology and offers statistical machine translation technology.

**Steps to Creating Microsoft Azure Language Translator:**
STEP 1:
Create a Microsoft azure account and login to the portal and click on Cognitive Services (portal.azure.com)

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

STEP 2:
On the Cognitive Service page, under Language, click on ‘Create’ under ‘Translator’

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

STEP 3:
Line 1 – Choose your Azure Subscription
Line 2 – Your resource group name you have chosen
Line 3 – Preferred location
Line 4 – Choose a unique name
Line 5 – Use this if you’re on a budget like me. Lol
Then click ‘Review + create

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

STEP 4:
Click on "create"

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

STEP 5:
Click on ‘Go to resource’

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

STEP 6:

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

FINAL STEP:
Click on the arrows to change to any language of your choice and write a command for translation

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

HURRAY!!! Your Microsoft Azure Cognitive Service Language Translator is ready.
If you want to clean up and remove a Cognitive Service subscription, you can delete the resource group but note that deleting the resource group also deletes any other resources contained in the group, so it is safer to delete the Cognitive service instead.

**PLEASE NOTE: Always remember to shut down and delete your azure virtual machine after usage because its a pay-as-you-go service. This will help you save your credit and money.
**
Flatiron Phase-2
Tags: react
Published: 2023-03-03 14:38:37

3-3-23:
Its Friday, and here at flatirons 1-30SE East cohort its Blog time!! Aside from it being required, I have heard first-hand that these can be extremely helpful in our career endeavors. 
This blog post in particular (if my understanding is correct) is about the usefulness of the dependency array for the useEffect hook. I have found myself needing to iterate over the array of objects fetched based on their assigned IDs. This became an issue when the non deleted objects ID's were not reassigned in the array (4,5,6,7 and 6 is deleted now the array is 4,5,7 and not 4,5,new6). A way around this is to use the dependency array for the useEffect's second argument that refers to the state of the array you are filling with the data fetched. 

const[arrayState, setArrayState] = useState([])

useEffect(()=>{fetch('api')},[arrayState]) 
 
this way, when arrayState changes the objects will be refetched. This could even be utilized when sorting data to have the order of objects in the array is reflected in the ID's as well