teleren/devto huggingface dataset:
JavaScript Call Stack
Tags: javascript, beginners, programming
Published: 2022-01-01 20:44:40

JavaScript engine uses a call stack to manage execution contexts: the Global Execution Context and Function Execution Contexts.

The call stack works based on the LIFO principle i.e., last-in-first-out.

When you execute a script, the JavaScript engine creates a Global Execution Context and pushes it on top of the call stack.

Whenever a function is called, the JavaScript engine creates a Function Execution Context for the function, pushes it on top of the Call Stack, and starts executing the function.

If a function calls another function, the JavaScript engine creates a new Function Execution Context for the function that is being called and pushes it on top of the call stack.

When the current function completes, the JavaScript engine pops it off the call stack and resumes the execution where it left off in the last code listing.

The script will stop when the call stack is empty.

## JavaScript call stack

start with this code below

```js
function add(a, b) {
  return a + b;
}

function average(a, b) {
  return add(a, b) / 2;
}

var x = average(10, 20);
```
JavaScript engine execute the code above, and right after the calling of `average()` function, he will take the function call and put it inside call stack, since `average()` function calling `add()` function, the same thing will happen again, he will take the function call `add()` and put it inside call stack

The following figure illustrates this


![Call Stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbpl2i0goqnms4hduiz9.gif)

## Stack overflow

The call stack has a fixed size, depending on the implementation of the host environment, either the web browser or Node.js.

If the number of the execution contexts exceeds the size of the stack, a stack overflow will occur.

consider this code below

```js
function foo() {
  foo();
}

foo();
```

when you execute a recursive function that has no exit condition, it will result in a stack overflow error:

The following figure illustrates this


![Stack overflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osp5hnawrdbb4uiu1jsg.gif)

that's it for call stack, next post will be about [event loop](https://dev.to/ejjraifihamza/javascript-event-loop-3kd4)

## Summary

In this post, you have learned about the JavaScript call stack that helps keep track of the execution contexts or function calls.
🤪 Tell me how to build a duplicate detection system!
Tags: javascript, discuss, webdev, productivity
Published: 2022-01-01 19:47:08

