teleren/devto huggingface dataset:
Creating a new blog with Texted
Tags: rust, texted, blog, tutorial
Published: 2024-04-28 19:14:36


### Overview

Creating a new self-hosted blog with texted is super simple. This is a tutorial explaining how to do it.

### Pre-requisites

Install Rust if you've now already done

[Rust - Getting started](https://www.rust-lang.org/learn/get-started)

### Installing Texted

```bash
cargo install texted
```

### Bootstrapping a new blog

```bash
# Let's create a new directory for our new blog
mkdir ~/my-awesome-blog && cd ~/my-awesome-blog
# And now create the skeleton of a fully functional blog
texted-tool bootstrap --out-dir .
```

Now, let's run and test it.

```bash
# Inside the same ~/my-awesome-blog directory, run
texted
```

And open in your browser http://127.0.0.1:8001/

### Adding a new post

Texted by default caches all urls and posts for best performance. Please quit texted and run again to see new posts in the listing.
If you want to disable rendering cache to see changes in the post content without restarting, change
`rendering_cache_enabled = false` in the texted.toml configuration file


```bash
# Still inside the same ~/my-awesome-blog directory, run
pushd posts/

# This will create one directory such as 20240428_how_to_write_a_new_blog_post
# with a file index.md inside.
texted-tool post --title "How to write a new blog post" -o dir

# And let's run texted again
popd
texted
```

You now have a new post available in the post list

---

This post was adapted from [Texted project](https://gitlab.com/thiagomg/texted)
Agile Methodology Task_4
Published: 2024-04-28 19:04:04

## **Describe the Differences in between:**

_**1) Smoke & Sanity testing**_

_**2) Validation & Verification**_

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

## **2.Explain about Agile Methodology?**

 _Agile methodology is a flexible and collaborative way of developing software. It breaks the project into small chunks called sprints, where teams work closely together to create usable parts of the product._

1. **_Iterative Approach:_** Work is broken into small, manageable parts called sprints.
2. **_Collaboration:_** Teams work closely together, including customers, to create and refine the product.
3. **_Flexibility:_** Plans can change based on feedback and evolving needs.
4. **_Continuous Improvement:_** Teams regularly review and adjust their processes for better results.
5. **_Empowerment:_** Teams are trusted to make decisions, leading to better-quality outcomes and faster delivery.

## **Explain about Epic and User Stories?**
_Epics are large, high-level requirements that are broken down into smaller, more detailed user stories. User stories are small, customer-centric descriptions of specific functionality that can be implemented within a single sprint._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4r9v9qqgcg24s0b18n92.png)
Glam Up My Markup Submission: Earth Day Celebration
Tags: devchallenge, frontendchallenge, css, javascript
Published: 2024-04-28 18:51:52

