teleren/devto huggingface dataset:
Javascript 【tricky】💡interview output questions (Part 2)
Tags: javascript, webdev, frontend, beginners
Published: 2023-06-23 04:53:07

## What is the output for each code mentioned below and Why ? 
Add your solutions with explanation in the comment section.

### **Question 1**
```javascript
var y = 1;
  if (function f(){}) {
    y += typeof f;
  }
  console.log(y);
```

### **Question 2**
```javascript
var output = (function(x){
    delete x;
    return x;
  })(0);
  console.log(output);
```

### **Question 3**
```javascript
var Employee = {
  company: ’myCompany’
}
var emp1 = Object.create(Employee);
delete emp1.company
console.log(emp1.company);
```

### **Question 4**
```javascript
(function() {
   var a = b = 5;
})();
console.log(b);
```

### **Question 5**
```javascript
function test() {
   console.log(a);
   console.log(foo());
   var a = 1;
   function foo() {
return 2; }
}
test();
```
Docker commands | Docker comandos
Published: 2023-06-23 04:35:56


- Para crear un volumen simple

```
docker volume create test-mariadb
```

- Para crear un container asociado a un volumen previamente creado.

```sh
docker container run \
-dp 3306:3306 \
--name world-db-mariadb \
--env MARIADB_USER=user \
--env MARIADB_PASSWORD=password \
--env MARIADB_ROOT_PASSWORD=password \
--env MARIADB_DATABASE=world-mariadb \
--volume test-mariadb:/var/lib/mysql \
mariadb:jammy
```

- Para saber en donde guardar el volumen deberemos ir a la documentación de DockerHub para buscar en donde se almacena la base de datos de dicha imagen

- Para remover

```sh
docker container rm aass
docker volume rm asdasd
```

- Para saber el puerto expuesto en mi docker container
```sh
docker port containername
```

- Para saber qué puertos expone mi imagen de docker
```sh
docker inspect
```

---
---
---

### Docker network

Para crear network 

```sh
docker network create network-name
```

crear el mismo contenedor sin el docker-compose.yml
```sh
docker container run \
--name nest-app \
-w /app \
-p 80:3000 \
-v "$(pwd)":/app \
node:16-alpine3.16 \
sh -v "npm install && npm run start:dev"
```

docker-compose.yml


para cuando quieres eliminar una imagen y vovler a construir un build de docker-compose
docker rmi imagename/backend-test:v1 && docker-compose up -d --build
Explore Hilux Trucks at Uttam Toyota, the Premier Hilux Showroom in East Delhi
Tags: hilux, toyotadealereastdelhi, hiluxdealereastdelhi, uttamtoyota
Published: 2023-06-23 04:29:28

