teleren/devto huggingface dataset:
Beginner's TypeScript #18
Published: 2024-01-06 15:00:00

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

⭐ **Typing Async Functions** ⭐

Let's go deeper into function types.

Here we have a **createThenGetUser** function:

```ts
const createThenGetUser = async (
  createUser: unknown,
  getUser: unknown,
): Promise<User> => {
  const userId: string = await createUser();

  const user = await getUser(userId);

  return user;
};
```

This function takes in an asynchronous **createUser** function. It returns a promise that includes a **userId** string.

The **userId** string is then used in a call to **getUser** which would be a database call or something similar.

Both **createUser** and **getUser** are currently typed as **unknown**.

We will figure out how to type the async functions.

🌟 **Solution: Specify the Type for an Async Function**

Here is the correct syntax for typing these functions:

```ts
const createThenGetUser = async (
  createUser: () => Promise<string>,
  getUser: (id: string) => Promise<User>,
): Promise<User> => {
  const userId: string = await createUser();

  const user = await getUser(userId);

  return user;
};
```

Same as before, these can be extracted into their own types as well:

```ts
type GetUser = (id: string) => Promise<User>;
```

What this is saying is that we have an **id** which is a **string**, and the function will return a Promise containing a **User**.

If we had **GetUser** only returning the **User** without the Promise, we wouldn't be able to call it as an async function.

Wrapping function return types with Promises is really useful when working with real-world processes like fetching from databases.

---

I hope you found it useful. Thanks for reading. 🙏

