teleren/devto huggingface dataset:
Navigating Git Merge
Published: 2023-09-29 16:16:48

## Introduction
In the world of coding, Git conflicts are like roadblocks that every developer encounters at some point. Recently, I faced one such hiccup while working on the txtToWeb.py script. This story is about how I navigated the challenge, resolving the conflict, and what I learned in the process.

## Background and Implementation
As a part of Lab 3, I implemented two additional features in two different branches my txtToWeb tool as discussed in previous blogs. 

- issue-9 : This branch a lang flag implemented based on which my html lang was set.
- issue-10 : This branch had a parses implemented for `---` to convert it to `<hr>` tags.

Link to the issues created to track the above : [#9](https://github.com/Rachit1313/txtToWeb/issues/9) [#10](https://github.com/Rachit1313/txtToWeb/issues/10)


## The Merge Attempt

I was merging changes from two branches, `issue-9` and `issue-10`, into the main code. Things seemed smooth until Git hit a snag and flagged a conflict in the txtToWeb.py file. It meant lines of code from both branches clashed, creating confusion.

## Fast-Forward Merge

The first merge for merging `issue-9` was straightforward a fast-forward type of merge as it directly had the main branch as the parent and I just used the command below to make the changes.

```
git merge issue-9
```
## Recursive Merge
With the first merge done, I proceeded to merge issue-10. However, this time, Git didn’t play nice. The conflict arose in the txtToWeb.py file, halting my progress. Lines of code from both branches were entangled, and Git was waiting for my decision on which changes to keep. It required me to commit my changes again in order to merge the last branch. The special thing about this type of merge is that It has two parent commits. 

## Committing Changes: Handling the Dual Parent Commits

Once I resolved the conflict and edited the code accordingly, there was a unique step in the process. In a recursive merge, Git requires an additional commit to finalize the merge, especially when there are two parent commits. This step ensured that both branches' changes were properly integrated.

## Learning Outcome from the Lab
I faced an issue that it failed to open vi editor. After consulting with my professor, He guided me to change my default git editor using the command below:
```
git config --global core.editor "vim"
```
I also learned how to handle both type of git merges and how to handle few conflicts related to recursive merges.

Another important thing I learned is using `git status` to debug when in middle of a conflicting merge.
Buy Verified Cash App Accounts
Published: 2023-09-29 16:14:25


**[Buy BTC Enable Cash App Accounts](https://iblmarketpro.com/product/buy-verified-cash-app-accounts/)**

iblmarketpro is one of the best quality, reliable Verified Cash App Accounts  providers. We are account  Experts and provide Verified Cash App Accounts from USA, UK, and more other countries. We are providing High-Quality Verified Cash App Accounts at the cheapest rate. Along with that we give a 100% money-back guarantee. Our only demand is to gain customer satisfaction through good and reliable services. Here you can buy Verified Cash App Accounts services at the cheapest price.

Our service gives-

Email login access
Phone login Access.
SELFIE VERIFIED.
Cash app login access. + tag change.
100% secure and full verified accounts
Personal information such as Drivers license and SSN and others
Customer satisfaction guaranteed
You can transfer money without any problem
Replacement guaranteed within 15 days
BTC WALLET AND BTC BUY/SELL ENABLED.
Guarantee and secure account to use.
Accounts Replacement guaranteed
Customer support 24 hour
To avoid scam and to get verified and best quality cashapp account you can place your order. Your satisfaction always our first priority. We think iblmarketpro.com is best place to buy verified cashapp accounts to you. Place your order and buy it safely.

24/7 Customer support/ Contact US
WhatsApp: +1(561)3202534
Telegram: @iblmarketpro
Skypea: @iblmarketpro
Email: iblmarketpro23@gmail.com

https://iblmarketpro.com/product/buy-verified-cash-app-accounts/
Switching Themes in a Vue.js Application with `<script setup>` and PrimeVue
Tags: vue, primevue, themeswitch
Published: 2023-09-29 15:57:09

In this post, we'll explore how to implement theme switching in a Vue.js application using the `<script setup>` syntax and PrimeVue. We'll create a simple Vue application where users can switch between different themes provided by PrimeVue.

### Prerequisites

Before we begin, make sure you have the following installed:

- Vue.js
- PrimeVue

### Setting Up the Project

Let's start by setting up a new Vue.js project with PrimeVue. You can create a new Vue project using Vue CLI or integrate PrimeVue into an existing project.

### Creating the Theme Switcher Component

We'll create a theme switcher component that allows users to select a theme from a dropdown menu. This component will use the `<script setup>` syntax, which is a more concise way to define Vue components.

```vue
<template>
  <div>
    <!-- Theme Switcher -->
    <select v-model="selectedTheme" @change="changeTheme">
      <option value="vela">Vela</option>
      <option value="bootstrap">Bootstrap</option>
      <!-- Add other theme options as needed -->
    </select>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const selectedTheme = ref('vela'); // Set the default theme here

const changeTheme = () => {
  // Dynamically change the theme by updating the href attribute
  const themeLink = document.querySelector('link[href*="/primevue/themes/"]');
  themeLink.href = `primevue/themes/${selectedTheme.value}/theme.css`;
};
</script>
```

In this component, we define a `<select>` element to choose themes, and when the selection changes, it triggers the `changeTheme` function to dynamically update the theme by changing the `href` attribute of the theme stylesheet link.

### Using the Theme Switcher Component

To use the theme switcher component, simply include it in your Vue application where you want the theme switching functionality.

```vue
<template>
  <div>
    <ThemeSwitcher />
  </div>
</template>

<script  setup>
import ThemeSwitcher from './ThemeSwitcher.vue';
</script>
```

### Conclusion

With this setup, you can easily implement theme switching in your Vue.js application using the `<script setup>` syntax and PrimeVue. Users can select their preferred theme from a dropdown menu, and the application's appearance will change dynamically.

Feel free to extend this example by adding more themes and customizing the theme-switching mechanism to fit your project's requirements.

That's it! You now have a Vue.js application with theme switching capabilities using `<script setup>` and PrimeVue. Happy coding!
Rotate certificate in NGINX Open Source without restart
Tags: nginx, ssl, opensource, nginxplus
Published: 2023-09-29 15:52:00

_ตอนนี้ทีมทยอยย้ายเข้า Office ใหม่ตึก OASIS ในรูปเป็นห้องร้อง Karaoke เอ๊ยห้องประชุมขนาดย่อม ไว้ร้อง Karaoke ได้เต็มที่ 8 คน เอ๊ยนั่งทำงานได้เต็มที่ 4 คนครับ_

ท่านที่ใช้งาน NGINX คงจะคุ้นเคยกับการใส่ Certificate บน NGINX เพื่อที่เวลา Client request จะได้สามารถเปิด Connection แบบเข้ารหัสได้ ผลคือทำให้ Client สามารถเชื่อได้ว่าเป็นเว็บไซต์ เช่นเว็บผู้ให้บริการนี้ตัวจริง และยังช่วยเข้ารหัสข้อความที่ส่งไปมาระหว่างกัน

```
server {
    listen              443 ssl;
    server_name         www.example.com;
    ssl_certificate     www.example.com.crt;
    ssl_certificate_key www.example.com.key;
    ...
}
```

โดยปกติ Certificate จะถูกอ่านจากไฟล์(Disk) แล้วนำไปเก็บใน Memory ตอนที่ start NGINX ฉะนั้นการ Establish connection ก็จะเรียกใช้ key pairs ได้อย่างรวดเร็วผ่าน memory ถ้าเว็บมี server_name เดียว และไม่ได้เปลี่ยนคีย์บ่อยๆ หรือเปลี่ยนแบบมี Downtime ได้ การใช้งานแบบปกติก็ยังเพียงพอ

แต่ถ้าเป็นการที่มี Dynamic name เช่นมีหลายชื่อ มีชื่อเพิ่มเข้าออกบ่อย, หรือกรณีต้องการเปลี่ยน Certificate เป็นตัวใหม่ โดยไม่ให้เกิด Downtime กรณีนี้ เดิมทำได้ทั้งบน NGINX Plus และ NGINX OSS อยู่แล้ว ต่างกันที่วิธีการและ Performance

- โดย NGINX Plus ใช้ key-value store ในการเก็บ ซึ่งอยู่บน memory และ load ค่าใหม่จาก Disk เข้า Memory ได้หากต้องการ
- NGINX Open Source ใช้วิธีให้อ่านใหม่ทุกครั้ง ซึ่งมีผลกระทบคือเป็นการอ่านจาก Disk ทำให้กระทบกับ Performance กรณีที่ต้อง Establish connection บ่อยๆ

ที่จะเล่าวันนี้มาจาก [SSL/TLS Certificate Rotation Without Restarts in NGINX Open Source](https://www.nginx.com/blog/ssl-tls-certificate-rotation-without-restarts-in-nginx-open-source/?utm_medium=owned-social&utm_source=linkedin&utm_campaign=ww-nx_ssap_g&utm_content=bg-) โดยเป็นการใช้ความสามารถของ NGINX JavaScript Module มาทดแทน key-value store บน NGINX Plus

เริ่มจาก ให้ njs เป็นคนเก็บค่า certificate ไว้ใน Memory
```
     # Sets an njs function for the variable. Returns a value of cert/key
      js_set $dynamic_ssl_cert main.js_cert;
      js_set $dynamic_ssl_key main.js_key;   
```

จากนั้น NGINX นำค่านี้ไปใช้ตามปกติ ก็จะเป็นค่าอ่านค่า Certificate จาก Memory ซึ่งไม่กระทบกับ Performance แล้วนั่นเอง
```
      # use variable's data
      ssl_certificate data:$dynamic_ssl_cert;
      ssl_certificate_key data:$dynamic_ssl_key;
```

เมื่อต้องการเปลี่ยนไปใช้ Certificate ใหม่ สามารถใช้ njs ให้ยกเลิกค่าใน Memory และไปอ่านค่าจากไฟล์ใหม่ได้ทันที, เมื่อ NGINX เรียกใช้ ก็จะเรียกใช้งานจาก Memory ได้ต่อเนื่อง

เบื้องหลังการยกเลิกการใช้งาน Certificate เดิมที่อยู่ใน Memory ให้ไป Load Certificate ใหม่จาก Disk

```
   location = /clear {
      js_content main.clear_cache;
      # allow 127.0.0.1;
      # deny all;
    }
```

โดยสรุป เราสามารถที่จะใช้ NJS หรือ NGINX JavaScript Module ซึ่งใช้งานได้ง่ายด้วยภาษา JavaScript และคนทำเว็บคุ้นเคยอยู่แล้ว มาช่วยเพิ่มความสามารถอื่นๆ ให้ NGINX ได้ครับ ในทีนี้คือทำ Function Serve certificate จาก Cache พร้อมความสามารถในการ Reload Certificate ใหม่จาก Disk ลง Cache ได้ด้วยครับ __
What is Low code app development?
Tags: lowcode, java, appdevelopment, opensource
Published: 2023-09-29 15:42:12

Low-code app development is an innovative approach to creating software [applications](https://www.wavemaker.com/java-low-code-platform/) that require minimal manual coding. Instead of writing extensive lines of code, developers use a visual interface with drag-and-drop components and pre-built templates to design, configure, and customize applications. This method significantly accelerates the development process and makes it more accessible to individuals with limited coding experience.

[Low-code app development platforms](https://www.wavemaker.com/what-is-low-code-app-development/) provide a set of tools and features that enable developers to streamline application development, automate repetitive tasks, and integrate with various data sources and services. These platforms are designed to empower businesses to create applications more quickly and cost-effectively while maintaining the flexibility to customize the software to meet specific needs.

Overall, [low-code app development](https://www.wavemaker.com/low-code-app-development-platform/) simplifies and expedites the software development lifecycle, making it an attractive option for organizations looking to innovate, respond to changing market demands, and enhance their digital capabilities.
Problem importing useNavigation or Link from 'react-router-dom'
Tags: react, hooks, route, vite
Published: 2023-09-29 15:40:50

I installed react-router-dom (6.5.0) among the dependencies of my project, but when I want to import the hooks, it doesn't show anything from the dependency.

I don't have anything strange configured, using Vite and js. If I copy and paste something like import {useNavigation} from 'react-router-dom' the entire screen goes blank (the background is gray). I tried installing a previous version, installing and uninstalling several times, including npm, but nothing changes.

I leave screens.


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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zodl3uc78v0dskvryx5b.png)
Association Proxy
Tags: python, flask
Published: 2023-09-29 15:34:31

Association Proxy is a useful tool for modeling relationships in SQLAlchemy. It provides a way to relate many-to-many relationships without showing the middle relationship and allowing you to select specific fields to use. 

In the following example, there are many users that have read many books. We want to be able to access which books each user has read through the joiner association of UserBooks. 

```
from sqlalchemy.ext.associationproxy import association_proxy

class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String, nullable = False)

    books = db.relationship('Book', backref = 'user')

    userbooks = association_proxy('books', 'userbook')

class Book(db.Model):
    __tablename__ = 'book'

    id = db.Column(db.Integer, primary_key = True)
    title = db.Column(db.String, nullable = False)

class UserBook(db.Model):
    __tablename__ = 'userbook'

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    book_id = db.Column(db.Integer, db.ForeignKey('book.id'))
```
For the association proxy, the first argument is the location we want to pull the data from. In this case, we want to pull it from the `books` relationship defined immediately above. The second argument is what data we want to receive from that location. This also allows us to create new `userbook` objects when we add to the collection. 

```
>>> user = User("Alfred")
>>> user.userbooks.append("The Name of the Wind")
>>> user.userbooks.append("The Lies of Locke Lamora")
>>> print(user.readbooks)
['The Name of the Wind', 'The Lies of Locke Lamora']
```
Without association proxy, the same result as above would be more complicated. 

```
>>> user = User("Alfred")
>>> user.userbooks.append(Book("The Name of the Wind"))
>>> user.userbooks.append(Book("The Lies of Locke Lamora"))
>>> print([book.title for book in user.books])
['The Name of the Wind', 'The Lies of Locke Lamora']
```
In the first example, the `.append()` event is intercepted by the association proxy and instantiates a new instance of the intermediate object, which is the UserBook class in this case. Additionally, because of the relationships mapped out in the User class, this instance only needs the one argument.
Prune Unused Resources in Docker
Tags: docker, devops, programming, tutorial
Published: 2023-09-29 15:30:00

Over time, Docker can accumulate unused resources like containers, images, volumes, and networks. These unused resources consume disk space and can make your Docker environment less efficient. To keep your system clean and free up disk space, it's a good practice to regularly prune these resources using Docker's built-in commands.

Here are some useful commands for resource pruning:

- **Prune Unused Containers:**
  ```bash
  docker container prune
  ```

- **Prune Unused Images:**
  ```bash
  docker image prune
  ```

- **Prune Unused Volumes:**
  ```bash
  docker volume prune
  ```

- **Prune Unused Networks:**
  ```bash
  docker network prune
  ```

- **Prune All Unused Resources (Containers, Images, Volumes, Networks):**
  ```bash
  docker system prune
  ```

Please exercise caution when using these commands, especially the `docker system prune` command, as it will remove all unused resources, and there's no way to recover them once they are pruned. It's a good practice to periodically run these commands, but be mindful of their potential impact on your Docker environment.

You can also automate resource pruning by setting up a scheduled job or script to run these commands regularly. This helps maintain a clean and efficient Docker environment and can prevent unexpected resource-related issues in the future.
ULTIMEA Poseidon D60 - Ultimea’s First 5.1 Dolby Atmos Soundbar Under $200
Tags: productivity, news
Published: 2023-09-29 15:24:07

SEPTEMBER 15th, 2023/ ULTIMEA, a leading provider of affordable soundbars, projectors, and home audio systems, is excited to announce the launch of its latest product, the Poseidon D60  5.1 Dolby Atmos Soundbar. This groundbreaking addition to ULTIMEA's lineup of home audio and video products sets a new standard for immersive sound experiences at an affordable price point.

If you desire a cinematic sound experience from the comfort of your own home, the ULTIMEA Poseidon D60 offers even more options to suit your needs. With its deep and immersive sound capabilities, compact enclosure design, and versatile surround speakers, this product brings the movie theater ambiance right into your living room. 

- 5.1 Dolby Atmos Sound
- ULTIMEA BassMX Technology
- Wireless Subwoofer
- 2 Surround Rear Speakers
- Versatile Connectivity
**[Learn more](https://www.ultimea.com/blogs/news/ultimea-poseidon-d60-5-1-dolby-atmos-soundbar)**
ULTIMEA Thor T60 Triple Laser TV:Born Bright,Beyond Daylight
Tags: lasertv, ultimea, product, news
Published: 2023-09-29 15:18:41


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vnwbbfa9xj9wuouidn4.jpg)[]((https://www.kickstarter.com/projects/611565840/ultimea-thor-t60-triple-laser-tv-born-brightbeyond-daylight))
4000 ANSI Lumens | 4000:1 Contrast Ratio | 120% BT.2020 HCTC™️ Technology | Dolby Vision | 4K UHD | Dolby Atmos & DTS HD
- Powered by a Tri-Color Laser Engine and HCTC™ 3.0 Technology for unmatched color purity, a vast color gamut, and striking contrast.
- Achieves an extremely high contrast ratio of 4000:1 for vivid and sharp images.
- Exceeds the 120% BT.2020 standard for a wide color range.
- Utilizes ULTIMEA's trademark technology, BrightMX™, to deliver optimal brightness in any environment.
- 4000 ANSI Lumens, ensuring bright projection in all settings.
[Learn more]((https://www.kickstarter.com/projects/611565840/ultimea-thor-t60-triple-laser-tv-born-brightbeyond-daylight))
Golang error updates
Tags: go, programming, development
Published: 2023-09-29 15:12:09

Since go 1.20, golang has improved the ergonomics of error handling. Noteworthy improvements include:

- `errors.Is` and `errors.As` have been updated to work on tree of errors
- `fmt.Errorf` accepts multiple %w format verbs, allowing to join multiple errors
- The `Unwrap []error` function allows traversing through tree of errors

Follow some tests demonstrating the practical application of these enhancements (also available in the [golang playground](https://go.dev/play/p/LCBbcvRUXAD)):

```golang
package main

import (
	"errors"
	"fmt"
	"testing"
)

func TestErrorfForWrapping(t *testing.T) {
	err1 := errors.New("a")
	err2 := errors.New("b")
	// the parentheses in the string are arbitrary
	wrap := fmt.Errorf("%w (%w)", err1, err2)

	if errors.Is(wrap, err1) == false {
		t.Fatal()
	}
	if errors.Is(wrap, err2) == false {
		t.Fatal()
	}
}

func TestStatusCodeInErrors(t *testing.T) {
	var (
		//
		// client errors
		//
		clientError = errors.New("client error")
		//
		// client error causes
		//
		unauthorized     = errors.New("unauthorized")
		resourceNotFound = errors.New("resource not found")

		//
		// server errors
		//
		serverError = errors.New("server error")
		//
		// server error causes
		//
		badGatewayError     = errors.New("badGateway")
		internalServerError = errors.New("internal server error")
	)

	getStatusCode := func(err error) (int, string) {
		if errors.Is(err, clientError) {

			if errors.Is(err, unauthorized) {
				return 400, "unauthorized"
			}
			if errors.Is(err, resourceNotFound) {
				return 400, "resource not found"
			}
			return 400, "no error type"

		} else if errors.Is(err, serverError) {

			if errors.Is(err, badGatewayError) {
				return 500, "bad gateway"
			}
			if errors.Is(err, internalServerError) {
				return 500, "internal server error"
			}
		}
		return 500, "no error type"
	}

	err := fmt.Errorf("%w (%w)", clientError, unauthorized)

	if code, mex := getStatusCode(err); code != 400 || mex != "unauthorized" {
		t.Fatal()
	}

	err = fmt.Errorf("%w (%w)", clientError, resourceNotFound)
	if code, mex := getStatusCode(err); code != 400 || mex != "resource not found" {
		t.Fatal()
	}

	err = fmt.Errorf("%w (%w)", serverError, internalServerError)
	if code, mex := getStatusCode(err); code != 500 || mex != "internal server error" {
		t.Fatal()
	}
}

type customError struct {
	wrapped []error
}

func (t *customError) Unwrap() []error {
	return t.wrapped
}
func (t *customError) Error() string {
	return "custom error"
}

func TestCustomErrorWrapping(t *testing.T) {
	err1 := errors.New("a")
	err2 := &customError{wrapped: []error{err1}}
	// it's much more convenient to do this
	// wrap := fmt.Errorf("%w (%w)", err1, err2) and you do not need to implement Unwrap

	if errors.Is(err2, err1) == false {
		t.Fatal()
	}
	if errors.Is(err2, err2) == false {
		t.Fatal()
	}
	if errors.Is(err2.Unwrap()[0], err1) == false {
		t.Fatal()
	}
}

```
How to use Filament Api Service Plugin
Tags: php, laravel, filament, tutorial
Published: 2023-09-29 15:09:07

## Installation

You can install the package via composer:

```bash
composer require rupadana/filament-api-service
```

## Usage

```bash
php artisan make:filament-api-service BlogResource
```

Add this code to your routes file, example in routes/api.php

```php
...
use App\Filament\Resources\BlogResource\Api;
...

BlogApiService::routes();
```

and then you will got this routes:

- [GET] '/api/blogs'   - Return LengthAwarePaginator 
- [GET] '/api/blogs/1' - Return single resource   
- [PUT] '/api/blogs/1' - Update resource
- [DELETE] '/api/blogs/1' - Delete resource


Im using `"spatie/laravel-query-builder": "^5.3"` to handle query and filtering. u can see `"spatie/laravel-query-builder": "^5.3"` [https://spatie.be/docs/laravel-query-builder/v5/introduction](documentation)


You can specified `allowedFilters` and `allowedFields` in your model

Example
```php
class User extends Model {
    public static array $allowedFilters = [
        'name'
    ];
    
    public static array $allowedFields = [
        'name'
    ];
}
```


## Transform API Response

```bash 
php artisan make:filament-api-transformer Blog
```

it will be create BlogTransformer in `App\Filament\Resources\BlogResource\Api\Transformers`

next step you need to edit & add it to your Resource

```php
    use App\Filament\Resources\BlogResource\Api\Transformers\BlogTransformer;

    class BlogResource extends Resource
    {
        ...
        public static function getApiTransformer() 
        { 
            return BlogTransformer::class; 
        }
        ...
    }
```


## Group Name & Prefix

You can edit prefix & group route name as you want, default im use model singular label;

```php
    class BlogApiService extends ApiService
    {
        ...
        protected static string | null $groupRouteName = 'myblog';
        ...
    }
```
Renew SSL Let’s Encrypt
Tags: ssl, https, letsencrypt, webdev
Published: 2023-09-29 15:06:39

## Renew
To renew SSL Let's Encrypt you can run the following command


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

## Auto Renew

So that you don't have to bother renewing SSL manually, you can create a cron job to renew automatically. Run the command “crontab -e” and add the following command to the last line.


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