Visit Uttam Toyota, the leading [Hilux dealer in East Delhi](https://www.uttamtoyota.com/showroom/hilux/), to discover the rugged and reliable Hilux trucks. Find the perfect Hilux model to meet your needs and experience unmatched performance, durability, and versatility. Contact Uttam Toyota today and take the first step towards owning your dream Hilux truck in East Delhi.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0jyfe5h2netcevdbpxc.jpeg)
Generate files and folder structures of your code
Tags: automation, tree, bash, programming
Published: 2023-06-23 04:02:27

I recently found a cool way to generate the file and folder structure inside your root project directory. In order to generate the folder structure, you need to follow following steps,

### 1. Download `tree` package

If you are in `mac`, type following code in your terminal,

```bash
brew install tree
```

If you are in `ubuntu`, type following code in your terminal,

```bash
sudo apt install tree
```

### 2. Navigate to the root directory

```bash
cd ~/Downloads/my-project
```

> Make sure to change the path.

### 3. Explore tree command

If you want to generate the files and folder structure in your working directory, just type `tree` command in terminal and it will print out the files and folders in proper structure,

```bash
tree
```

But, most of the time, our project might contain some of the unnecessary things such as, `node_modules`, `python_venv` etc. In that case, you might want to avoid those folders or files. In order to avoid those, simply wright the following code,

```bash
find . -type f -not -path '*/\.*' | grep -v -F -f .gitignore | cut -c 3- | tree --fromfile --prune
```

Let me explain the code for you,

* `find . -type f -not -path '*/\.*'`: This command recursively finds all the files (`-type f`) in the current directory (`.`) and its subdirectories. The `-not -path '*/\.*'` part excludes hidden files such as `.git`.

* `grep -v -F -f .gitignore`: This command filters out the files and directories listed in the `.gitignore` file.

* The `cut -c 3-` command removes the first two characters from each line of input, effectively removing the `"./"` prefix in each path.

* `tree --fromfile --prune`: This command reads the file and directory structure from the output of the previous commands and displays it using the `tree` command. The `--prune` option excludes the empty directories from the output.

I got the following result from above script:

```
.
├── __init__.py
├── file1.ipynb
├── file2.ipynb
├── requirements.txt
├── script_json
│   ├── test1.json
│   └── test2.json
├── version1.ipynb
└── version2.ipynb

```

I hope this post is informative for you. If you like this blog, please support me by subscribing to my YouTube channel: https://www.youtube.com/c/iamtekson
Automatically Generate Icons for Apps
Tags: development, beginners, programming, tutorial
Published: 2023-06-23 04:00:00

**Elevate Your App's Visual Appeal with Custom Icons, Automatically Generated by [Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)**

**DON'T WANNA READ THE LONG POST?
[FIND THE LINK TO AI](https://www.aiforme.wiki/ai/tools/Appiconai)**

Introducing **[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)**, the cutting-edge AI tool designed to simplify the process of creating app icons for developers. With Appiconai, you can harness the power of artificial intelligence to generate a completely unique set of icons for your app. Let's explore the features and benefits of **[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)** and discover how it can elevate the visual appeal of your app.

**Seamless Icon Generation:**

**[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)** takes the hassle out of creating app icons by utilizing the capabilities of AI. By simply entering your email and password and making a one-time payment of $20, you gain access to 50 sets of 6 distinctive icons. These icons are automatically generated based on your app's specifications, providing you with a wide range of options to choose from.

**Tailored Options with AI:**

With **[Appiconai's](https://www.aiforme.wiki/ai/tools/Appiconai)** AI-powered technology, you can rest assured that each generated icon set is tailored to suit your app's unique requirements. The tool leverages its deep learning capabilities to analyze your app's concept, theme, and target audience, generating icons that perfectly align with your vision.

**Simplicity and Convenience:**

**[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)** offers a fast and user-friendly experience. You can quickly and easily obtain custom icons for your app, eliminating the need for time-consuming manual design work. This allows you to focus on other crucial aspects of app development while ensuring your app stands out with visually captivating icons.

**Unlock the Potential:**

By embracing **[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)**, you unlock the potential to create eye-catching app icons that leave a lasting impression on your users. With its AI-driven approach, you can confidently showcase your app's uniqueness and professionalism through stunning visuals, setting it apart from the competition.

**[Appiconai](https://www.aiforme.wiki/ai/tools/Appiconai)** revolutionizes the way developers create app icons. With its AI-powered capabilities, you can generate custom icon sets effortlessly, saving valuable time and resources. 

Elevate your app's visual appeal and create a strong brand identity with **[Appiconai's](https://www.aiforme.wiki/ai/tools/Appiconai)** automatically generated icons.

**[FIND THE LINK TO AI](https://www.aiforme.wiki/ai/tools/Appiconai)**

Embrace the power of AI and witness your app come to life with captivating and memorable icons. 🚀📱✨
Intrigued by the idea of another off-world blog
Published: 2023-06-23 03:29:48

---
title: Intrigued by the idea of another off-world blog 
published: true
description: On digital gardens
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-06-22 20:25 +0000
---

I'd never really thought much about using this site as a blog, much less the concept of [digital gardens](https://dev.to/jbranchaud/the-digital-garden-l10) until I read this post. 

One of the challenges of having a bevy of both professional and personal interests, is that it's hard to navigate how to develop your online presence. When I was younger, it was less important. As personal websites became something people would look up, I felt the need to keep a presence "presentable" for anyone who might show up.

These days, I don't need a website to get me a job. So I can kinda do whatever I want and it'd be fun to recede to the blogging days of yore to some degree, partially because in the absence of Twitter, I realized how much I'd prefer to put stuff down somewhere in a place I own. 

Weirdly, I just type better inside of a CMS box. I can't make sense of that, but it's why for a long time I found Tumblr such a great place for my writing and at the peak Tumblr time, I was prolific. Same with older sites. I could do the same for my own site, but there's something nice about having a scratchpad where people can react, especially as it relates to professional topics, because there's almost no way I'd be where I am without the amplifier that Twitter ended up being for me at a key time in my career.
C++, remove all duplicated, multiple value in sorted vector
Tags: cpp, remove, duplicated, sorted
Published: 2023-06-23 02:58:03

Just a quick way to remove all multiple, duplicated values in a sorted array

```cpp
template <class T>
void removeAllDuplicates(vector<T>& vec) {
    size_t i;
    size_t pos = 0;
    for (i = 1; i < vec.size(); i++) {
        if (vec[i] != vec[pos]) {
            pos++;
            vec[pos] = vec[i];
        }
    }
    vec.erase(vec.begin() + pos + 1, vec.end());
}
```
Prerequisites to Learn Angular
Tags: angular, beginners, tutorial, webdev
Published: 2023-06-23 02:54:47

Before starting with Angular development, it's helpful to have a basic understanding of the following technologies and concepts:

- **HTML**
Having a good understanding of HTML (Hypertext Markup Language) is essential for building web applications with Angular. HTML is used to structure the content of web pages.

- **CSS**
Familiarity with CSS (Cascading Style Sheets) is important for styling and positioning elements on web pages. CSS is used to define the visual appearance of HTML elements.

- **JavaScript**
Angular is built with JavaScript, so having a solid understanding of JavaScript is crucial. You should be comfortable with concepts such as variables, data types, functions, objects, and control flow.

- **TypeScript**
Angular is primarily written in TypeScript, a superset of JavaScript that adds static typing and other features. It's recommended to have some knowledge of TypeScript, as you'll be writing Angular code using this language.

- **Node.js and npm**
Understanding the basics of Node.js and npm (Node Package Manager) is important. Node.js is a JavaScript runtime that allows you to execute JavaScript code outside the browser, while npm is used to manage packages and dependencies in your project.

- **IDE or Text Editor**
Choose an Integrated Development Environment (IDE) or a text editor that you're comfortable with for writing your code. Popular options for Angular development include Visual Studio Code, WebStorm, and Atom.

- **Command Line or Terminal**
Familiarize yourself with using the command line or terminal for running commands and navigating through directories. This will be useful when executing Angular CLI commands and managing your Angular project.

Having a solid foundation in these technologies and concepts will greatly assist you in understanding and effectively developing Angular applications. Additionally, it's beneficial to refer to the official [Angular documentation](https://angular.io/docs) as a comprehensive resource for learning Angular and its various features.
Understanding Foreign Keys in PostgreSQL
Tags: postgres, intern, foreignkey, db
Published: 2023-06-23 02:38:44

## Introduction

Foreign keys are a fundamental concept in relational databases, including PostgreSQL. They establish relationships between tables and ensure data integrity. In this article, we will explore the concept of foreign keys in PostgreSQL, their syntax, and how they can be used to enforce referential integrity.


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


## What are Foreign Keys?

Foreign keys are a mechanism that allows us to establish relationships between tables in a relational database. They define a link between two tables based on the values of one or more columns. The primary purpose of foreign keys is to enforce referential integrity, ensuring that data in the related tables remains consistent.

## Syntax of Foreign Keys in PostgreSQL

In PostgreSQL, foreign keys are defined as a column or a set of columns in a table that reference the primary key or a unique constraint of another table. The syntax for creating a foreign key constraint involves specifying the referencing table, the referenced table, and the column(s) involved in the relationship.

## Performance Considerations

Foreign keys provide essential data integrity benefits in PostgreSQL, but they can also impact database performance. It's important to consider the following factors when working with foreign keys to optimize query performance and minimize potential performance trade-offs:

**Index Creation**: Creating indexes on the columns involved in foreign key relationships can significantly improve query performance. Indexes allow the database to locate and retrieve related data more efficiently. PostgreSQL automatically creates an index on the referencing column when a foreign key constraint is added, but you may need to manually create indexes on the referenced columns if they are frequently used in queries.

**Query Optimization**: When executing queries involving foreign keys, it's crucial to optimize the queries to make the best use of available indexes. Use EXPLAIN and EXPLAIN ANALYZE to analyze query execution plans and identify potential performance bottlenecks. Consider adding indexes, rewriting queries, or using query hints like JOIN order adjustments to improve performance.

## Conclusion

Foreign keys in PostgreSQL provide a powerful mechanism for establishing relationships and ensuring data integrity. They enable developers to build robust and consistent databases by enforcing referential integrity rules. By incorporating foreign keys into your database design, you can create more reliable and efficient applications.
Research with Snyk and Redhunt Labs: Scanning the top 1000 orgs on GitHub
Tags: java, javascript, python, ruby
Published: 2023-06-23 02:00:40

Open source code is a vital aspect of modern development. It allows developers to increase their application’s functionality, while reducing overall development time. However, the system isn’t perfect. The nature of third party software and it’s dependencies often creates opportunity for security vulnerabilities to lurk in libraries and downloads. 


One solution to this problem is package managers. Many languages, such as JavaScript or Python, have package managers like [npm (Node Package Manager)](https://www.npmjs.com/) and [pip (Preferred Installer Program)](https://pypi.org/project/pip/) — which rely on the specific files they read to determine what dependencies should be downloaded. If a dependency explicitly mentions a version, the package manager will download those dependency versions. But, the versions of these dependencies are often depreciated, and could contain potential security vulnerabilities. 


In a recent research project, Snyk and Redhunt Labs set out to learn more about the security posture of popular GitHub repositories. The top 1000 GitHub organizations were scanned for insecure dependencies in their source repositories. By extracting their dependencies and comparing their versions against widely known security flaws, the researchers attempted to evaluate the security state of these repositories. Results for the Java, JavaScript, Python, and Ruby repositories are presented separately in the report.


In order to concentrate on repositories with a possible impact, the research entailed filtering down repositories based on star count and particular keywords. In total, 11,900 repositories were examined, and 1,229,601 vulnerabilities in 15,584 vulnerable dependency files were found.


Some of the findings include:


* Deserialization of Untrusted Data was the most prevalent vulnerability type with a whopping 130,831 occurrences in Java repositories, by making it 40 per cent of the total vulnerabilities identified.
* Prototype Pollution being the most common vulnerability identified (62%) in JavaScript, repositories contained 5,49,566 vulnerabilities in total.
* 16,590 vulnerabilities were High or Critical among the 72,082 vulnerabilities found in the Python repositories' 2,602 dependency files.
* Last but not least, In Ruby repositories, 50% of the vulnerabilities are in the Critical or High categories.
* The top ten researchers who reported the most vulnerabilities are also highlighted in the study.


[Download the report today](https://go.snyk.io/scanning-the-top-1000-orgs-on-github.html) to learn more about the approach, methodology, and results of this exciting study with RedHunt Labs.
6 more Rules that will help you write secure, scalable and adaptable programs
Tags: beginners, programming, devjournal, systems
Published: 2023-06-23 01:31:00

“Programming isn’t about what you know; it’s about what you can figure out.”- Chris Pine

6 more Rules that will help you write secure, scalable and adaptable programs:


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


## 1. Avoid overcrowding your message bus:

Don't publish everything. Sample traffic to ensure alignment between cost and value. Eliminate low-value, high-cost traffic. Sample low-value/low-cost and high-value/high-cost traffic to reduce the cost.


## 2. Be wary of scaling through third parties:

Do not rely on vendor products, services, or features to scale your system. Keep your architecture simple and keep your costs in control. It can be violated by using a vendor’s proprietary scaling solution.


## 3. Purge, archive, and cost-justify storage:

Apply recency, frequency, and monetization analysis to determine the value of the data. Match storage costs to data value. It is important to understand and calculate the value of your data and to match storage costs to that value.



## 4. Remove business intelligence from transaction processing:

Separate business systems from product systems and product intelligence from database systems. Remove stored procedures from the database and put them in your application logic.



## 5. Design your application to be monitored:

Think about how you will need to monitor your application as you are designing it. Build hooks into your system to record transaction times. Adopt as an architectural principle that your application must be monitored.


## 6. Be competent:

Be competent, or buy competency in/for each component of your architecture. Identify the team responsible and the level of competency with that component. You can also buy solutions and be competent in their deployment and maintenance.


The earlier 40 rules: [Link](https://dev.to/pragyanatvade/10-more-rules-that-will-help-you-write-secure-scalable-and-adaptable-programs-5f1d)



Thanks for reading this.

If you have an idea and want to build your product around it, schedule a call with [me](https://calendly.com/pragyanatvade).

If you want to learn more about DevOps and Backend space, [follow me](https://dev.to/pragyanatvade).

If you want to connect, reach out to me on [Twitter](https://twitter.com/pragyanatvade) and [LinkedIn](https://www.linkedin.com/in/pragyanatvade/).
C++, print floating-point number with precision, customise format
Tags: cpp, precision, scientific, hex
Published: 2023-06-23 01:19:52

When we need to print a number with a specific format, such as printing it as a hexadecimal value or filling it with certain characters in front of it or some formatting options similar to the data format used in GLONASS (Global Navigation Satellite System) NAV DATA etc.
Ex we have some numbers

```cpp
double a = 100.345;
double b = 2006.008;
double c = 2331.41592653498;
```
and we can show it look like :

```cpp
0x64
_______+2006.01
2.331415927E+03
```
by using functions: setfill, setw, showbase, setprecision...from `<iomanip>`

```cpp
cout <<left<<hex<<showbase << nouppercase << (long long)a << endl;
cout <<right<<setfill('_')<<fixed<<setw(15)<<setprecision(2)<<showpos << b << endl;
cout<<left<<scientific<<uppercase<<setprecision(9)<<noshowpos<<c << endl;
```
Level Down to Level Up
Tags: career, learning
Published: 2023-06-23 00:04:00

##### Learning new topics and skills will help you level up your career.

---

## Do it for the culture!

I'm a huge fan of [swyx](https://twitter.com/swyx) and what his revolutionary [#LearnInPublic](https://twitter.com/swyx/status/1385349103106760705) mantra has done in making it acceptable to learn new things in the public space. As he so eloquently puts it:

> Try your best to be right, but don't worry when you're wrong.

I take the above to mean "it's ok to mess up...learn from it". _**Doing it for the culture**_ is learning and returning the knowledge gained to the extended creative community.

## Just like in Vegas 🎲 🎰

You will be wrong (betting) more times than you will be right (winning) in Las Vegas casinos. Unlike Vegas odds, when it comes to learning the "wrongs" in public helps you synthesize your knowledge.

## Learning => Knowing => Teaching

When you learn something new, try to use or apply it to your career or in life. After gaining a better understanding, teach what you have learned to someone else. You will be **_giving back_** while also **_gaining_**.



---

Photo by <a href="https://unsplash.com/es/@charlesetoroma?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Charles Etoroma</a> on <a href="https://unsplash.com/photos/TcvCFHfGlqo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>