Let's get connected! You can find me on:
- **Medium:** https://medium.com/@nhannguyendevjs/
- **Dev**: https://dev.to/nhannguyendevjs/
- **Hashnode**: [https://nhannguyen.hashnode.dev](https://nhannguyen.hashnode.dev/)/
- **Linkedin:** https://www.linkedin.com/in/nhannguyendevjs/
- **X (formerly Twitter)**: https://twitter.com/nhannguyendevjs/
Git push , fetch , merge and pull understand in simple way
Published: 2024-01-06 14:46:58

**Here's a beginner-friendly comparison of Git commands `push`, `pull`, `fetch`, and `merge` in a tabular format along with their real-life developer situations:**

| Command  | Description                                       | Real-Life Developer Situations                                        |
|----------|---------------------------------------------------|------------------------------------------------------------------------|
| `git push <remote> <branch>`     | Sends local commits to a remote repository.       | - Sharing your changes with the team on GitHub/GitLab/Bitbucket.        |
| `git pull <remote> <branch>`     | Fetches changes from the remote and merges them   | - Updating your local repository with changes made by other team members.|
| `git fetch <remote>`             | Fetches changes from the remote but doesn't merge | - Checking what's new in the remote repository without merging it.      |
| `git merge <branch>`             | Merges changes from a different branch            | - Combining changes from a feature branch into the main development branch.|

Explanation:

- **`git push <remote> <branch>`:**
  - Sends your committed changes from the local repository to a remote repository (e.g., GitHub).
  - Real-Life Situation: Sharing your completed feature or bug fixes with your team by uploading changes to the central repository.

- **`git pull <remote> <branch>`:**
  - Fetches changes from a remote repository and merges them into the local branch.
  - Real-Life Situation: Updating your local codebase with the latest changes made by other team members on the shared repository.

- **`git fetch <remote>`:**
  - Retrieves the latest changes from the remote repository but does not merge them into the local branch immediately.
  - Real-Life Situation: Checking for updates in the central repository without merging them into your working branch immediately.

- **`git merge <branch>`:**
  - Integrates changes from a different branch into the current branch.
  - Real-Life Situation: Combining changes from a feature branch into the main development branch or integrating updates from a release branch.

These commands help developers collaborate, keep their local repositories up-to-date with the central repository, and manage code changes effectively by sharing, fetching, and merging code between local and remote repositories in a team setting.
Exploring the Diversity and Benefits of Marijuana Products in Today's Market
Published: 2024-01-06 14:35:15

**Introduction to Marijuana Products**

1. Historical Perspective: Marijuana has been used for centuries, tracing back to ancient civilizations for medicinal, spiritual, and recreational purposes.

**2. Evolution of Consumption: **Over time, various forms of consumption have emerged, from traditional smoking to innovative methods like edibles, tinctures, topicals, and concentrates.

**Types of Marijuana Products**

3**. Edibles: **These products include infused candies, baked goods, beverages, and more, providing a discreet and palatable option for consumption.

**4. Tinctures**: Liquid extracts infused with cannabinoids, offering precise dosing and versatility in usage.

**5. Topicals:** Balms, creams, and oils applied externally, offering localized relief for pain, inflammation, and skin conditions.

6. **Concentrates:** Highly potent extracts such as wax, shatter, and oils, appreciated for their potency and rapid onset of effects.

Benefits and Uses

**7. Medicinal Properties**: Marijuana products have shown promise in alleviating symptoms of chronic pain, anxiety, epilepsy, and nausea, among other conditions.

**8. Wellness and Relaxation**: Many users find marijuana products helpful in promoting relaxation, stress relief, and improved sleep quality.

9.** Creativity and Focus: **Some individuals report enhanced creativity and focus, attributing it to certain strains or product types.

**Legal Landscape and Regulation**

1**0. Shifting Legalities**: Marijuana laws and regulations vary worldwide, leading to a complex landscape where legality and accessibility differ from one place to another.

**11. Quality Assurance**: Ensuring product safety, potency, and accurate labeling remains a challenge in the industry due to varying regulations.

**Consumer Trends and Market Growth**

12. Diversification of Offerings: The market has expanded to offer a wide array of products catering to different preferences and needs, attracting a diverse consumer base.

13.** Rising Popularity: **Increased social acceptance and awareness of potential benefits have contributed to the growing popularity of marijuana products.

**Challenges and Future Prospects**

14. Stigma and Misconceptions: Despite advancements, stigma around marijuana products persists, hindering widespread acceptance and understanding.

15. R**esearch and Innovation:** Continued research and technological advancements are crucial for unlocking the full potential of marijuana products in medicine and wellness.

**Conclusion
**
**[Marijuana products ](https://www.moonflowerdelivery.com/)**continue to evolve, offering a diverse range of options for both medicinal and recreational purposes. As societal perceptions shift and research progresses, the potential for these products to positively impact health and well-being remains promising.
Responsive fonts in CSS
Tags: css, responsivedesign, webdev, clampfunction
Published: 2024-01-06 14:30:41

Let's explore a super useful and modern technique to make our fonts responsive, using the CSS clamp() function along with custom properties. Let's get started!

---

### Introduction to clamp()
The clamp() function in CSS is a powerful tool that allows us to set a font size (or any other property) within a specific range. This means we can have more precise control over how our content looks on different screen sizes.


&nbsp;

#### Step 1: Define Custom Properties
First, we define the custom properties in our style sheet:


```css
:root {
    --font-min: 16px; /* Minimum size */
    --font-max: 32px; /* Maximum size */
    --font-preferred: 2vw; /* Preferred size */
}
```

> These variables will allow us to easily adjust our font sizes throughout the project.

&nbsp;

#### Step 2: Apply clamp()
Now, we apply clamp() to our desired element:

```css
body {
    font-size: clamp(var(--font-min), var(--font-preferred), var(--font-max));
}
```

> With this code, the font size will automatically adjust within the defined range.

&nbsp;

#### Step 3: Adjustments and Customization
Feel free to adjust the values of `--font-min`, `--font-max`, y `--font-preferred` to suit your needs. This technique can be applied to any element, not just the font size of the document.

&nbsp;

#### Conclusion
And that's it! With a few simple steps, we have created fonts that perfectly adapt to different screen sizes, improving the readability and aesthetics of our websites.

---

Do you have questions or suggestions? Share what you think in the comments!
31 Open-Source Libraries to Skyrocket Your Programming Journey ⛰️
Published: 2024-01-06 14:25:05

In this blog post, we've compiled a curated list of 31 open-source libraries that can transform your programming journey and boost your portfolio. Whether you're a beginner looking to make a mark in the tech world or an experienced developer seeking to expand your horizons, these libraries offer a treasure trove of opportunities for learning, growth, and contributing to the open-source community.

1. Unveiling AI's Potential: 
Dive into a world of AI-powered libraries that bring the power of artificial intelligence to your fingertips. From in-app AI chatbots to AI-infused text areas, explore how these libraries can enhance user experience and revolutionize your applications.


2. Embracing the Cloud and Database Revolution: 
Unlock the potential of cloud-oriented programming languages and SQL-based cloud resource management tools. Learn how these libraries simplify cloud operations, provide infrastructure support, and help you build and deploy cloud apps efficiently.


3. Enhancing Developer Productivity with Utilities: 
Discover a collection of dev utilities that streamline your development workflow and make coding more enjoyable. From API collaboration tools to testing frameworks and documentation generators, these libraries empower you to work smarter, not harder.


4. Mastering Backend Development: 
Explore libraries that empower you to build robust and scalable backend systems. From context-specific user permissions to authentication and authorization frameworks, these tools provide the building blocks for secure and reliable applications.


5. Revolutionizing UI/UX Design: 
Transform your user interfaces with stunning UI components, animation libraries, and mobile swipe UI implementations. Bring your designs to life with ease and create user experiences that captivate and engage your audience.


6. Venturing into Miscellaneous Libraries: 
Uncover hidden gems and explore a diverse range of libraries that don't fit into specific categories. From AI data searchers to full-stack web app development frameworks, these libraries offer unique functionalities that can enrich your programming arsenal.


7. Cultivating a Growth Mindset: 
Embrace a growth mindset by actively participating in open-source projects, contributing to their development, and engaging with the vibrant community of developers who are passionate about building innovative solutions.
How To Grow As a Frontend Developer in 2024
Tags: webdev, frontend, javascript, programming
Published: 2024-01-06 14:17:56

As we step into 2024, the realm of frontend development continues its rapid evolution, demanding a proactive approach to growth and skill enhancement. With over three years of experience in the field, I've come to realize the paramount importance of continually expanding one's skill set and staying abreast of the latest advancements in the industry.


**1. Mastering Core Technologies**

Revisiting the core trio of HTML, CSS, and JavaScript remains a cornerstone of frontend development. As a seasoned frontend developer, honing these foundational skills is a perpetual process, ensuring a solid understanding of the building blocks upon which all frontend technologies are constructed.


**2. Exploring Advanced Frameworks and Libraries**

Delving into advanced frontend frameworks such as React, Vue.js, or Angular is pivotal in keeping pace with the ever-evolving ecosystem. As a frontend developer committed to growth, staying updated with the latest features and updates of these frameworks remains a priority.


**3. Version Control Systems and Collaboration Tools**

In the collaborative landscape of development, proficiency in version control systems like Git and collaborative platforms such as GitHub is indispensable. Understanding these tools' nuances and leveraging them for efficient teamwork has been instrumental in my growth as a frontend developer.


**4. Continuous Learning and Adaptability**

Embracing a growth mindset and continually adapting to emerging technologies and trends is a philosophy that has driven my career progression. The frontend domain's dynamic nature demands adaptability and a hunger for learning, traits I actively cultivate in my professional journey.


**5. Soft Skills and Professional Development**

Recognizing the significance of soft skills alongside technical prowess has been pivotal in my career growth. Effective communication, teamwork, and problem-solving are indispensable skills that complement technical expertise and contribute to overall professional development.


**6. Building Projects and Contributions**

Fostering personal projects, contributing to open-source initiatives, and nurturing a robust portfolio have been an ongoing endeavor. Showcasing skills through practical implementations and real-world contributions has been a testament to my dedication to growth and learning.

As I conclude this reflection on growth as a frontend developer in 2024, it's clear that the journey to mastery is an ongoing expedition rather than a destination. Embracing a growth-oriented mindset, staying passionate about learning, and continually adapting to the ever-changing landscape remain my guiding principles in this exciting field.
mdka: Rust crate to convert HTML to Markdown
Tags: rust, mdka, markdown, html
Published: 2024-01-06 14:16:08

I released Rust library to convert HTML to Markdown 💫📝 A kind of text manipulator named mdka (= MD 化/か).

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

https://crates.io/crates/mdka

This is my first open source crate published 🥲 Happy.
How to Understand and Use nil in Golang Correctly?
Published: 2024-01-06 14:05:16

---
title: How to Understand and Use nil in Golang Correctly?
published: true
date: 
tags: 
canonical_url: https://www.pixelstech.net/article/1704096526-How-to-Understand-and-Use-nil-in-Golang-Correctly
---

In Golang, nil is a predefined identifier that carries different meanings in various contexts, but typically represents "none", "empty" or "zero value". It can be assigned to variables of pointer, slice, map, channel, function, and interface types. Understanding the significance of nil is crucial for writing robust Go programs, as mishandling nil can lead to unexpected issues. nil in Pointers In G
Understanding Git Branches & Merge to main
Published: 2024-01-06 14:05:06




**Git branches are essential for organizing development tasks. To create a new branch, use the following command:
bash**


`git checkout -b feature/add-to-cart`

This creates a new branch named feature/add-to-cart and switches to it.
Creating and Working on Feature Branches:

After making changes, stage and commit them using:

`git add .`

git commit -m "Implemented add to cart functionality"
To push the branch and changes to the remote repository:

`git push origin feature/add-to-cart`

Create a Pull Request from feature/add-to-cart to main on your Git hosting service.
Review and Merging Workflow:

Reviewers will provide feedback and approvals through the Pull Request interface.
Once approved, merge the branch into main using the merge button on the Pull Request page.
Post-Merge Actions:

Update your local main branch to reflect the merged changes:

`git checkout main
git pull origin main`

Optionally, delete the feature branch both locally and remotely:

`git branch -d feature/add-to-cart
git push origin --delete feature/add-to-cart`

Best Practices and Considerations:

Always sync your local repository with remote changes before creating a new branch.
Ensure your branch is up-to-date with the main branch to avoid conflicts during merging.
What you learning about this weekend? 🧠
Tags: codenewbie, learning, beginners, discuss
Published: 2024-01-06 14:00:00

Heyo y'all!

What's everybody learning on this weekend?

Whether you're sharpening your [JS](https://dev.to/t/javascript) skills, making PRs to [your OSS repo of choice](https://github.com/forem/forem) 😉, sprucing up your portfolio, or [writing a new post](https://dev.to/new) here on DEV, we'd like to hear about it.

Hope ya all learn loads and enjoy your weekend.

![An anime cartoon character is writing on papers while sitting at a desk, but wind is blowing up from beneath them fiercely sending the pages flying in the sky and their hair blowing back. It makes it look like their studying super intensely.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3exu6xkrsvcgngx9xf5.gif)
Ibuprofeno.py💊| #15: Explica este código Python
Tags: python, programming, beginners, spanish
Published: 2024-01-06 13:57:48

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

```py
list = [1, 2, 3, 4]
list.append(10)
print(list)
```

- A. `[10]`
- B. `10`
- C. `[10, 1, 2, 3, 4]`
- D. `[1, 2, 3, 4, 10]`

---

Respuesta en el primer comentario.
Ibuprofeno.py💊| #14: Explica este código Python
Tags: python, programming, beginners, spanish
Published: 2024-01-06 13:56:06

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

```py
print("hola mundo como estas".split(" "))
```

- A. `['hola', 'mundo', 'como', 'estas']`
- B. `['hola mundo como estas']`
- C. `hola mundo como estas`
- D. `Ninguna de las anteriores`

---

Respuesta en el primer comentario.
Syncing Across Tabs: The JavaScript Magic You Didn't Know Existed!
Tags: javascript, webdev, tutorial
Published: 2024-01-06 13:44:09

I recently discovered a fascinating feature on the [SoundCloud](https://soundcloud.com/) website: the ability to seamlessly control audio playback across multiple tabs in the same browser. Intrigued by this, I delved into how it was implemented and stumbled upon a powerful tool - JavaScript's [Broadcast Channel API](https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API).

The Broadcast Channel API allows communication between browser tabs, making real-time updates and synchronization possible. It's supported by major browsers, making it a versatile solution for enhancing user experiences.

## Using the Broadcast Channel API

To implement this feature, create a `BroadcastChannel` object with a channel name, like so:

```ts
const broadCast = new BroadcastChannel('audio-player');
```

Now, you can send messages using postMessage:

```ts
broadCast.postMessage({
    type: 'audio-played',
});
```

To receive messages, subscribe to the onmessage event:

```ts
broadCast.onmessage = ({ data = {} }) => {
    console.log(data);
};
```

This simple yet powerful API enables real-time communication between browser tabs, opening up possibilities for dynamic and synchronized user interfaces.

I have created a sample demo to showcase this feature.

- [Source Code](https://github.com/bhumit070/browser_tabs_communication)
- [Live Demo](https://bhumit070.github.io/browser_tabs_communication/)

## Conclusion

The Broadcast Channel API offers a seamless solution for enhancing multi-tab support on your website. Explore this feature in your projects and unlock the potential for dynamic and synchronized user experiences.

## Follow me for more updates

- [Twitter](https://twitter.com/bhumit070)
- [Linkedin](https://www.linkedin.com/in/bhoomit-ganatra/)
Meow | HackTheBox Write-up
Tags: beginners, tutorial, security, cybersecurity
Published: 2024-01-06 13:43:25

#Introduction
This box introduces us to many basic concepts and tools used in ethical hacking. We explore using commands such as: ping, nmap, telnet, and more. For this box, to capture the flag we need to ultimately login to the telnet service running on the box in order to read the file containing the flag (flag.txt).

#Enumeration
To start off, we **ping** (also known as an ICMP (internet control message protocol) echo test) the target box (computer) in order to make sure it is actually alive:


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

Since we are receiving back packets from the target computer, we can confirm it is up and running.

Next, we are going to run an **nmap** (network map) to enumerate for running services and their respective ports on the target machine:


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

We can see that port 23 is open, running the service **telnet**. Telnet is an old text-based protocol that allows for remote computer access.

#Telnet
Using the **telnet** command, we can try to login to the target machine:


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

We are met with a login screen.

After trying various login usernames, we were granted access without a password using login name **root**.


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

Using the command **ls** (list) we can view what contents are in the current directory.


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

We see the **flag.txt** file, which is what we are looking for to complete the box. Using the **cat** (concatenate) command we can view the contents of the file.


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

As we can see, we have captured the flag for this box.


#Various Questions:
What does the acronym VM stand for?
**Virtual Machine**

What tool do we use to interact with the operating system in order to issue commands via the command line, such as the one to start our VPN connection? It's also known as a console or shell.
**terminal**

What service do we use to form our VPN connection into HTB labs?
**openvpn**

What tool do we use to test our connection to the target with an ICMP echo request?
**ping**

What is the name of the most common tool for finding open ports on a target?
**nmap**

What service do we identify on port 23/tcp during our scans?
**telnet**

What username is able to log into the target over telnet with a blank password?
**root**

Submit root flag
**Try it yourself :)**