teleren/devto huggingface dataset:
The Marvel of Gecko Adhesion How Geckos Stick to Walls
Tags: geckos, adhesion, setae, vanderwaalsforces
Published: 2024-06-29 02:12:44

# 🦎 The Marvel of Gecko Adhesion: How Geckos Stick to Walls 🦎

Geckos are among nature&#x27;s most fascinating creatures, known for their incredible ability to stick to walls and ceilings. This remarkable talent allows them to defy gravity and move effortlessly across various surfaces. But how do they do it? Let&#x27;s delve into the science behind gecko adhesion and uncover the secrets of their sticky feet.

# 🔬 The Science Behind Gecko Feet 🔬

The secret to a gecko&#x27;s adhesive prowess lies in the microscopic structures on their feet called setae. Each foot is covered in millions of these tiny, hair-like structures, which are key to their sticking power.

## 🦠 What Are Setae? 🦠

Setae are minute hair-like structures that branch out into even smaller structures called spatulae. These spatulae are so small that they interact with the surface at a molecular level, enabling the gecko to cling to it.

## ⚛️ The Role of Van der Waals Forces ⚛️

The sticking mechanism is primarily due to van der Waals forces, which are weak intermolecular forces that arise from the attraction between molecules. Here&#x27;s how it works:

1. **Contact with the Surface**: When a gecko&#x27;s foot touches a surface, the spatulae come into close contact with it, allowing the molecules of the spatulae and the surface to interact.

2. **Van der Waals Forces Activation**: These interactions generate van der Waals forces, which, though individually weak, collectively create a strong adhesive force due to the vast number of spatulae involved.

3. **Effortless Movement**: By adjusting the angle of their foot and the orientation of the setae, geckos can easily attach and detach their feet from surfaces, allowing them to move swiftly and efficiently.

# 🌍 Real-World Applications 🌍

The unique adhesive properties of gecko feet have inspired numerous scientific and engineering innovations. Researchers are developing synthetic adhesives that mimic the structure and function of gecko setae, which could lead to new advancements in robotics, medical devices, and everyday adhesive products.

# 🦎 Geckos: Nature&#x27;s Sticky Superheroes 🦎

Geckos are a testament to nature&#x27;s ingenuity. Their ability to stick to walls and ceilings is not just a quirky trait but a marvel of biological engineering. The next time you see a gecko defying gravity, you&#x27;ll know that their secret lies in the microscopic setae and the powerful van der Waals forces at work.

In a world full of wonders, geckos remind us that even the smallest creatures can possess extraordinary abilities. So, let&#x27;s celebrate these amazing animals and the science that helps us understand their remarkable skills.
BEM with native nesting V2 - Even more powerful 🔥
Tags: css, webdev, tutorial
Published: 2024-06-29 02:04:54

