teleren/devto huggingface dataset:
Learning TypeScript and NestJS
Tags: typescript
Published: 2024-01-19 20:06:07

In upcoming days I will shift my focus to learning NestJS and TypeScript for various reasons.
- Javascript is a very popular language used by many small, big and huge companies (everywhere).
- Has a huge community and a lot of resources.
- Can be used for many things (Frontend, Backend, Mobile, Desktop, etc).
- In performance wise, its very fast and efficient language (very good for high traffic applications, example: Twitter/X).
- Its a must have skill/tool for any developer that wants to find a work in the tech industry.

So, I have enrolled in a course on Udemy to learn TypeScript and NestJS. I am on the first section of the course and here what I have learned so far:

Why does TypeScript exist? <br><br>
- Typescript is basically a superset of Javascript. It adds types to Javascript. It's like a layer on top of Javsacript. Typescript = Javascript + Type System.
- Helps you catch errors before you run your code.
- Helps you write better/Maintainable code.
- Doesnt run in the browser or nodejs. It needs to be compiled to Javascript first.
- It doesnt provide any performance benefits.
- Its like a friend sitting next to you and telling you "Hey, you made a mistake here, you should fix it before you run your code".

What is a type? <br><br>
A type is something that describes the different properties and functions that a value has. Lets take exmple of a string:
```javascript
let color = 'red';
```
The type of `color` is `string`. It has properties like `length` and functions like `toUpperCase()`. <br><br>
Another example: 
```javascript
let count = 5;
```
The type of `count` is `number`. It has properties like `toFixed()` and functions like `toString()`. <br><br>

And there are 2 categories of types:
- Primitive Types: (number, string, boolean, symbol, void, undefined, null)
- They directly store/hold the value.
- If you have variable a storing number 5, its like saying you have a number 5 in your hand.
- Object Types: (functions, arrays, classes, objects).
- They store a reference to the value.
- They don't hold the actual data, but point to where the data is stored.
- If you have a variable a storing an an object called Person, its like saying you have a piece of paper in your hand that has the address where the details about that Person are stored, not the Person itself.