_This is a submission for [Frontend Challenge v24.04.17](https://dev.to/devteam/join-us-for-the-next-frontend-challenge-earth-day-edition-52e4), Glam Up My Markup: Earth Day Celebration Landing Page_

## What I Built
I created a landing page with a friendly style, adding illustrations and animations to the provided HTML. My goal was to create a welcoming and playful design.

## Demo

![Screenshot of my Earth Day Celebration landing's hero section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zn20q3tzkyjic8lk96qc.png)
Find here a [link to my project](https://vivitt.github.io/earth-day-dev-challenge/) and in this one you will find [a public repo with my code](https://github.com/vivitt/earth-day-dev-challenge).

## Journey

It was really fun to work on this project, as I spent some time trying out ideas I've had for a while and experimenting with animations and CSS.

I learned how to create scroll-driven animations, and it was a great chance to try out the [animation timeline](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timeline) CSS property. However, since it's still in an experimental state, I prioritized JavaScript-based animations to move elements based on scroll in my project. So I could ensure a more consistent experience across browsers and devices.
One interesting learning was how to create my own feature detection tests using [CSS.suports()](https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports_static).
Also, I learned more about DOM manipulation and became more confortable using CSS grid. 
Certainly, the most challenging part was achieving an acceptable appearance on small devices while retaining the visual interest of my design.

<!-- Thanks for participating! -->
Day 28/366
Tags: 1percentplusplus, 100daysofcode
Published: 2024-04-28 17:29:22

🚀 **Today's Learning:**

🌟 DSA
- Minimum in a rotated sorted array

Search in a rotated sorted array

🌟 Dev
- Lifecycle of a component in React

🔍 **Some Key Highlights:**

DSA

To find the minimum value in a rotated sorted array, you start by comparing the middle element with the first and last elements to determine which half of the array is sorted. Then, you recursively search in the unsorted half until you find the minimum element. This process continues until you've narrowed down the search to a single element, which is the minimum value.

In searching a rotated sorted array, you apply a similar approach to binary search, but with adjustments for the rotation. You compare the middle element with the target value and adjust the search based on whether the target could be in the left or right half of the array, considering the rotation. This process is repeated recursively until you find the target element or determine that it's not present in the array.

DEV

In React, the lifecycle of a component refers to the series of events that occur from its creation to its removal from the DOM. It begins with the component being initialized and mounted onto the DOM, where it can then be updated and interacted with by users. During the mounting phase, the component goes through various stages such as constructor initialization, rendering, and componentDidMount, where you can perform side effects like fetching data or setting up subscriptions. Once mounted, the component can be updated based on changes in state or props, triggering rerendering and lifecycle methods like componentDidUpdate. Finally, when the component is removed from the DOM, it goes through the componentWillUnmount phase, allowing you to clean up any resources or subscriptions to prevent memory leaks. This lifecycle pattern helps manage the behavior and appearance of components throughout their existence in a React application.

 #100daysofcode #1percentplusplus
Coze Trailblazer: Adding image processing capability with Image Wizard
Tags: cozechallenge, devechallenge, ai, machinelearning
Published: 2024-04-28 18:37:40

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp): Trailblazer.*

## What I Built

So, users are increasingly relying on AI-based tools to solve their problems. One common issue with images is file formats. Some websites don't accept certain formats or something similar. To address this problem, my plugin adds the capability for the bot/workflow to convert a image in another format. Example: PNG to JPG.

With this tool, users will not waste time searching for a solution; they simply need to upload their image and specify the desired format, and we'll take care of the rest.

## Demo

[Image Wizard - Coze Plugin Store](https://www.coze.com/store/plugin/7362967850568548358)

To preview, you can review my bot submission that utilizes the Image Wizard plugin in the background to convert an image to another format.

[Bot link that uses Image Wizard plugin](https://www.coze.com/store/bot/7362968711982104582)

To use this plugin for now, you just need to add the Convert tool to your bot or workflow. In the video below, I demonstrate a simple bot image converter.

{% embed https://www.youtube.com/watch?v=3LswSr0v6fg %}

## Journey

To complete this project, I decided to develop an application for image conversion. In the background, I worked with NestJS, MongoDB, Image Uploader Provider, Logging System, Operational System Setup, and Image libraries setup to offer a wide range of format conversions. Additionally, I learned other things to make this tool possible.

After that, I gained an understanding of the Coze ecosystem and developed my plugin and bot.

It's a great opportunity to explore new things and keep learning, so thank you!
Tetris Development #5 - The HOLD Piece
Published: 2024-04-28 18:18:51

In this post, I will talk about the implementation of the HOLD piece in our Tetris game.

First, what is a **HOLD piece**? In Tetris, there is a **HOLD slot**, which is empty at the start of the game, and the player can press a button to put the currently controlled piece into the HOLD slot to be used later. The game then continues as if the hold piece vanished. When the player thinks it is time to use the HOLD piece, they can press the same button again to swap the HOLD piece with the currently controlled piece and continue the game.

This allows for strategic planning and setup, where players can HOLD a useful piece to be used later in the game.

**"Ok but how do we implement it?"**

## Logic
I started by adding a new variable for HOLD piece, and it is empty at the start of the game.

When the HOLD button (spacebar) is pressed, the game logic will check if there exists a piece being held. If there isn't, the HOLD piece will clone the current active piece, and the active piece will be replaced by the next piece in line.

If there is already a piece being held, then pressing the HOLD button will swap the held piece with the active piece.

## Details
There are two important details in the HOLD implementation. 
Firstly, when the active piece is replaced by the HOLD piece, the drop indicator will need to change as well. Without it, the drop indicator will still show where the original block (now in HOLD) will drop, instead of the newly swapped piece. Therefore, extra logic on the drop indicator piece was implemented to correct the behavior.

Next, to ensure consistency, I made it so that when a piece is put into HOLD, its orientation (i.e. rotation) is reverted back to upright. This means that every time the player swap a piece out of HOLD, the piece will be in an upright position, instead of whatever position it was when the player pressed HOLD. Since there are 4 possible orientations, if the player has to remember which orientation the HOLD piece was in, it is a huge burden especially if the player is swapping between different HOLD pieces. Thus, by reverting to always being upright, it adds more consistency to the outcome when using the HOLD functionality.

## UI updates
But the HOLD piece won't work if the player can't see it!
Thus, the HUD must now have space for the HOLD slot, and the player should be able to see what piece is being held right now. I updated the UI to free up some space on the top-right in order to show the HOLD slot.

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

That is the end of the HOLD piece implementation. Personally, I feel that similar to the Next Piece Indicators, the HOLD piece adds another level of depth to the game and more rewards to carefully planned gameplay by strategic players. This also makes the training of an AI to play the game later more interesting.
Unlocking AI Superpowers in DevOps: Master Prompt Engineering to Revolutionize Your Workflow!
Tags: chatgpt, ai, productivity, devops
Published: 2024-04-28 18:15:38

As a Lead DevOps Engineer who continuously explores ways to work smarter and enhance our operations with AI, I recently completed a course on Prompt Engineering that offered some noteworthy insights into leveraging ChatGPT effectively.

**Key learnings:**

- AI as a Partner: The course emphasized the concept of AI as a partner, not a threat. By understanding how to communicate effectively with tools like ChatGPT, we can enhance our problem-solving capabilities.
- Prompt Engineering Skills: Structural patterns in prompts can drastically change the output quality. As engineers, we appreciate systematic approaches, and this is no different when instructing an AI.
- Efficiency in Automation: ChatGPT can be utilized to generate code snippets, automate repetitive communications, and even aid in complex troubleshooting scenarios, all by mastering the art of prompt crafting.
- Mindset for Innovation: AI requires a different mindset. It's about guidance, iteration, and continuous learning—skills that are at the core of DevOps philosophy.

**Tips for fellow DevOps professionals:**

- Be Specific: Tailor your prompts to be as detailed as possible. The more context you give, the better the AI can assist you.
- Iterate and Learn: AI won't always get it right the first time. Use each interaction as a learning opportunity to refine your prompts.
- Use AI for Scale: ChatGPT can help scale your operations by handling tasks like generating documentation, providing first-level support answers, and even creating templates for infrastructure as code.

By integrating these practices, we can make our workflows more efficient and stay ahead in the rapidly evolving field of AI. Let’s embrace the change and lead the transformation in our DevOps operations.

Would love to hear how others are integrating AI into their workflows! Feel free to share your experiences.

https://www.udemy.com/course/chatgpt-prompt-engineering/
2073. Time Needed to Buy Tickets
Tags: php, leetcode, algorithms, programming
Published: 2024-04-28 18:09:21

2073\. Time Needed to Buy Tickets

Easy

There are n people in a line queuing to buy tickets, where the <code>0<sup>th</sup></code> person is at the **front** of the line and the <code>(n - 1)<sup>th</sup></code> person is at the **back** of the line.

You are given a **0-indexed** integer array `tickets` of length `n` where the number of tickets that the <code>i<sup>th</sup></code> person would like to buy is `tickets[i]`.

Each person takes **exactly 1 second** to buy a ticket. A person can only buy **1 ticket at a time** and has to go back to **the end** of the line (which happens **instantaneously**) in order to buy more tickets. If a person does not have any tickets left to buy, the person will **leave** the line.

Return the **<i>time taken</i>** for the person at position `k` **<i>(0-indexed)</i>** to finish buying tickets.



**Example 1:**

- **Input:** `tickets = [2,3,2], k = 2`
- **Output:** `6`
- **Explanation:**
  - In the first pass, everyone in the line buys a ticket and the line becomes `[1, 2, 1]`.
  - In the second pass, everyone in the line buys a ticket and the line becomes `[0, 1, 0]`.
    The person at position `2` has successfully bought `2` tickets and it took `3 + 3 = 6` seconds.

**Example 2:**

- **Input:** `tickets = [5,1,1,1], k = 0`
- **Output:** `8`
- **Explanation:**
  - In the first pass, everyone in the line buys a ticket and the line becomes `[4, 0, 0, 0]`.
  - In the next `4` passes, only the person in position `0` is buying tickets.
    The person at position `0` has successfully bought `5` tickets and it took `4 + 1 + 1 + 1 + 1 = 8 seconds`.



**Constraints:**

- `n == tickets.length`
- `1 <= n <= 100`
- `1 <= tickets[i] <= 100`
- `0 <= k < n`

**Solution:**

```
class Solution {

    /**
     * @param Integer[] $tickets
     * @param Integer $k
     * @return Integer
     */
    function timeRequiredToBuy($tickets, $k) {
        $ans = 0;

        foreach ($tickets as $i => $ticket) {
            if ($i <= $k) {
                $ans += min($ticket, $tickets[$k]);
            } else {
                $ans += min($ticket, $tickets[$k] - 1);
            }
        }

        return $ans;
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
1700. Number of Students Unable to Eat Lunch
Tags: php, algorithms, leetcode, programming
Published: 2024-04-28 18:07:37

1700\. Number of Students Unable to Eat Lunch

Easy

The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers `0` and `1` respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.

The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a **stack**. At each step:

- If the student at the front of the queue **prefers** the sandwich on the top of the stack, they will **take it** and leave the queue.
- Otherwise, they will **leave it** and go to the queue's end.

This continues until none of the queue students want to take the top sandwich and are thus unable to eat.

You are given two integer arrays `students` and `sandwiches` where `sandwiches[i]` is the type of the i<sup>th</sup> sandwich in the stack (`i = 0` is the top of the stack) and `students[j]` is the preference of the j<sup>th</sup> student in the initial queue (`j = 0` is the front of the queue). Return the number of students that are unable to eat.

**Example 1:**

- **Input:** **`students = [1,1,0,0], sandwiches = [0,1,0,1]`**
- **Output:** **`0`**
- **Explanation:**
    - **`Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].`**
    - **`Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].`**
    - **`Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].`**
    - **`Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].`**
    - **`Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].`**
    - **`Front student leaves the top sandwich and returns to the end of the line making students = [0,1].`**
    - **`Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].`**
    - **`Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].
      Hence all students are able to eat.`**

**Example 2:**

- **Input:** **`students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]`**
- **Output:** **`3`**



**Constraints:**

- <code>1 <= students.length, sandwiches.length <= 100</code>
- <code>students.length == sandwiches.length</code>
- `sandwiches[i]` is `0` or `1`.
- `students[i]` is `0` or `1`.

**Solution:**

```
class Solution {