Recently, [WhatIsLove Dev](https://whatislove.dev/articles/bem-modifiers-in-pure-css-nesting/) wrote a fantastic article explaining how to write BEM modifiers in pure CSS, similar to Sass. In the example the technique consists in using attribute selectors and parent selectors to make the block + modifier relationship:

```css
.tag-list__tag {
  --background-color: var(--color-red-200);

  padding-block: 2px;
  padding-inline: 6px;
  background-color: hsl(var(--background-color) / 30%);

  &[class*='--html'] {
    --background-color: var(--color-green-100);
  }

  &[class*='--github'] {
    --background-color: var(--color-gray-100);
  }

  &[class*='--ts'] {
    --background-color: var(--color-blue-200);
  }
}

```

To apply a modifier, declare the base and modifier classes on the same element:


```html
<aside class="aside box">
  <span class="aside__border aside__border--top">
    <!-- omitido -->
  </span>
</aside>

```

I thought
> "It would be sick if I could just write the modified class, right? After all, the prefix of the modifier class is the base class (block)."


<br />

-----

<br />


## Suffix and Prefix

The idea is simple: the suffix refers to the base class, and the prefix to its modifiers. The attribute selector supports string start and end searching, so just nest the suffix inside the prefix.

Given a class `.card` with modifiers `.card--brand` and `.card--grey`:

```css
:where([class^="card"]) {
  &[class*="--grey"] {}
  &[class*="--brand"] {}
}
```

- **([class^="card"])** - Captures the element's prefix (block)
- **&[class="--grey"]** - Captures the element's suffix (element/modifier)

<figure> 
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0a01xs02s7xsgc1wb9d8.gif" alt="meme do xablau" />

  <figcaption>XABLAU</figcaption>
</figure>

## Downsides of the Technique

- Attribute selectors are costly in terms of performance because they perform a substring search through the element tree.
- In addition to class name collisions, there will be suffix collisions as well, doubling the need for careful naming.

Check out this CodePen to play around:

{% codepen https://codepen.io/camilo-micheletto/pen/qBGGVNy %}
Navigating the Seas How Do Sea Turtles Navigate Across the Ocean
Tags: seaturtles, navigation, marinebiology, animalbehavior
Published: 2024-06-29 02:02:29

# 🐢 Navigating the Seas: How Do Sea Turtles Navigate Across the Ocean? 🐢

Sea turtles are remarkable creatures known for their long migrations across vast oceans. These journeys often span thousands of miles, as sea turtles return to the very beaches where they were born to lay their eggs. But how do sea turtles navigate such incredible distances with such precision? Let&#x27;s explore the fascinating navigational abilities of sea turtles and the science behind their remarkable journeys.

# 🔬 The Science of Sea Turtle Navigation 🔬

Sea turtles use a combination of environmental cues and innate abilities to navigate across the ocean. One of the most important tools in their navigational arsenal is the Earth&#x27;s magnetic field.

## 🧠 How Sea Turtles Navigate 🧠

1. **Magnetoreception**: Sea turtles have specialized cells called magnetoreceptors in their brains, which allow them to detect the Earth&#x27;s magnetic field. This sense, known as magnetoreception, helps them determine their position and direction.
2. **Geomagnetic Imprinting**: During their first journey to the ocean as hatchlings, sea turtles imprint on the magnetic field of their natal beach. This &quot;geomagnetic imprinting&quot; helps them return to the same location years later to nest.
3. **Solar and Celestial Cues**: In addition to the magnetic field, sea turtles may use the position of the sun, stars, and other celestial cues to help guide their migrations.
4. **Ocean Currents and Chemical Cues**: Sea turtles also use ocean currents and chemical cues in the water to navigate and locate feeding grounds and nesting sites.

# 🌍 The Journeys of Sea Turtles 🌍

Sea turtles undertake some of the longest migrations in the animal kingdom. Their ability to navigate across the ocean ensures their survival and the continuation of their species.

### 🐢 Types of Sea Turtles:
- **Loggerhead Turtles**: Known for their long migrations from feeding grounds to nesting beaches.
- **Green Turtles**: Migrate between feeding areas and nesting sites, often traveling thousands of miles.
- **Leatherback Turtles**: The largest sea turtles, known for their extensive migrations across entire ocean basins.

### 🐢 Navigational Challenges:
- **Human Impacts**: Pollution, climate change, and coastal development can disrupt the magnetic fields and environmental cues sea turtles rely on for navigation.
- **Predation and Bycatch**: Sea turtles face threats from predators and accidental capture in fishing gear during their migrations.

# 🌟 The Marvel of Sea Turtle Navigation 🌟

Sea turtles are a testament to the incredible navigational abilities found in the natural world. Their long journeys and precise navigation highlight the remarkable adaptations that have evolved over millions of years.

Next time you see a sea turtle, take a moment to appreciate the incredible journey it has undertaken to get where it is. Let&#x27;s celebrate the wonders of sea turtle navigation and the fascinating science that explains their remarkable migrations.
The Amazing Regeneration of Starfish How Do Starfish Regenerate Lost Limbs
Tags: starfish, regeneration, biology, marinelife
Published: 2024-06-29 01:52:14

# 🌟 The Amazing Regeneration of Starfish: How Do Starfish Regenerate Lost Limbs? 🌟

Starfish, or sea stars, are known for their remarkable ability to regenerate lost limbs. This incredible process not only helps them recover from injury but also plays a role in their survival and adaptability. But how do starfish regenerate their limbs, and what are the cellular mechanisms behind this feat? Let&#x27;s explore the fascinating world of starfish regeneration.

# 🔬 The Science of Starfish Regeneration 🔬

Starfish can regenerate lost limbs through a process called autotomy, which involves the deliberate shedding of a limb. Following autotomy, starfish initiate a complex regenerative process that involves cellular proliferation and differentiation.

## 🧠 How Starfish Regenerate Limbs 🧠

1. **Autotomy**: When a starfish loses a limb due to injury or predation, it can shed the damaged limb through autotomy. This self-amputation helps prevent further injury and infection.
2. **Wound Healing**: The starfish quickly seals the wound at the site of limb loss to prevent infection and initiate the regeneration process.
3. **Neoblast Activation**: Specialized cells called neoblasts, which are similar to stem cells, become activated at the wound site. These cells have the ability to differentiate into various cell types needed for limb regeneration.
4. **Cellular Proliferation**: The neoblasts proliferate and migrate to the site of regeneration, forming a structure called a blastema. This mass of undifferentiated cells serves as the foundation for the new limb.
5. **Differentiation and Growth**: The cells in the blastema begin to differentiate into the specific tissues and structures of the limb, such as muscle, nerve, and skin cells. Over time, the new limb grows and takes on the same form and function as the original limb.

# 🌍 The Benefits of Regeneration 🌍

Regeneration is a vital adaptation for starfish, providing several benefits that enhance their survival and resilience.

### 🦀 Predation Defense:
- **Escape Mechanism**: By shedding a limb, starfish can escape from predators and survive attacks that would otherwise be fatal.

### 🧬 Genetic Advantage:
- **Survival and Reproduction**: Regeneration allows starfish to recover from injuries and maintain their ability to reproduce and contribute to the gene pool.

### 🦑 Environmental Adaptation:
- **Habitat Flexibility**: The ability to regenerate limbs enables starfish to thrive in various environments, from rocky shores to deep-sea habitats.

# 🌟 Nature&#x27;s Resilient Marvels 🌟

Starfish are a testament to the incredible regenerative capabilities found in nature. Their ability to regrow lost limbs showcases the remarkable adaptability and resilience of marine life.

Next time you encounter a starfish, take a moment to appreciate the intricate biological processes that allow these creatures to heal and regenerate. Let&#x27;s celebrate the wonders of starfish regeneration and the fascinating science that explains their incredible abilities.
BEM com nesting nativo V2 - ainda mais poderoso 🔥
Tags: css, webdev, braziliandevs, tutorial
Published: 2024-06-29 01:44:18

Recentemente o [WhatIsLove Dev](https://whatislove.dev/articles/bem-modifiers-in-pure-css-nesting/) escreveu um artigo muito massa explicando como escrever modificadores BEM de forma muito parecida com a que fazemos no Sass usando apenas CSS pur. Abaixo, [exemplo extraído do seu próprio site](https://whatislove.dev/articles/bem-modifiers-in-pure-css-nesting/#native-css-nesting-modifiers).

```css
.tag-list__tag {
  --background-color: var(--color-red-200);

  padding-block: 2px;
  padding-inline: 6px;
  background-color: hsl(var(--background-color) / 30%);

  &[class*='--html'] {
    --background-color: var(--color-green-100);
  }

  &[class*='--github'] {
    --background-color: var(--color-gray-100);
  }

  &[class*='--ts'] {
    --background-color: var(--color-blue-200);
  }
}

```

<br />

Pra aplicar o modificador basta declarar a classe base e a classe modificadora no mesmo elemento, típico:

```html
<aside class="aside box">
  <span class="aside__border aside__border--top">
    <!-- omitido -->
  </span>
</aside>

```

<br />

Ai eu pensei:
> Pô, massa, mas seria ainda mais legal se eu escrevesse só a classe modificada né? Afinal o **prefixo** da classe modifier é a classe base (block).

Pois bem.

<br />

-----

<br />


## Sufixo e prefixo

A ideia é simples: o sufixo vai se referir sempre à classe base, o prefixo aos seus modificadores. O _attribute selector_ dá suporte à busca no início e no fim da string, logo basta fazer nesting do sufixo dentro do prefixo.

Dado uma classe `.card` que possuí os modificadores `.card--brand` e `.card--grey`.

```css
:where([class^="card"]) {
  &[class*="--grey"] {}
  &[class*="--brand"] {}
}
```

- **:where([class^="card"])** - Captura o prefixo (block) do elemento
- **&[class*="--grey"]** - Captura o sufixo (element / modifier) do elemento

<figure> 
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0a01xs02s7xsgc1wb9d8.gif" alt="meme do xablau" />

  <figcaption>XABLAU</figcaption>
</figure>

## Pontos negativos da técnica

- O seletor de atributo é um seletor caro pra performance pois além de realizar a busca na árvore de elementos [ele ainda faz uma comparação de substring](https://blogs.windows.com/msedgedev/2023/01/17/the-truth-about-css-selector-performance/)
- Além da colisão de nomes de classe, teremos colisão de sufixos também, ou seja, o dobro de cuidado na nomenclatura.


Enfim, codepen pra vocês brincarem:

{% codepen https://codepen.io/camilo-micheletto/pen/qBGGVNy %}
Missing Number
Published: 2024-06-27 09:18:41

**with using sort method to solve**

```
const numbers = [1, 2, 3, 4, 5, 6, 8, 9, 10];
function findMissingNumber(arr) {
    arr.sort((a, b) => a - b);
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] !== i + 1) {
            return i + 1;
        }
    }
    return arr.length + 1;
}


const missingNumber = findMissingNumber(numbers);
console.log("The missing number is:", missingNumber);
```


**Without  using any built in method**
```
//third way to find missng number
const arr1 = [1, 2, 3, 5];
const N = arr1.length;
function getMissingNo(arr1, n) {
    // The range is [1, N]
    const N = n + 1;
    // Calculate the sum of the range
    const totalSum = (N * (N + 1)) / 2;

    // Sum of elements in the array
    let arraySum = 0;
    for (let i = 0; i < n; i++) {
        arraySum += arr1[i];
    }

    // The missing number
    return totalSum - arraySum;
}

// Driver code

console.log(getMissingNo(arr1, N));

```
**With using reduce method  to solve** 
```
const arr = [1, 2, 4, 5, 6];
//second way find missing job
function findMissingNumber(arr) {
  // Calculate the length of the array + 1 (since one number is missing)
  const n = arr.length + 1;
  
  // Calculate the expected sum of numbers from 1 to n
  const expectedSum = (n * (n + 1)) / 2;
  
  // Calculate the sum of numbers in the given array
  const actualSum = arr.reduce((acc, num) => acc + num, 0);
  
  // The difference between expectedSum and actualSum is the missing number
  const missingNumber = expectedSum - actualSum;
  
  console.log("The missing number is:", missingNumber);
  return missingNumber;
}

// Example usage

findMissingNumber(arr);  // Output will be: The missing number is: 3
```
**Find all missing first to last element between ** 
```
const arr1 = [1, 3, 5, 7];

// Find the minimum and maximum values in the array
const min = Math.min(...arr1);
const max = Math.max(...arr1);

// Initialize an array to hold the missing numbers
const missingNumbers = [];

// Loop through the range from min to max
for (let i = min; i <= max; i++) {
  // If the current number is not in the array, add it to the missing numbers
  if (!arr1.includes(i)) {
    missingNumbers.push(i);
  }
}

console.log(missingNumbers); 
```
Real-time chat communication for a messaging system with NodeJs and Socket.IO
Tags: webdev, node, backend, mongodb
Published: 2024-06-29 01:39:55

I'm going to be writing about a back-end problem I solved and give an overview of the step-by-step approach I took to solving that problem.

Quite recently while working on implementing a messaging system and I faced an issue of making it a real-time communication system. 

## The Challenge
The primary challenge was to create a messaging system that supports real-time communication between users. The requirements include having real-time updates meaning messages should appear instantly without the need for refreshing the page.

## Step-by-Step Solution
**Step 1: Choosing Appropriate Technologies**
To build the real-time chat functionality, I opted for the following technologies
**- NodeJs** with **Socket.IO** for the server-side real-time communication.
**- MongoDB** for persistent storage of the messages.

**Step 2: Setting-up the server**
I then set-up a server with NodeJs and socket.io

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

**Step 3: Implementing the logic to handle the real-time communication**
Created 4 different events for this namely;
**Connection event** which is triggered whenever a client connects to the server
**JoinRoon event** which will allow user to join specific chat rooms
**Chatmessage event** which will handle incoming chats
**disconnect event** which is triggered when the user disconnects from the server

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

**Step 4: Creating a persistent storage for the Messages**
To ensure messages are not lost and can be retrieved later, I used MongoDB for persistent storage.

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


Building this real-time chat application involved careful consideration of technologies and architecture and by leveraging NodeJs and Socket.io I was able to implement a messaging system that met my requirements.

I'm a backend developer that loves building good and efficient systems. Being a problem solver, I love to learn new things and ways of doing things. And recently got accepted into an internship of an organization known as HNG and I know this internship is an opportunity for me to grow my skills as a developer by working on real-world projects, learning and gathering knowledge from experts in the field.
So I really am super excited to be part of this internship which promises to be a wonderful journey. You can learn more about this internship here on [https://hng.tech/internship](url) or here [https://hng.tech/hire](url). 
I really look forward to being one of the few to complete this internship so Wish me luck in my endeavour.
LEARNING OF JAVASCRIPT
Published: 2024-06-27 09:03:39

Yesterday, we embarked on our journey with JavaScript and reviewed the topics we had previously studied. We refreshed our understanding of the basics and revisited key concepts. Following this, we delved into the distinction between primitive and non-primitive data types, gaining a comprehensive understanding of their characteristics. We also took the opportunity to compare and contrast Java and JavaScript, deepening our insights into both programming languages.
Today, our focus was on strings. We thoroughly explored various methods for manipulating strings, such as toLowerCase, toUpperCase, slice, replace, replaceAll, and many more. These methods allow us to transform and modify strings in different ways, enhancing our ability to work with textual data effectively.
Through this exploration, we discovered that JavaScript provides a robust set of tools with 7 core methods for string manipulation. Each method serves specific purposes and applications, empowering us to handle strings with precision and efficiency in our programming tasks.
So, Today, we will continue to build upon these concepts, further expanding our knowledge and practical skills in JavaScript.
Sleeping Underwater How Do Dolphins Sleep Without Drowning
Tags: dolphins, sleep, marinebiology, aquaticlife
Published: 2024-06-29 01:01:02

# 🐬 Sleeping Underwater: How Do Dolphins Sleep Without Drowning? 🐬

Dolphins are fascinating marine mammals known for their intelligence, playful behavior, and remarkable ability to sleep in the water without drowning. This unique ability has intrigued scientists and animal lovers alike. But how do dolphins manage to get the rest they need while living in an aquatic environment? Let&#x27;s dive into the world of dolphins and uncover the secrets of their sleeping habits.

# 🔬 The Science of Dolphin Sleep 🔬

Unlike humans, dolphins cannot enter a deep sleep where they become completely unconscious, as they need to come up for air regularly. To solve this problem, dolphins have developed a unique method of sleeping called unihemispheric slow-wave sleep (USWS).

## 🧠 How Dolphins Sleep 🧠

1. **Unihemispheric Slow-Wave Sleep (USWS)**: Dolphins shut down one hemisphere of their brain at a time while keeping the other hemisphere awake. This allows them to rest while still being partially conscious to surface for air and stay alert for predators.
2. **Alternating Hemispheres**: They alternate which hemisphere of the brain is asleep, ensuring both sides get the rest they need. This process allows dolphins to maintain necessary bodily functions and vigilance even while resting.

### 💤 Benefits of USWS:
- **Breathing**: By keeping one hemisphere awake, dolphins can consciously control their breathing and surface for air as needed.
- **Safety**: Staying partially awake helps dolphins remain alert to potential threats, such as predators or obstacles in their environment.
- **Social Interaction**: Dolphins are social animals, and this method of sleeping allows them to stay connected with their pod members, even while resting.

# 🌊 Dolphin Sleep Patterns 🌊

Dolphins typically sleep in short intervals throughout the day and night. This fragmented sleep pattern helps them stay active and responsive in their dynamic aquatic environment.

### 🌞 Daytime Naps:
- **Resting in Shallow Waters**: Dolphins often rest in shallow waters or near the surface, making it easier for them to breathe.
- **Pod Protection**: They may sleep while remaining close to their pod, providing mutual protection and maintaining social bonds.

### 🌜 Nighttime Rest:
- **Quiet Periods**: During the night, dolphins may have longer rest periods but still practice USWS to ensure they can surface for air and remain vigilant.

# 🌟 Adaptation to Aquatic Life 🌟

Dolphins have perfectly adapted to their aquatic lifestyle, developing unique sleeping habits that allow them to rest without the risk of drowning. Their ability to maintain consciousness while sleeping is a testament to their remarkable evolutionary adaptations.

Next time you see a dolphin gliding gracefully through the water, you&#x27;ll know that even these energetic animals need their rest. Let&#x27;s celebrate the incredible adaptability of dolphins and the fascinating science behind their sleeping patterns.