[I'm working on a linter right now](https://github.com/fairfield-programming/eaf-linter), and one of the requested features for it was code duplication detection. I made an [issue for it already](https://github.com/fairfield-programming/eaf-linter/issues/6), but I need to start working on it. And, that's where my question lies. 

I can either build the system to detect the duplications based on plain text. This is how most systems work because it is the simpler of the two options. But, it is also the most failure prone. For instance, this system would fail if there was the same exact code in two places, but there was a comment in the middle of one of them- it would not register as a duplicate.  

Alternatively, I can use an abstract syntax tree to detect the duplications. But, theres another problem there- what is the most-lightweight and all-around-best javascript parser out there? I'm planning on using the babel parser but I'm already running into a problem because it doesn't parse the comments in a way I would like. 

**So, if you have an opinion on what I should do, please leave a comment below. Also, please star [the project](https://github.com/fairfield-programming/eaf-linter) and contribute if you have time. If you can, that would be amazing, and I thank you so much!**
Bastante Conteúdo e Feliz 2022!
Tags: 2022, ruby, elixir, braziliandevs
Published: 2022-01-01 19:27:44

Um feliz 2022 para todos nós!

Este ano estou me propondo criar bastante conteúdo, e meu objetivo é trazer todo o conteúdo do curso que já ministrei e tudo que venho estudando.

E o primeiro do ano já esta pronto:

[O que é uma Gem?] (https://lnkd.in/gminbnc5)

Em 2021 minha meta seria ao menos 1 conteúdo publicado por mês, e consegui:

1 - [Aridade de uma função] (https://lnkd.in/ewAtnwC)

2 - [O que é um atom?] (https://lnkd.in/eJwUDyP)

3 - [List não é array!] (https://lnkd.in/gX6GnsjY)

4 - [{"O", "que", "é", 1, :tupla, "?"}] (https://lnkd.in/esmVQA6)

5 - [O que é um map?] (https://lnkd.in/ewyecuV)

6 - [A história do Ruby] (https://lnkd.in/gxPXpdAA)

7 - [Introdução ao controle de versão Git] (https://lnkd.in/gsXN2eNR)

8 - [Array em Ruby] (https://lnkd.in/g4N3gnRt)

9 - [Tipagem Dinâmica] (https://lnkd.in/gmr_8SNU)

10 - [Tipagem Forte] (https://lnkd.in/gH6jbgR9)

11 - [Ruby - Diferença entre %w e %W] (https://lnkd.in/gjPHBf2H)

12 - [Hash em Ruby] (https://lnkd.in/gzTEFgiQ)

13 - [Adicionando Tailwind em um projeto com Rails 7] (https://lnkd.in/gs8FN7Nq)

**Contato:**
Email: contato@diegonovais.com.br
LinkedIn: https://www.linkedin.com/in/diegonovais/
Github: https://github.com/dnovais
:Round to - In Bubble.io
Tags: nocode, webdev, tutorial, bubbleio
Published: 2022-01-01 19:25:47

How to :round to in bubble.io app. The documentation for me wasn't very clear, so I'm being pro-active and documenting the glimmer of achievements on dev.to for other nocode coders. 

> ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/anjfy9k78dqtpdbbvr2m.jpg)

Very simple. (when you know how to do it, lol)

Lets say you want to get an average on a number. You would use :average in the editor like this pic below.

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

but what if that average ends up being an average of 3.8 or 0.234? I had come across this problem, and wanted to share my discoveries.

> I'm using a Star Rating plugin - Highly Recommend it, but just like everything, it needs to be fully setup before it actually can be used properly. Message me if you want me to post a how to on this bubble plugin. This plugin can be found by going to your plugin's section and in search type in "**_Bootstrap Star Rating Input_**". Also along with [documentation found here](https://manual.bubble.io/core-resources/bubble-made-plugins/star-rating)

Suppose you want to round to the nearest integer. Inside the bubble editor you want to :round to . After placing the :round to you must enter a digit after, i will explain below.

If your :average is:

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

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

> 3.8 and you want to get to a 4:
```
:round to 0
```

If your :average is:

> 0.234 and you want to get to 0.2:

```
:round to 1
```

If your :average is:

> 0.234 and you want to get to 0.23:

```
:round to 2
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vrxblp6soi6o5uwwb81.jpg)

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



So on, and so forth. I sincerely hope this helps you.

Follow, Like, Unicorn - I would.
Accessing your standalone Gitlab Snippets with Curl
Tags: programming, curl, gitlab, snippets
Published: 2022-01-25 17:10:37

---
title: Accessing your standalone Gitlab Snippets with Curl
published: true
date: 2022-01-01 19:20:28 UTC
tags: Programming,curl,gitlab,snippets
canonical_url: https://www.jucktion.com/tech/snippets-curl-gitlab/
---

GitLab is an open-source collaborative git platform with tons of features. Gitlab offers a broad range of features for its users to make git more collaborative and accessible. It offers free tier for users with personal and hobby projects. Users can create private repositories if they don’t want the code to be public. Similar to GitHub’s gists, GitLab has its snippets. Snippets are short standalone programs that usually server a specific purpose. You can have private snippets as well. Here’s how you access your private snippets remotely without logging into your GitLab account.

![Gitlab Snippets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2hm0ltczz2smybwbaia.png)

GitLab has [documented API access](https://docs.gitlab.com/ee/api/repository_files.html) for files in a repository, but it’s missing them for standalone snippets. The documentation has snippets access shown [here](https://docs.gitlab.com/ee/api/project_snippets.html), but it targets snippets that are already inside a project. It says nothing about snippets not inside a project.

You will need:

* A GitLab private access token(requires login) to access the file remotely or through your terminal.
* The ID of your snippet.
* General understanding of curl

Now you will have to format a curl syntax to make it grab your snippets file. The private access token will verify our request so the file inaccessible to anyone but us.
```
curl --header “PRIVATE-TOKEN: <private-access-token>” “https://gitlab.com/api/v4/snippets/<snippet-id>/raw” -o main.py
```
Example:
```
curl --header “PRIVATE-TOKEN: 2LAX6jyj4f8Zb5fd5Ft4yA” “https://gitlab.com/api/v4/snippets/9999999/raw” -o main.py
```

The “main.py” is file name you want the output to be pasted to. It can be any name you prefer the file name and extension to be saved. Obviously, it it is a source code file, you’ll have to name it properly, but the idea is that It doesn’t have to reflect the exact filename on your snippet.

![Curl Operation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucii775xw12zlrtd4gog.png)

If all goes well, you will see a file download progress and the file should appear on your folder. Notice the “Total” column, it should have a file size information. It’s a sign that the command worked.
Abstract in Coding
Published: 2022-01-01 19:15:28

Coding is not just the process making software applications and websites. Coding can be used for many other purposes, such as to create a budget, solve a math problem, or even write an abstract. This blog post will teach you how to do all of these tasks using code and show you examples of the different ways it can be used.

Coding can be used to make or solve almost every kind of problem, but one of the most common uses is to make software. For example, "software developers are quickly solving the problem of global warming by writing new code."

Coding is a way to write or create something using only numbers and letters. Code can do many different things for many different purposes. It can also be used in many different subjects. Programming languages are special ways to code.

Source: [micro switches](https://www.unionwellvietnam.com/)
The Saga Of Magnificent Metaverse Has Begun! Here's Is What You Need to Know.
Published: 2022-01-01 18:36:31


<p>All the technological advancements we humankind have achieved helped us experience this world with quality. A couple of decades back, people used phones just for messages and texts. And then came the boom of the internet and smartphones, and things started getting more visual. In the present, we are living in a time where connections are super fast in most parts of the world. Of course, nothing is more inspiring than a visual treat. We have made a leap from text to photos to videos with the dawn of super-fast networks and ever-evolving smartphones.</p>
<p>All these changes indicate our rising need to get an immersive and quality experience through the devices we use. These advancements reflect how we people have always been trying to reach a point where we can perceive data through our five senses. In other words, we want everything from entertainment to academics to be more mesmeric. There is no surprise in this because we are the only living beings on Earth with such complex neural connections that we always wanted to experience and change things for the better, the very essence of our evolution to this scale. And the good news is that we are getting one step closer to this dream of ours to have surreal and more tangible experiences with the coming of the Metaverse.</p>
<p>Metaverse has been a hot talking point ever since Facebook renamed itself to Meta to signal that the company was branching out and venturing into the world of Metaverse. Ever thought of an embodied internet where you are in the experience and not just looking at it like you do now? Well, this is the basic concept behind Metaverse. It's a hypothesized 3D virtual environment where we can do almost everything from work, play, shop, create, and much more.</p>
<p>The pandemic has made many people more skeptical about social interactions. However, we are social beings, so when Metaverse comes into existence, we can have more tangible interactions with more and more people. With Metaverse, we get the power to experience things that we could only dream of before using our virtual avatar.</p>
<p>While Metaverse might sound like one of the best advancements humanity will achieve, it has its flip side too. Ever wondered why aliens who we supposed to be super civilized and advanced than us didn't come here yet? What if they are all lost in their little virtual universes. Now that we talk about colonizing space and mars. Will we ever get there? Many people find even Instagram addicting, a mere 2D social platform that is nothing compared to the gigantic Metaverse in the making.</p>
<p>The real question is so do we have to be scared about Metaverses? No, it is no threat because addictions have been something that humankind has been battling from time immemorial. While one can argue that many are getting addicted, on the flip side, millions of people are getting benefitted and more visibility from technological advancements. It depends on how we choose to use it. We have the power to pick out things wisely. With more technology comes more responsibility.</p>
Binary Search Algorithm
Tags: algorithms, programming, computerscience
Published: 2022-01-01 18:12:40

What is binary search?
Binary search is one of the searching algorithm used to find element in sorted array in Logarithmic running time complexity

**Note:** Binary search can only be applied in sorted array

**Why binary search is better then linear search**
Binary search has O(log(n)) logarithmic time complexity and linear search has O(n) linear time complexity     

**How Binary Search Work**
Binary search use divide and conquer strategy to search element in given array. Binary search divide the searching area into exact half in each pass.

start : it store the value of starting index
end : it stores the value of ending index
mid : it stores the value of middle index

start = 0
end = array_length -1
mid = (start + end)/2 // but that's not good practice
(start + end) can sometime exceed the integer limit

mid = start + (end - start)/2 // this is the correct way

Suppose at first we have an array nums = { 1, 2, 4, 8, 10, 50, 70, 88, 100 } (note here array is sorted) and your target element is 70.
First check if middle element of array is equal to target or not. If it's equal then return middle index or mid. If not then check if target is smaller or bigger then middle element. 
If target is smaller then middle element reduce the search space, end = mid -1. Now new search space is (start, mid -1).  
If target is bigger the middle element reduce the search space, start = mid +1. Now new search space is (mid+1, end).

Hence, at each pass the search space will reduce into half until start <= end. If start became greater then end, the loop will break

**Algorithm**
Binary search in Java
```
import java.util.Arrays;  

public class BinarySearch {
    public static void main(String[] args) {

        int[] nums = { 1, 2, 3, 19, 29, 40, 60, 100 };
        int target = 40;

        System.out.println(Arrays.toString(nums));
        System.out.println(binarySearch(nums, target));
    }

    static int binarySearch(int[] nums, int target) {

        int start = 0;
        int end = nums.length - 1;

        while (start <= end) {

            int mid = start + (end - start) / 2;
            if (nums[mid] == target) {
                return mid;
            } else if (target < nums[mid]) {
                end = mid - 1;
            } else {
                start = mid + 1;
            }

        }

        return -1;
    }
}
```
Artificial Intelligence
Published: 2022-01-01 18:06:29

Artificial intelligence is a branch of computer science and engineering that deals with creating intelligent machines capable of performing tasks that normally require human intelligence.

What does this mean for you? It means, among other things, that artificial intelligence can help make your life easier in the near future. But how exactly might this look like in practice? Let's say you're making a cake for your sister's birthday.
Visit: [Website](https://www.unionwellrussia.com/)
2021 Wrapped 
Tags: learning, growth, career, motivation
Published: 2022-01-01 18:00:21

What a year 2021 has been! It has easily been the year I’ve upgraded the most in tech, from undertaking various courses to taking part in events to my first ever kaggle competition, last year was absolutely mind blowing! 

I started the year with an introductory course on AI, followed by a course on ML and introduction to Data Science in Python. Amidst these courses, I also attended Google I/O, which honestly was such a turning point for me! Attending keynotes and other events was exhilarating but nothing can match the experience I had of being able to interact with women in tech from all around the world! Being the youngest in all the groups, I received lots of advice on how to advance in the field. I connected with quite a few of them on LinkedIn and they were all such incredible women that have definitely been one of the major inspirations for me to keep learning this year! 

I also made a few projects, used GitHub for the first time (took me over a day to figure out the basics but it was so worth it!!), and hosted my projects there. Following this, I attended a Kaggle event on ML through which I got to take part in my first ever Kaggle competition and a few mini courses along the way. 

I did a few labs on GCP throughout the year. I also took part in my first ever open source program, GirlScript Winter of Contributing where I mainly contributed under the domain of Data Science With Python. I have learnt so much from my mentors and supervisors, it’s honestly quite hard to put into words! Hacktoberfest’21 was a whole new experience too. Finding repos and making valid and meaningful contributions was incredibly fun. 

Oh and I also published my first ever blog! I’ve always been passionate about writing but clubbing that with my love for tech was just something else. 

Last year I mainly expanded my knowledge in ML, AI and data science so carring that forward, this year I would love to explore a few more fields and decide what I would like to begin my career in. 

Thank you so much for this wonderful year, with even more wonderful experiences! I have grown so much this year, and the credit goes to the entire tech community! 

Wishing you all the very best for 2022. 

I would love to connect with you all, please drop me a message if you’d like! :))
target="_blank" is a security risk?
Tags: security, html, javascript, webdev
Published: 2022-01-01 17:58:17

As we all use target="_blank" to open the link into new tab of a window but everyone should know a risk inside it.

When we open a new tab link `window.opener` get triggered which made a limited access to the specific tab opened, _for example_; you can not go back in the previous page by clicking back button from your URL bar.   

**So what is the risk here?**
when the new tab link open it can alter the Link page URL from `window.opener.location`. 
If your external link is not trusty that may cause a real problem to your website.

**What can happen?**
1. Hacker can redirect your domain.
2. CSRF can be performed.
3. XML entities can be altered. 

**How to prevent this?**
Do not forget to add relation attribute in your link tag `rel=noopener noreferrer` 

**_In a Nutshell_** `<a href="https://thehassantahir.web.app" target="_blank" rel="noopener noreferrer">Thehassantahir</a>`


**_Comment your views &
Follow me on [Github](https://github.com/thehassantahir) & [Twitter](https://twitter.com/thehassantahir) and Sponsor me on_** 👇
[![Patreon Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n16ri16f50t2xf348879.png)](https://www.patreon.com/hassantahir)
WHAT IS SOURCETREE? HOW TO INSTALL IT?
Tags: sourcetree, github, githunt, git
Published: 2022-01-01 17:53:32

Hey folks!

In this blog we will learn about sourcetree.

So first of all what is sourcetree?

```
Sourcetree is a gui application (desktop client app) that helps
you to interact with your git repository. 
Basically you can perform almost all operations on your git repository.

So, if you want say good bye to your command line or 
if you want to learn github without using command line 
or github commands then sourcetree would be the best solution for you.
```


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


**Now Let's Download Sourcetree:**
 Go to https://sourcetreeapp.com/ then download the installer
 
**then Install the setup:**
  Installing sourcetree is simple as you install other simple softwares but if you are facing any issue.

So, You can follow this video https://www.youtube.com/watch?v=vx68MO3k_Ys

Thanks!