    /**
     * @param Integer[] $students
     * @param Integer[] $sandwiches
     * @return Integer
     */
    function countStudents($students, $sandwiches) {
        $count = array_count_values($students);
        $i = 0;
        foreach ($sandwiches as $s) {
            if (!$count[$s]) {
                break;
            }
            $count[$s]--;
            $i++;
        }
        return count($sandwiches) - $i;
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
834. Sum of Distances in Tree
Tags: php, leetcode, programming, algorithms
Published: 2024-04-28 18:03:24

834\. Sum of Distances in Tree

Hard

There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges.

You are given the integer `n` and the array `edges` where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge between nodes a<sub>i</sub> and b<sub>i</sub> in the tree.

Return an array `answer` of length `n` where `answer[i]` is the sum of the distances between the <code>i<sup>th</sup></code> node in the tree and all other nodes.

**Example 1:**

![lc-sumdist1](https://assets.leetcode.com/uploads/2021/07/23/lc-sumdist1.jpg)

- **Input:** n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]
- **Output:** [8,12,6,10,10,10]
- **Explanation:** The tree is shown above.
  We can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)
  equals 1 + 1 + 2 + 2 + 2 = 8.
  Hence, answer[0] = 8, and so on.

**Example 2:**

![lc-sumdist2](https://assets.leetcode.com/uploads/2021/07/23/lc-sumdist2.jpg)

- **Input:** n = 1, edges = []
- **Output:** [0]

**Example 3:**

![lc-sumdist3](https://assets.leetcode.com/uploads/2021/07/23/lc-sumdist3.jpg)

- **Input:** n = 2, edges = [[1,0]]
- **Output:** [1,1]

**Constraints:**

- <code>1 <= n <= 3 * 10<sup>4</sup></code>
- `edges.length == n - 1`
- `edges[i].length == 2`
- <code>0 <= a<sub>i</sub>, b<sub>i</sub> < n</code>
- <code>a<sub>i</sub> != b<sub>i</sub></code>
- The given input represents a valid tree.

**Solution:**

```
class Solution {

    /**
     * @param Integer $n
     * @param Integer[][] $edges
     * @return Integer[]
     */
    function sumOfDistancesInTree($n, $edges) {
        $g = array_fill(0, $n, array());
        foreach ($edges as $e) {
            $a = $e[0];
            $b = $e[1];
            array_push($g[$a], $b);
            array_push($g[$b], $a);
        }
        $ans = array_fill(0, $n, 0);
        $size = array_fill(0, $n, 0);

        $dfs1 = function ($i, $fa, $d) use (&$ans, &$size, &$g, &$dfs1) {
            $ans[0] += $d;
            $size[$i] = 1;
            foreach ($g[$i] as &$j) {
                if ($j != $fa) {
                    $dfs1($j, $i, $d + 1);
                    $size[$i] += $size[$j];
                }
            }
        };

        $dfs2 = function ($i, $fa, $t) use (&$ans, &$size, &$g, &$dfs2, $n) {
            $ans[$i] = $t;
            foreach ($g[$i] as &$j) {
                if ($j != $fa) {
                    $dfs2($j, $i, $t - $size[$j] + $n - $size[$j]);
                }
            }
        };

        $dfs1(0, -1, 0);
        $dfs2(0, -1, $ans[0]);
        return $ans;
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
VectorDB in Action: Unleashing the Power of Molecular Biology
Tags: webdev, python, vectordatabase, programming
Published: 2024-04-28 17:53:40

Welcome to VectorDB in Action, where the realms of molecular biology come alive with innovation and discovery. Step into the world where vectors are not just tools, but instruments of scientific prowess, driving research forward and unraveling the mysteries of life itself.

### note, you have to pip it: pip install vectordb

Code Example in Python:
```

import vectordb

# Connect to VectorDB database
db = vectordb.connect()

# Search for a specific vector by name
vector = db.search("pET28a")

# Retrieve detailed information about the vector
details = vector.get_details()

# Print vector information
print("Vector Name:", details['name'])
print("Vector Type:", details['type'])
print("Vector Sequence:", details['sequence'])
print("References:", details['references'])

```
In this example, we demonstrate how VectorDB empowers researchers with seamless access to vector information, facilitating efficient exploration and utilization in their experiments.

Why VectorDB?

## Comprehensive Database:
VectorDB boasts a vast repository of vectors encompassing various types and applications, providing researchers with a one-stop solution for their molecular biology needs.
## Advanced Search Functionality:
With advanced search capabilities, users can quickly pinpoint specific vectors based on criteria such as name, type, host organism, and more, streamlining the research process.
## Detailed Information: 
Each vector entry in VectorDB is accompanied by comprehensive details, including sequence information, annotations, references to relevant literature, and more, ensuring researchers have access to all the necessary information for their experiments.
## Community Engagement:
VectorDB fosters a vibrant community of researchers, allowing for collaboration, knowledge sharing, and feedback, further enriching the database and advancing scientific discovery.