teleren/devto huggingface dataset:
The first step of Bun
Published: 2023-09-16 23:27:06

As you know, [Bun](https://bun.sh/) is the fastest JavaScript runtime and the substitute for Node.js.

Today, I want to introduce the first step of Bun.

### Install Bun globally
```sh
# Open your terminal
$ curl -fsSL https://bun.sh/install | bash
```

### Create a TypeScript file
```sh
# In your terminal
$ touch index.tsx
```
```tsx
// index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);
```

### Lounch a server with Bun
```sh
# In your terminal
$ bun run index.tsx
```

http://localhost:3000/

Welcome to Bun!!!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/of0spitb24i04zjgyjeu.png)
How to create Functions in MySQL
Tags: database, mysql, bigdata, programming
Published: 2023-09-16 21:51:44

in this post i'll give you the simple way to create function in MySQL :
click this link : [**How to create Functions in MySQL Step By Step**](https://thebestcoding.com/a-guide-to-creating-functions-in-mysql-step-by-step/)
visit our Website : [**The Best Coding**](https://thebestcoding.com/)
Top 5 Parallax Effects With CSS + Source Code
Tags: css, web3, webdev, programming
Published: 2023-09-16 21:33:35

Before diving into the examples, let's briefly understand what parallax scrolling is. Parallax scrolling is a web design technique where the background images move at a different speed than the foreground content, creating a captivating 3D effect. This technique can be achieved using HTML, CSS, and JavaScript.

<hr>

> Help us grow our community by sharing this post with your friends! ❤️

<hr>

## 1. Multi-layered Parallax Illustration
Another great parallax effect is developed by Patrick Westwood using HTML(Haml), CSS(SCSS), and JS(CoffeeScript).
[Demo / Source Code](https://codepen.io/patrickwestwood/pen/MyoBaY)

<hr>

## 2. Parallax Background
A No JavaScript Parallax background by Ravi Dhiman, developed using HTML(Pug) and CSS(SCSS).
[Demo / Source Code](https://codepen.io/ravid7000/pen/LREEzv)

<hr>

## 3. Coderado.co Denver Parallax Scrolling
A parallax effect page with a city skyline as the backdrop. Developed by Jeremy Hull using HTML and CSS(SCSS).
[Demo / Source Code](https://codepen.io/coderado/pen/BzGdxW)

<hr>

## 4. 3D CSS Parallax Depth Effect
CSS translate and rotate transforms based on mouse move to simulate some z-axis depth on the card and individual movie characters. Developed by Adrian Payne using HTML, CSS(SCSS), and JavaScript(Babel).
[Demo / Source Code](https://codepen.io/dazulu/pen/VVZrQv)

<hr>

## 5. CSS Parallax Orbs
A parallax effect inspired by Sims 4 made by Jamie Coulter using HTML(Haml) and CSS(SCSS).
[Demo / Source Code](https://codepen.io/jcoulterdesign/pen/OMOqjy)

<hr>

> If you found this helpful, give us a thumbs up and don't forget to follow us for more!
> Thanks for reading, See you next time... ❤️👋

<hr>

## Final Thoughts on The CSS Parallax Effect
The parallax effect has grown more popular as a way to improve user experiences. This design strategy boosts engagement and increases interactions.

Throughout this article, you have gotten to know CSS parallax in depth. You learned about code snippets that enable you to include **[parallax effect website](https://noobizdev.tech/how-to-create-parallax-effects-with-css-to-your-website-with-example/)**. Plus, you got to explore examples of web pages that employ parallax with skill, distinction, and creativity.

Remember to keep a balanced approach to parallax usage.
Troubleshooting parallel routing in Next.js
Tags: webdev, nextjs, frontend
Published: 2023-09-16 21:25:24

Parallel routing is great --- it allows you to render a slot based on certain conditions conditionally, either auth or data fetching status. 

If you haven't heard of or used parallel routing before, please check [this](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes)

But it can go wrong very quick, luckily fixes are quick too!

In a scenario you have a blank page comes with a layout, and you are trying to hydrate the page with three parallel route: `overview`, `projects`, and `dashboard` to show different things to your users. But it can break when you have a file structure like
```ts
|-[workspaceId]
|--create-project
|--settings
|--@overview
|--@projects
|--@dashboard
|--layout.tsx
```
#### Problem 1: it shows you a blank page

What you can do? 
In your `layout.tsx` file, you have already specified
```ts
export default function WorkspaceLayout(props: {
 
  create: React.ReactNode;
  projects: React.ReactNode;
  overview: React.ReactNode;
}) {
  return (
    <>
     <SomeLayout>
      {props.projects}
        {props.create}
      {props.overview}
    </SomeLayout>
    </>
  );
}
```
#### Solution 1: In this case, You will need an empty `page.tsx` like: 
```ts
export default function DashboardPage(props: {
  params: { workspaceId: string };
}) {
  return <></>;
}
```

with an empty fragment and add the implicit children your `layout.tsx` like so: 

```ts
 export default function WorkspaceLayout(props: {
  children: React.ReactNode;
  create: React.ReactNode;
  projects: React.ReactNode;
  overview: React.ReactNode;
}) {
  return (
    <>
    {props.children} // it really doesn't matter where this is placed because it's nothing in there, 
     <SomeLayout>
      {props.projects}
        {props.create}
      {props.overview}
    </SomeLayout>
    </>
  );
}
```
##### If the `page.tsx`, or `children` prop doesn't exist, nextjs can't initialise this segment. 

At this point your files will look like 
```ts
|-[workspaceId]
|--create-project
|--settings
|--@overview
|--@projects
|--@dashboard
|--layout.tsx
|--page.tx
```

#### Problem 2: when you navigate to /[someworkspaceId]/create-project, it shows you a 404 error, tell you page not found or internal server error. 

What the heck happened? I have a route there! 

#### Solution 2: Create a separate layout group
Instead of having a file structure like above, you could have one like this: 
```ts
|-[workspaceId]
|--create-project
|--settings
|--page.tsx
|--layout.tsx
|--(dashboard)
|---@overview
|---@projects
|---@dashboard
|---layout.tsx
|---page.tx
```
Move the old `layout.tsx` into `(dashboard)` folder but keep the `<SomeLayout/>` component in `[workspaceId]` folder, and there you have layouts inherited from a level above, and routes like `/[workspaceId]/create-project` will work again!

Do you have problems with parallel routing and intercepting routes? Found a solution or not? 

Would love to hear from comment section 👇🏻
The Translation Lookaside Buffer (TLB) - The Cache Behind the Scenes
Tags: cache, tlb, cpu, go
Published: 2023-09-16 19:51:06

The Translation Lookaside Buffer, known as TLB, is a special kind of cache inside the CPU. Its main job is to speed up the process of translating virtual memory addresses to their corresponding physical addresses.

Why the fuss about TLB? Well, every time a program wants to access memory, it's usually dealing with virtual addresses. For the computer to find the actual data, it needs to know the real, physical address. This translation can be a bottleneck, and that's where the TLB steps in. It remembers recent translations, making repeated lookups super fast. However, if the TLB can't find a translation, we get a "miss", and the system has to do a more time-consuming lookup in the page table.

Now, how does this relate to Go? The memory access patterns in your Go applications can influence the efficiency of the TLB. When data is accessed in a contiguous block, like in an array, it's more TLB-friendly. On the flip side, hopping around memory, as you might with linked-list structures, can lead to more TLB misses.

Let's visualize with a simple Go example. Imagine two ways of accessing data: one with a straight array and another with a linked-list type structure.

```go
// Accessing data in a contiguous block
data := []int{10, 20, 30}
for _, value := range data {
    // Process value
}

// Hopping around memory
type Node struct {
    Data int
    Next *Node
}

func processNode(n *Node) {
    for n != nil {
        // Process n.Data
        n = n.Next
    }
}
```

In essence, while Go abstracts away many hardware intricacies, having an understanding of things like the TLB can help you make more informed coding decisions. However, it's also essential to remember that real-world applications require a balance. Being TLB-aware is great, but it's one piece of the larger performance puzzle. As you develop in Go, keep the TLB in mind, but always consider the broader context of your application's needs.
Boilerplate para TypeScript
Tags: boilerplate, typescript, javascript, spanish
Published: 2023-09-16 19:37:43

Esta primera entrada la presento tanto como un recurso para mi yo el futuro y como una fuente de interés para aquellos que compartan mi pasión.

He creado un repositorio específico con el propósito de establecer una base sólida desde la cual iniciar proyectos utilizando TypeScript desde cero, orientados al desarrollo del lado del servidor (backend).

El repositorio en cuestión se encuentra alojado en la siguiente dirección:

https://github.com/ProfeJulianLasso/boilerplate-project-typescript

## ¿Qué ofrece este boilerplate?

El enfoque de este proyecto abarca cuatro aspectos fundamentales:

[**Pruebas unitarias con Jest**](https://jestjs.io/): Se ha incorporado la capacidad de realizar pruebas unitarias utilizando la potente herramienta Jest.

[**Análisis estático del código con ESLint**](https://eslint.org/): El código se somete a un riguroso análisis estático a través de ESLint para garantizar su calidad y cumplimiento de estándares.

[**Gestión de commits bajo Conventional Commits**](https://www.conventionalcommits.org/): Se adopta la metodología de Conventional Commits para mantener un registro de los cambios de manera clara y estructurada con la ayuda de [commitlint](https://commitlint.js.org/).

[**Formateo del código con Prettier**](https://prettier.io/): El código se formatea automáticamente con Prettier, asegurando coherencia en el estilo de escritura.

Además de estos aspectos, el repositorio hace uso de [**Husky**](https://typicode.github.io/husky/) para automatizar ciertas tareas al realizar commits y push al repositorio.

Invito a todos los interesados a colaborar en este proyecto y agradecería mucho cualquier comentario u observación que me puedan ofrecer.

Este es un recurso valioso tanto para aquellos que desean iniciar proyectos con TypeScript desde cero como para quienes buscan mejorar sus habilidades en el desarrollo del lado del servidor. Me enorgullece compartir esta contribución con la comunidad, bajo la esperanza de que resulte beneficioso para otros profesionales y entusiastas de la tecnología.
Toggling Mobile Navigation Visibility with CSS: 3 Ways
Tags: css, beginners, frontend, webdev
Published: 2023-09-16 19:32:35

As a frontend developer, I sometimes need to change the visibility of mobile navigation or other ui elements without using JavaScript. Although it may seem hard at first, you can easily do this with CSS. In this article, I'll show you three easy ways to do it

## 1. Checkbox Hack

The checkbox hack is an ingenious way to use the **:checked** pseudo-class to manipulate other elements.

HTML:

``` html
<label for="menuToggle" class="menu-toggle">Menu</label>
<input type="checkbox" id="menuToggle" class="menu-checkbox">
<nav class="mobile-nav">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>
```

CSS:

```CSS
.menu-toggle {
  cursor: pointer;
  background-color: #333;
  color: #fff;
  padding: .5rem 1rem;
}

.menu-checkbox {
  display: none;
}

.mobile-nav {
  display: none;
}

.menu-checkbox:checked ~ .mobile-nav {
  display: block;
}
```

[https://codepen.io/joxx/pen/QWzqbrE](https://codepen.io/joxx/pen/QWzqbrE)

## 2. Leveraging the :focus-within pseudo-class

Leveraging the **:focus-within** pseudo-class is another handy trick to toggle visibility.

HTML:

```HTML
<a href="#" class="menu-toggle">Menu</a>
<nav class="mobile-nav">
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>
```

CSS:

```CSS
.menu-toggle {
  background-color: #333;
  color: #fff;
  padding: .5rem 1rem;
  text-decoration: none;
}

.mobile-nav {
  display: none; 
}

.menu-toggle:focus-within + .mobile-nav {
  display: block; 
}
```

[https://codepen.io/joxx/pen/MWZEYrg](https://codepen.io/joxx/pen/MWZEYrg)

##3. Using the :target Pseudo-Class

This method revolves around the **:target** pseudo-class which gets triggered when an element with an ID matches the current URL's fragment.

```HTML
<div id="mobileNav">
  <a href="#mobileNav" class="menu-toggle menu-open">Menu</a>
  <a href="#" class="menu-toggle menu-close">Close</a>
  <nav class="mobile-nav">
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </nav>
</div>
```

CSS:

```CSS
.menu-toggle {
  background-color: #333;
  color: #fff;
  padding: .5rem 1rem;
  text-decoration: none;
}

#mobileNav:not(:target) .mobile-nav,
#mobileNav:not(:target) .menu-close {
  display: none;
}

#mobileNav:target .menu-open {
  display: none;
}
```

[https://codepen.io/joxx/pen/oNJeROV](https://codepen.io/joxx/pen/oNJeROV)

##Conclusion

You can easily change the visibility of mobile navigation using only CSS. This way, frontend developers can create interactive features that are usually made with JavaScript. But, be sure to check if it suits your project's needs and is accessible. In certain situations, using JavaScript might still be a better choice, especially for complicated tasks or to help users using assistive technologies.
Introducing FlipkartDealNotifier!
Tags: python, telegram, flipkart
Published: 2023-09-16 19:12:51

- Keep track of exciting deals and discounts on Flipkart with ease.

- This Python-based project alerts you via telegram bot whenever there's a price drop on your favourite products.

- Check out the project on GitHub and let us know what you think.

- Project Link: https://github.com/Alpha-1729/FlipkartDealNotifier

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1qzq47f0ei795a76hidx.png)
After enabling topLevelAwait in webpack and built in production mode what is the easiest way to import?
Tags: webpack
Published: 2023-09-16 19:09:01

After enabling topLevelAwait in webpack and built in production mode what is the easiest way to import?

For example, I currently have to use code like
```
import * as p from "xxx"

let module
p.then((f) => module = f)

module.xxx
```
in order to import. There has to be a better way of doing this
IHeaderDictionary does not contain a definition for Referrer and no accessible extension method Referrer accepting a first...
Tags: c, net, webapi
Published: 2024-02-04 09:24:52

---
title: IHeaderDictionary does not contain a definition for Referrer and no accessible extension method Referrer accepting a first...
published: true
date: 2023-09-16 18:30:00 UTC
tags: C,NET,WebAPI,C
canonical_url: http://www.codetolive.in//c%23/.net/web%20api/IHeaderDictionary-does-not-contain-a-definition-for-Referrer-in-dotnetcore/
---

## 1. Problem statement

‘IHeaderDictionary’ does not contain a definition for ‘Referrer’ and no accessible extension method ‘Referrer’ accepting a first argument of type ‘IHeaderDictionary’ could be found (are you missing a using directive or an assembly reference?

Referrer is missing in the ‘IHeaderDictionary’ when using the .NET Core or .NET projects.

## 2. Context

A request header is an HTTP header that can be used in the HTTP request to pass additional information. The header can be sent from the client, and the same can be read from the server to retrieve the information.

The way of reading the header has been changed in the .NET Core and .NET projects.

## 3. Solution

**_Existing code:_**

```
Request.Headers.Referrer.ToString()

```

**_Fix:_**

```
Request.Headers["Referrer"].ToString();

```

Thanks for reading the article on fixing the request header issue in an ASP.NET Core project. Please feel free to drop your comments below, and you can follow us on Twitter ([@Codetoliveblog](https://twitter.com/codetoliveblog)) to receive the latest updates from this blog.
Send Form Data With Ajax
Tags: javascript, webdev, jquery, ajax
Published: 2023-09-16 18:07:32

Hello For Everyone !

Steps:
1. Create an index.html file (HTML)
2. Create a app.js file (JavaScript)

// You Can Also Style Your Form If You Need That !

HTML Codes:
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>
       Send Form Data With Ajax 
       By (https://dev.to/yubaeloualidi)
    </title>
</head>
<body>
    <div id="message"></div>
    <form id="form">
        <input type="text" name="username" autocomplete="off" required="required" />
        <input type="password" name="password" autocomplete="new-password" required="required" />
        <button id="login" type="submit">Login</button>
    </form>
    
    <script src="app.js"></script>
</body>
</html>
```

JavaScript Codes:
```JS
const request = new XMLHttpRequest(),
    form = document.getElementById("form"),
    login = document.getElementById("login"),
    message = document.getElementById("message");

form.onsubmit = event => {
    event.preventDefault();
    const formData = new FormData(form);
    var body = "";

    for (const [key, value] of formData) {
        body += `${key}=${value}&`;
    }

    body = body.substring(0, body.length - 1);

    request.addEventListener('readystatechange', () => {
        if (request.readyState === 4 && request.status === 200) {
            console.log(JSON.parse(request.responseText));
        }
    })
    
    request.open('POST', 'read.php');
    // Warning: you need to change the request URL (read.php) with 
       your personal

    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
    request.send(body);
}

```

When You Click on The Button (login), You Can Check if The request is sended in (web developers tool -> network -> your file)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2bl3mp0mdurvz8u5us3.png)
Contributing to Focusly: A Rewarding Experience
Tags: webdev, opensource, javascript, beginners
Published: 2023-09-16 18:03:27

I'm thrilled to share my journey of contributing to the Focusly app! 🚀 My PR was recently accepted and merged, and it's been an incredible learning experience. I want to express my gratitude to the Focusly team for the opportunity.

The new features and improvements we've introduced will make the app even more amazing. If you're interested in the details of my contribution, feel free to check it out on the GitHub repository [here](https://github.com/Utkarshn10/Focusly/pull/108)

Thank you to the entire #Focusly community for their support and collaboration. Let's continue to innovate and create something exceptional! 💪 #OpenSource #CodingCommunity #TechJourney
Swiggy Problem
Published: 2023-09-16 17:44:39

##Task-1
df = spark.sparkContext.parallelize([])
df = spark.read.json(input_path,multiLine=True)
df = df.select('cust_name', 'id', 'name', 'city', 'avgrating', 'cuisines', 'costfortwos', 'deliverytime',
'mindeliverytime', 'maxdeliverytime', 'locality', 'date', 'amount')
df = df.na.drop(how="all")
df = df.na.fill('N/A')
df = df.withColumn("delivery_rating",when( col("deliverytime") <=40,4).otherwise(3))
df = df.withColumn("deliverymin",when((df.deliverytime <=19),lit(10)).
when((df.deliverytime >=20)&(df.deliverytime <=29),lit(20)).
when((df.deliverytime >=30)&(df.deliverytime <=39),lit(30)).
when((df.deliverytime >=40)&(df.deliverytime <=49),lit(40)).
when((df.deliverytime >=50)&(df.deliverytime <=59),lit(50)))
return df
##Task-2
df_10 = clean_df
df_10 = df_10.groupBy(["name"]).agg(count("name").alias("no_of_orders"))
df_10 = df_10.sort(desc("no_of_orders")).limit(10)
return df_10
##Task-3
df_avg = clean_df #Replace this line with your actual code
df_avg = df_avg.groupBy(["city"]).agg(avg("avgrating").alias("avg_rating"),
max("avgrating").alias("max_rating"),min("avgrating").alias("min_rating"))
df_avg = df_avg.filter(df_avg.avg_rating>3.5)
return df_avg
##Task-4
df_del = clean_df
df_del = df_del.groupBy(["deliverymin"]).agg(count("deliverymin").alias("delivertime_count"))
df_del = df_del.sort("delivertime_count")
return df_del
Udemy Problem
Published: 2023-09-16 17:41:24

##Task-1
df = spark.read.format("csv").option("header","true").load(input_path)
df = df.select("course_id", "price", "num_subscribers", "num_reviews", "level",
"content_duration", "published_timestamp", "subject")
df.withColumn("price",df.price.cast("int"))
df.withColumn("num_subscribers",df.num_subscribers.cast("int"))
df.withColumn("num_reviews",df.num_reviews.cast("int"))
df.withColumn("level",df.level.cast("string"))
df.withColumn("content_duration",df.content_duration.cast("float"))
df.withColumn("published_timestamp",df.published_timestamp.cast("timestamp"))
df.withColumn("subject",df.subject.cast("string"))
return df
##Task-2
price_df = spark.read.load(transformed_data_path)
price_df =
price_df.groupBy(col("level"),col("subject")).agg(sum("price").alias("Total_price")).select("level","
subject","Total_price")
price_df = price_df.sort(desc("Total_price"))
return price_df
##Task-3
sub_df = spark.read.load(transformed_data_path)
sub_df = sub_df.filter(sub_df.level == "Expert Level")
sub_df = sub_df.withColumn("sub_level",when((sub_df.num_subscribers>1000),lit("High")).
when((sub_df.num_subscribers>500)&(sub_df.num_subscribers<1000),lit("Medium")).
when((sub_df.num_subscribers <500),lit("Low")))
sub_df = sub_df.select("course_id","num_subscribers","level","sub_level")
return sub_df
##Task-4
years_df = spark.read.load(transformed_data_path)
years_df = years_df.select("course_id","price","level","published_timestamp")
years_df = years_df.filter(years_df.price > 100)
years_df.show(5)
years_df = years_df.filter((years_df.published_timestamp>=("2012-01-01T00:00:00Z")) &
(years_df.published_timestamp<("2015-01-01T00:00:00Z")))
years_df.show(5)
years_df = years_df.sort(desc("price"))
return years_df