**Resources:**
- [NestJS: The Complete Developer's Guide](https://www.udemy.com/course/nestjs-the-complete-developers-guide/)
2024 Goals (ML, 1024km run, Writing)
Tags: devresolutions2024
Published: 2024-01-19 19:25:58

It's that time of the year when everyone is fired up to set bodacious goals. Now the DEV team has invited us to an accountability party with #devresolutions2024, and I hope we all deliver because it's going to be one hell of a ride once we accept the invitation. This kind of post will come to hunt you at the end of the year if you screw up or it could give you the best feeling in the world - fulfilment. 

_Here are my_

## Professional Goals:

1. **Python Certification**
I know Python pretty well, but I feel it would be great to also get a certificate as proof of concept. LinkedIn likes certification, so let's give it more this year ;)
Resource: [HackerRank](https://www.hackerrank.com/skills-verification/python_basic) and [freeCodeCamp](https://www.freecodecamp.org/learn/scientific-computing-with-python/).

2. **Django Project**
Aside being a Pythonista, I am a Djangonaut. And this year I will commit to developing a production-ready application with Django.

3. **Machine Learning Course**
Given that ML is currently the hottest space, how about we go get some! Okay, not just that; there are other better reasons and I've got plans ;)
Resource: [Fast.ai](https://course.fast.ai/) and [HuggingFace](https://huggingface.co/learn)


## Personal Aspirations:
1. **Conversational Spanish**
As an English speaker and a lazy student, I chose to learn Spanish because I think it is the easiest language for English speakers to learn.
Resource: [Duolingo](https://www.duolingo.com/)

2. **Run 1,024 km**
Ever heard of David Goggins? That's the man that made me run a marathon twice and several half-marathons last year. This year I will run at least a total distance of 1024km.
Resource: [MapMyFitness](https://www.mapmyfitness.com/challenges/)


3. **Chess 1500 Elo Rating**
Let's try to convince whoever will buy the idea that we are smart because we are good at chess. Okay, I just love the game and I want to get better at it. That's it.
Resource: [Chess.com](https://www.chess.com)



## DEV Community Contributions:

1. **Weekly Post** 
I am wondering why I have not been committed to posting on DEV. Most times I feel everything that I want to talk about has already been said, so why bother writing? However, I have found a good reason to write. Here it is: "Do it for you!". The point here is to focus on understanding a concept by writing about it or simply just telling your story as a developer. Hopefully, someone will find it useful but even if it gets zero views and zero likes, you keep writing for you.
> _If you can think, and speak, and write, you are absolutely deadly. **Writing is thinking formalized.** You gain the ability to think by first learning to write very, very carefully._
> — Dr Jordan B. Peterson

2. **Contribute and Collaborate** 
I will contribute to the community by sharing my story, moderating regularly, and collaborating with others to make [dev.to](https://dev.to/) great again.



_So help me God._
Web scraping with cheerio
Tags: scraping, cheerio, node, javascript
Published: 2024-01-19 19:11:30

---
title: Web scraping with cheerio
published: true
tags: ['scraping', 'cheerio', 'node', 'javascript']
canonical_url: https://sevic.dev/notes/scraping-cheerio/
---

Web scraping means extracting data from websites. This post covers extracting data from the page's HTML tags.

### Prerequisites

- `cheerio` package is installed

- HTML page is retrieved via an HTTP client

### Usage

- create a scraper object with `load` method by passing HTML content as an argument
  - set `decodeEntities` option to false to preserve encoded characters (like &amp;) in their original form
  ```js
  const $ = load('<div><!-- HTML content --></div>', { decodeEntities: false });
  ```
- find DOM elements by using CSS-like selectors
  ```js
  const items = $('.item');
  ```
- iterate through found elements using `each` method
  ```js
  items.each((index, element) => {
    // ...
  });
  ```
  access element content using specific methods
  - text `$(element).text()`
  - HTML `$(element).html()`
  - attributes
    - all `$(element).attr()`
    - specific one `$(element).attr('href')`
  - child elements
    - first `$(element).first()`
    - last `$(element).last()`
    - all `$(element).children()`
    - specific one `$(element).find('a')`
  - siblings
    - previous `$(element).prev()`
    - next `$(element).next()`

### Disclaimer

Please check the website's terms of service before scraping it. Some websites may have terms of service that prohibit such activity.

### Related reading

- [Web scraping with jsdom](https://sevic.dev/notes/scraping-jsdom/)

### Demo

The demo with the mentioned examples is available [here](https://sevic.dev/demos).
key knowledge areas essential for designing algorithms
Published: 2024-01-19 19:08:39

 **Here's a breakdown of the key knowledge areas essential for designing algorithms:**

**1. Programming Fundamentals:**

- **Solid understanding of a programming language:** This allows you to articulate your algorithm as a set of instructions for the computer to execute.
- **Control flow statements:** Mastering `if`, `else`, `for`, `while`, and other control structures empowers you to create decision-making and repetition within your algorithm.
- **Data types:** Understanding how different data types (numbers, strings, arrays, etc.) are stored and manipulated is crucial for designing algorithms that handle data effectively.

**2. Data Structures:**

- **Knowledge of common data structures:** Arrays, lists, stacks, queues, trees, and graphs are fundamental building blocks for organizing and managing data within algorithms.
- **Choosing appropriate data structures:** The right data structure can significantly impact an algorithm's efficiency and memory usage.

**3. Problem-Solving Skills:**

- **Problem decomposition:** Breaking down complex problems into smaller, more manageable subproblems is a core skill in algorithm design.
- **Pattern recognition:** Identifying common problem patterns and applying known algorithms or techniques to solve them efficiently.
- **Abstract thinking:** Focusing on the essential elements of a problem and ignoring irrelevant details aids in conceptualizing solutions.

**4. Algorithm Analysis:**

- **Time and space complexity:** Understanding how long an algorithm takes to run and how much memory it uses is crucial for evaluating its performance and making informed design choices.
- **Big O notation:** This standard way of expressing complexity allows you to compare the efficiency of different algorithms.

**5. Mathematical Foundations (Optional but Beneficial):**

- **Discrete mathematics:** Topics like logic, sets, relations, functions, and combinatorics provide a solid basis for understanding algorithms.
- **Number theory:** Concepts such as modular arithmetic, prime numbers, and factorization can be useful in certain algorithms.
- **Graph theory:** Representing relationships between entities as graphs finds applications in various algorithm design problems.

**6. Practice and Experience:**

- **Implementing algorithms:** Write code to solidify your understanding and experiment with different approaches.
- **Solving algorithm problems:** Practice on online platforms or in textbooks to develop problem-solving skills and design techniques.
- **Reading code:** Explore well-written algorithms to learn from others' approaches and techniques.

**7. Persistence and Creativity:**

- **Algorithm design often involves trial and error:** Don't be discouraged by initial challenges; persevere and explore different solutions.
- **Think outside the box:** Creativity and ingenuity can lead to innovative and efficient algorithms.
Mastering Neo4j: Graph Database Awesomeness Unleashed!
Tags: neo4j, k8s, kubernetes
Published: 2024-01-19 18:54:54

Dive into the world of Neo4j, where nodes, edges, and attributes come together in a symphony of data excellence. 🎓✨

## Deploying Neo4j with Helm

Unlock the power of graph-data-science with a breeze! Follow these steps:

1. **Prepare Your Helm Chart:**
	
-  Create a values.yaml file with essential configurations.

```
neo4j:
  name: licenses
  acceptLicenseAgreement: "yes"
  edition: enterprise
  resources:
    cpu: "1000m"
    memory: "2Gi"
volumes:
  data:
    mode: defaultStorageClass
env:
  NEO4J_PLUGINS: '["graph-data-science"]'
config:
  dbms.security.procedures.unrestricted: "gds.*"
```

	- Example Helm Chart available [here](https://github.com/neo4j/helm-charts)
	
2. **Deploy with Helm:**

- Execute a single command for deployment.

```
helm repo add neo4j https://helm.neo4j.com/neo4j
helm repo update
helm upgrade --install neo4j-cluster neo4j/neo4j --namespace neo4j --values values.yaml --version v5.15.0
```

3. **Verification:**
  - Confirm your installation with ``kubectl get pod``.

```
~ kubectl get pod 
NAME              READY   STATUS    RESTARTS      AGE
neo4j-cluster-0   1/1     Running   0                           124m
```
4. **Graph-Data-Science Check:**

- Verify graph-data-science with a Neo4j console query.

```
RETURN gds.version();
```

![gds.version command line](https://a.dailytask.co/images/tasks/nzaGQrYb4tWzHnOIzFNnkTHgU9jlToJDEi2m6tOy.png)

## Importing Data to Neo4j Cluster

Simplify the database import process effortlessly:

1. Upload Dump File:

   - Move your dump file to the pod.

```
kubectl cp Downloads/neo4j.dump neo4j/neo4j-cluster-0:/import/neo4j.dump 
```

2. **Run Import Command:**
   
   - Execute the import command line.

```
kubectl exec neo4j-cluster-0 -- neo4j-admin database load --from-path=/import neo4j --overwrite-destination=true --verbose
```

⚠️ Issue Resolution:

- Encounter locking issues? Delete the lock file.

> Caused by: org.neo4j.io.locker.FileLockException: Lock file has been locked by another process: /data/databases/neo4j/database lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
```
kubectl exec neo4j-cluster-0 -- rm -rf /data/databases/neo4j/database_lock 
```

3. **Restart Neo4j:**
      
- Ensure data loading completion.

```
kubectl exec neo4j-cluster-0 -- neo4j restart
```
Ready to unravel the magic of graph databases? 🌐✨ Connect with me on:

-  [Linkedin](https://www.linkedin.com/in/a7medzidan/) 
-  [Twitter](https://twitter.com/27medzidann)
Day 19: Unleashing Recursion Magic in Rust: Finding Factorial! 🚀
Tags: rust, 100daysofcode, programming, learning
Published: 2024-01-19 18:47:46

Today on Day 19 of #100DaysOfCode, I embarked on the adventurous journey of solving the classic factorial problem using recursion in Rust. While I've tackled this challenge in other languages, I was eager to witness Rust's unique twist on this recursive saga.

---

## The Rusty Recursion Spell ✨

I crafted a nifty function that takes a number as input and gracefully returns its factorial. Rust's syntax dances elegantly with recursion, making the code concise and expressive.

```rust
fn factorial(&num: &u128) -> u128 {
    if num == 1 {
        return 1;
    }

    num * factorial(&(num - 1))
}
```

The Rust code begins by defining a `factorial` function that takes a reference to a `u128` integer and recursively calculates its factorial. The base case checks if the input is 1, returning 1.

---

## User Interaction with Rust Charm ✨🤖

To sprinkle some user interaction magic, I decided to accept input from the command line. A loop diligently requests the user for input until a valid number graces the input stream. Parsing the input, I summoned the factorial function and presented the result in a grand finale.

```rust
fn main() {
    let mut user_input = String::new();
    let num: u128;

    println!("Enter a number: ");
    loop {
        io::stdin()
            .read_line(&mut user_input)
            .expect("Failed to read input, please try again");

        num = match user_input.trim().parse() {
            Ok(num) => num,
            _ => {
                println!("Please enter a valid number!!");
                continue;
            }
        };
        break;
    }

    let result = factorial(&num);
    println!("Factorial of {} is {}", num, result);
}
```

In the `main` function, user input is acquired in a loop, ensuring validity, and then passed to the `factorial` function. The result is printed, showcasing Rust's robust error handling and efficient memory management. The code exemplifies Rust's conciseness, clarity, and adherence to ownership principles, fostering a deeper understanding of recursion and user input handling in the language.

---

## Enchanting Learnings Along the Way 📚

- **Recursion Reigns Supreme:** Recursive solutions unveil the true power of programming, and Rust elegantly embraces this paradigm.

- **Rust's Mastery Unveiling:** Learning Rust goes beyond syntax; it's about adapting to Rust's mindset. Designing functions with a focus on references highlights the language's memory efficiency prowess.

The Rusty spellbook continues to unfold its pages, and I'm savoring every enchanting chapter. Stay tuned for more Rusty adventures! 🦀✨ 
#RustLang #RecursionMagic #CodeNewbie #LearningRust #ProgrammingJourney
Day 4 of #100DaysOfCloud: Navigating Azure's Identity Landscape – Azure Active Directory and RBAC
Tags: 100daysofcloud, azure, adcstreak, cloud
Published: 2024-01-19 18:44:00

As we journey through the #100DaysOfCloud, today was all about Azure Active Directory (AAD) and Role-Based Access Control (RBAC). Let's break down the Azure identity landscape and its unique twists! 💡✨

⚙️ Azure AD vs. On-Premise AD: Azure AD might sound familiar, but it's not the same as the on-premise Active Directory. Azure AD is the cloud-based identity and access management service, while the on-premise counterpart has its hierarchical structure. Yet, they can communicate, as seen in Hybrid Office 365 deployments.

🔄 Azure AD and On-Premise Integration: In real-world scenarios like Hybrid Office 365 deployments, Azure AD and on-premise Active Directory can seamlessly sync, bridging the cloud and on-premise worlds. Azure AD Connect plays a crucial role in synchronizing on-premise users for services like Exchange Online, SharePoint, and Teams.

🎭 RBAC: Balancing Autonomy and Governance: RBAC introduces a paradigm shift by allowing precise role assignments, striking the delicate balance between autonomy and corporate governance. For instance, granting specific users roles like managing virtual machines or virtual networks, or even entire resource groups, ensures efficient resource management.

🔍 Use Case: Navigating Complex Scenarios: Let's dive into a use case — running a Virtual Machine with specific regional requirements. RBAC empowers us to assign responsibilities effectively: one user managing virtual machines, another handling virtual networks, and a specialized database administrator group overseeing SQL databases within a specific resource group. This capability ensures a streamlined and secure cloud operation.

🔐 How RBAC Works: RBAC operates through Role Assignments, defining "who," "what," and "where." This involves Security Principals (users, groups, or applications), Role Definitions (collections of permissions), and Scope (applying access at various levels like management group, subscription, resource group, or resource).

🛠️ Built-In Roles and Customization: Azure provides fundamental built-in roles like Owner, Contributor, Reader, and User Access Administrator. However, for specific organizational needs, custom roles can be crafted. This flexibility ensures that roles align precisely with the organization's requirements.

Thanks @azdevindia  and @beingwizard  for the enlightening session and resources.
Hire Crypto Recovery Expert To Recover Lost Crypto Assets
Published: 2024-01-19 18:07:43

Cryptocurrencies have become increasingly popular in recent years, offering a decentralized and secure method for conducting financial transactions. However, the digital nature of cryptocurrencies also presents challenges, particularly when it comes to the recovery of lost funds.
Losing money, especially online, can be a devastating experience. Scams, technological hiccups, and human error can easily lead to disappearing funds, leaving victims feeling helpless and vulnerable. In this digital age, companies like DANIEL MEULI Web Recovery have emerged, promising to act as digital detectives, tracking down and recovering lost funds. But before entrusting them with your financial woes, it's crucial to approach their claims with a cautious eye.  When it comes to losing crypto, there are various scenarios that can leave you scratching your head. Whether it's forgetting your private key, falling victim to a scam, or losing access to your wallet, the possibilities are endless. Each type of loss presents its own set of challenges, making the road to recovery an arduous one. Finding missing cryptocurrency is more involved than just rummaging through couch cushions for extra pennies. The recovery procedure is made more difficult by the decentralized and pseudonymous nature of cryptocurrency. It can be likened to trying to find your way around a maze without any guidance or assistance if you don't have the necessary resources. Fortunately,  DANIEL MEULI Web Recovery is here to help make the journey a little less intimidating. To go deeply into the digital world and locate your lost cash,  DANIEL MEULI Web Recovery uses revolutionary blockchain research techniques. In order to find the hidden routes your cryptocurrency took and return it to your virtual vault, their team of knowledgeable wizards employs advanced algorithms and strategies. When it comes to dealing with something as valuable as your cryptocurrency, security and confidentiality are of utmost importance.  DANIEL MEULI Web Recovery understands this better than anyone. They ensure that your personal and financial information remains safeguarded throughout the recovery process, so you can rest easy knowing that your secrets are safe with them. Please contact  DANIEL MEULI web recovery on:



EMAIL: Danielmeuliweberecovery (@) email com
TELEGRAM:  (@) DANIELMEULI
Hoisting in JavaScript: Most Asked Topic in JOb Interviews
Published: 2024-01-19 18:07:36


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



no trash talking let's get straight in

look at this example:

see function is called before it is declared,
but JavaScript automatically puts the declaration  at the top of the script this is called hoisting it is simple:


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



remember that only declaration will be hoisted not the initialization.

var myVariable will be hoisted and it contains the value undefined after assignment it contains the value 42
so here "var myVariable" is hoisted nut "= 42" is not.


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



here when we declare the function using var you can see that calling sayHello() before intialization throws an error because intialization is not hoisted "Var sayHello" existed but we did'nt assigned a function to it as initialization is not hoisted so it throws an error.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/te6szr7akqb9cshhf7px.png)
I analyzed the 14 best open-source products launched on Product Hunt in 2023. Here's what I found.
Tags: startup, developer, marketing, opensource
Published: 2024-01-19 17:55:20

Product Hunt just unveiled a list of 14 products nominated for the [Golden Kitty Award 2023](https://www.producthunt.com/@fmerian/collections/best-open-source-products-of-2023) in the “Open Source” category. 

I analyzed the following data to identify some trends:

- launch dates;
- `#` upvotes; 
- `#` comments;
- awards.

Here’s what I found.

## tl,dr

- 11 products (79%) launched on a weekday; 
- 11 products (79%) ranked #1 Product of the Day, with 977 upvotes on average.

## key takeaways

- 11 products (79%) launched on a weekday: 21% launched on Mon or Tue, 14% launched on Thu or Fri;
- 10 products (71%) launched for the first time;

On launch day, the best open-source products got on average:

- 977 upvotes, range:[439-2,229];
- 222 comments, range:[15-466].

As a result:

- 11 products (79%) ranked `#1` Product of the Day, 13 products (93%) reached the Top 5;
- 2 products (14%) ranked `#1` Product of the Week, 10 products (71%) reached the Top 5;
- 2 products (14%) reached the Top 5 Products of the Month.

## wrapping up

I hope you'll find these learnings helpful. For the record, you can find the dataset [here](https://github.com/fmerian/awesome-product-hunt/discussions/3). 

If you're planning to launch a dev tool on Product Hunt, find inspiration from more great dev-first product launches [there](https://github.com/fmerian/awesome-product-hunt).

Enjoy!