teleren/devto huggingface dataset:
Part 3: Exception Handling in Kotlin Coroutines
Tags: webdev, kotlin, android, java
Published: 2023-05-21 20:11:02

In Part 2, we explored structured concurrency in Kotlin coroutines, ensuring orderly coroutine completion. We also witnessed how coroutines simplify asynchronous programming. In Part 3, we will unravel the art of handling exceptions in structured concurrency and equip you with techniques for robust error management. Brace yourself for an enlightening exploration!

**Exception Handling in Kotlin Coroutines: Ensuring Robustness in Asynchronous Programming**
Exception handling in coroutines is crucial for handling errors and ensuring the stability of your concurrent code. Here's a concise explanation with coding examples:

1.Error Handling and Exception Propagation:
   - Coroutines handle exceptions similarly to regular try/catch blocks.
   - Exceptions thrown in a coroutine are propagated up the call stack to the parent coroutine or the coroutine's job.
   - Unhandled exceptions in top-level coroutines are caught by the coroutine framework.

```kotlin
import kotlinx.coroutines.*

fun main() = runBlocking {
    val job = launch {
        try {
            // Coroutine logic
        } catch (e: Exception) {
            // Handle exception
        }
    }

    job.join()
}
```

In the example above, the `try/catch` block is used to handle exceptions within the coroutine.

2.`CoroutineExceptionHandler`:
   - `CoroutineExceptionHandler` is a special context element for handling uncaught exceptions in coroutines.
   - It can be attached to a coroutine scope or a specific coroutine using `CoroutineScope` or `SupervisorJob`.
   - The exception handler is invoked when an exception is unhandled, allowing you to perform custom error handling.

```kotlin
import kotlinx.coroutines.*

fun main() = runBlocking {
    val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
        // Handle uncaught exception
    }

    val job = launch(exceptionHandler) {
        // Coroutine logic
    }

    job.join()
}
```

In the example above, the `CoroutineExceptionHandler` is attached to the coroutine, allowing you to handle uncaught exceptions specific to that coroutine.

By incorporating proper error handling techniques, such as `try/catch` blocks and `CoroutineExceptionHandler`, you can effectively manage and respond to exceptions within your coroutines, ensuring the resilience and reliability of your concurrent code.


In Part 3, we explored exception handling in Kotlin coroutines, including error propagation and the usage of CoroutineExceptionHandler for custom error handling.

But why are Kotlin coroutines considered superior to Java threads? In Part 4, we'll uncover the key advantages of coroutines, including improved efficiency, conciseness, and integration with existing code. Stay tuned to discover why Kotlin coroutines are the future of concurrent programming!
Side project update
Published: 2023-05-21 20:03:30

Hello fellow developers.
I am making progress with tartigraid!!
My open source api development tool.

I finished adding support for multiple sniffers.
Now you can easily create multiple proxy sniffers with a click:

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

This is great if you are working with multiple services locally.
This way you could easily sniff all the request in your services. And see them in the dashboard.

Stay tuned i'll update on upcoming features!

Also if you think that this project is interesting. And you would like to contribute. Here is the link for my Github project:
https://github.com/idodav/tartigraid/issues
Weekly 0060
Tags: weeklyretro, devjournal
Published: 2023-05-21 19:34:09

## Monday

Today was a busy day at the office with my colleagues. We had a meeting where I presented the Azure Data Faker project, which is a tool that generates realistic fake data for testing and development purposes. I explained how it works, what features it has, and how it can benefit our clients. The presentation went well and I received some positive feedback and constructive suggestions from my team. I was happy with the outcome and proud of my work.

## Tuesday
Post on blog: [https://dev.to/this-is-learning/how-to-unleash-the-power-of-multithreading-in-javascript-with-web-workers-20m5](https://dev.to/this-is-learning/how-to-unleash-the-power-of-multithreading-in-javascript-with-web-workers-20m5)

![https://res.cloudinary.com/practicaldev/image/fetch/s--weIlnwoF--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3ai3dqb1vr4w02z8ja7.png](https://res.cloudinary.com/practicaldev/image/fetch/s--weIlnwoF--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3ai3dqb1vr4w02z8ja7.png)

During the day I did a lot of calls for Branplane.
The first one with Marta in the early morning to talk about the next steps for Brandplane and other with potential customers.

I also had a call with a new startup to become the new CTO. Let’s see in the next days/weeks.

### Wednesday

Clean up desktop and temporary files from my Desktop.
Update my PowerShell script to update my local GitHub projects and cleanup the directory: 

{% embed https://gist.github.com/kasuken/e128dc563005d13a5065d1d98162eef6 %}

In the afternoon I have packed all my stuff for traveling in the next ten days. I will write a blog post about what I bring with me for 3 conferences in 10 days and a few days of remote working.

### Thursday

Bank Holidays in DACH area!

**Mood: 💸**

## Friday
After lunch a had an important meeting (super secret) and after that meeting I went to the venue of the first conference I will have tomorrow.
I am one of the organizers of Collabdays Italy 2023 and we had to check all the stuff to the venue, pack some speakers gifts and other accomodations for everyone.
In the evening we had the speakers dinner.

Mood: ☠️

---

Are you interested in learning GitHub but don't know where to start? Try my course on LinkedIn Learning: [Learning GitHub](https://bit.ly/learninggithub).

![LinkedIn Learning](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdc2bpiftpadibi4h51c.gif)

---

Thanks for reading this post, I hope you found it interesting!

Feel free to follow me to get notified when new articles are out 🙂

{% embed https://dev.to/kasuken %}
Git things: Renaming your working branch
Tags: beginners, git, tutorial
Published: 2023-05-21 19:30:37

> I drafted this post years ago and never hit "Publish". :)

As a developer, I have been working with various proprietary tools for most of my professional life. Recently, I started working on some personal projects where I needed to use Git, an open-source tool for version control. I have to admit, I made silly mistakes while navigating Git at first. But, with some practice and research, I have learned how to use it effectively.

Something I struggled with initially was renaming a working branch in Git. It's a common task that developers need to do quite often, but I found it challenging initially. After some research and experimentation, I have come up with a goto-guide.

Here is my step-by-step guide to rename a working branch in Git on both local and remote setups:

## Renaming a branch locally
First, navigate to the local branch that you want to rename using the command:

`git checkout <branch-name>`
Then, rename the branch using the command:

`git branch -m <new-branch-name>`
This will rename the current branch to the new branch name.

## Pushing renamed branch to remote
After renaming the branch locally, push the changes to the remote repository using the command:

`git push origin -u <new-branch-name>`
This will push the renamed branch to the remote repository.

## Deleting old branch on remote
If you want to delete the old branch from the remote repository, use the command:

`git push origin --delete <old-branch-name>`
This will delete the old branch from the remote repository.

## How do I manage branch renaming with my team members or other contributors?
Here are some things that have really helped me navigate conflicts during branch naming:
- Communicate with your team about the branch renaming and coordinate with members who have branches based on the original branch.
- Merge or rebase changes from affected branches onto the renamed branch. To merge changes from an affected branch onto the renamed branch run 
`git merge <affected-branch>`
To rebase the changes from an affected branch onto the renamed branch, you can run:
`git rebase <renamed-branch>`
- Talk through situations where you need a rebase or a merge with your team.
- Update remote branches and repositories by running 
`git push -u origin <renamed-branch>`
Ask your team to update changes to their local repositories. 
Once all this gets done, consider removing the old branch to keep this clean.



That's it! You have successfully renamed a working branch in Git on both local and remote setups.

Happy coding!
Python env: be careful with requirements
Tags: python, beginners, dependencies
Published: 2023-05-21 19:17:48

It's not uncommon to provide a file called `requirements.txt` that list all third-party packages the script needs to work properly.

This way, users only have to use the following command before running the desired script:

```
pip install -r requirements.txt
```

The technique relies on pip, the package manager for Python, and the `requirements.txt` file simply contains a list of all pip packages you have to install (one per line).

## Check all dependencies carefully

It's pretty convenient and quite robust, but it's also prone to bad scenarios.

If the script you want to use relies on too much dependencies, it's not necessarily evil, but it's usually a bad sign.

This list should be kept short, in my opinion.

## Use `venv`

You should use `venv` to create isolated virtual environments "with their own independent set of Python packages installed in their site directories."

[source: Python documentation - venv](https://docs.python.org/3/library/venv.html)

If you'd like to share your Python scripts or plan to maintain a library, you can include it in your documentation to let beginners know it's possible to install your stuff in a virtual env and not globally.

It does not require any installation, as `venv` is included in Python.

You will also avoid various compatibility issues, and a virtual env is easy to `deactivate`.

## Wrap up

As a good practice, never install Python packages globally unless you perfectly know what you're doing.

Instead, you can leverage virtual environments to isolate your projects and don't mess with system-wide packages.

It won't solve all situations but you may avoid some headaches.
New to the group
Tags: python, machinelearning
Published: 2023-05-21 19:05:21

Hello everyone, I am new to modern coding but did grow up with DOS. Python is the language I am learning because I started out programming Arduino and Raspberry Pi. Then I started seeing articles about machine learning and became interested in it more than the Arduino stuff, so I switched. Just finished the Coursera course by Andrew Ng and am now exploring what I can do with my infant knowledge that may help the world. Thanks for having me, I look forward to learning.
Let's discuss a Password Manager for the Apocalypse Era.
Tags: showdev, webdev, security, discuss
Published: 2023-05-21 19:00:35



**First**, it should be something you can print out (preferably on heat-resistant titanium plates 💥 🔥 ) and then scan to a file and run. (It's a bit of a joke requirement, though why not?).

**Second**, you wouldn't need to use external programs to access your passwords (you just might not have them at your disposal).

**Third**, your secrets should not only be resistant to quantum computing, but also provide a _proven impossibility_ 🤖 to decrypt in the absence of a key.


So, I am working on a [pet project](https://github.com/griffin-container/griffin) 😺 of such a container for secrets where all secrets are stored encrypted in a single HTML file which requires only a web browser to open and you do not need to be online.

What other features should be included into such a password manager? 🤔
Maximizing Storage Efficiency: Unveiling Line Pointer Pruning in PostgreSQL
Published: 2023-05-21 18:26:49



## Introduction:
In the world of PostgreSQL databases, line pointer pruning takes center stage as a vital process for optimizing storage and enhancing query performance. By understanding the essence of line pointer pruning, database administrators can effectively manage disk space utilization and ensure the smooth operation of their PostgreSQL databases. In this concise blog post, we embark on a journey to uncover the significance and benefits of line pointer pruning.

## Line Pointer Pruning:

1. Explore the concept of line pointer pruning, which involves reclaiming space occupied by deleted or updated rows in PostgreSQL tables.
2. Grasp how line pointer pruning works behind the scenes, freeing up disk space by removing unnecessary tuples.
3. Discover how line pointers are marked as available, trimming the excess data from table files.
4. Benefits of Line Pointer Pruning:

## Efficient Disk Space Usage:

-  Line pointer pruning prevents table files from becoming bloated with obsolete data, optimizing disk space utilization.
- Enhanced Query Performance: By removing outdated tuples, line pointer pruning reduces the amount of data processed during queries, leading to faster and more efficient results.
- Cost Savings: By reclaiming disk space, line pointer pruning helps reduce storage requirements, potentially lowering costs.
## Line Pointer Pruning in Action:

- Witness the impact of line pointer pruning through practical examples.
- Understand how deleted or updated rows are identified as free space and become eligible for pruning.
- Explore the triggers and conditions that initiate line pointer pruning in PostgreSQL.
## Strategies and Considerations:

- Discover effective approaches for optimizing line pointer pruning in your PostgreSQL database.
- Explore autovacuum settings and configuration options to fine-tune pruning behavior.
- Maintain an appropriate balance between pruning frequency and resource consumption.
- In the intricate world of PostgreSQL database management, line pointer pruning shines as a valuable player. By efficiently reclaiming disk space occupied by obsolete tuples, line pointer pruning ensures optimal storage utilization and improved query performance. Embracing line pointer pruning techniques and implementing effective strategies will empower you to maintain lean and efficient PostgreSQL databases, unlocking the full potential of your data storage capabilities.
Database Normalization and De-Normalization.
Tags: database, normalizatio, management
Published: 2023-05-21 18:15:14

Normalization is a process that helps organize relational databases into logical and efficient structures by eliminating data redundancy and ensuring data integrity. It involves decomposing large tables into smaller ones based on specific rules and dependencies. The most common normalization forms include First Normal Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF).


**First Normal Form (1NF):**
1NF requires that each attribute within a table contains only atomic (indivisible) values. It eliminates repeating groups and ensures that each row has a unique identifier (primary key).


**Second Normal Form (2NF):**
2NF builds upon 1NF and addresses partial dependencies. It requires that all non-key attributes depend on the entire primary key, rather than just a portion of it. This form ensures each attribute is functionally dependent on the primary key.


**Third Normal Form (3NF):**
3NF further refines the normalization process by addressing transitive dependencies. It mandates that no non-key attribute depends on other non-key attributes within the same table. In other words, it removes indirect relationships between non-key attributes.




** Benefits of Normalization:**

**Data integrity:**
Normalization helps prevent anomalies such as insertion, deletion, and update anomalies, ensuring data consistency.

**Reduced redundancy: **
By eliminating redundant data, normalization reduces storage requirements and avoids inconsistencies.
**Improved query performance:**
Normalized tables are typically optimized for efficient data retrieval, leading to faster query execution.

**Denormalization:**
Denormalization is the process of selectively reintroducing redundancy into a database to improve query performance or simplify data retrieval. While normalization aims to minimize redundancy, denormalization acknowledges that in certain scenarios, duplicating data can be beneficial.

**Types of Denormalization:**

**Flattening:** 
Combining related tables into a single table to eliminate the need for joins.
Redundant Columns: Adding duplicate data to a table to avoid joins and improve query performance.
**Summary Tables:** 
Creating aggregated tables that contain pre-computed summaries of data to speed up analytical queries.
**Materialized Views:**
Storing the results of complex queries as physical tables to enhance query performance.


**Benefits of Denormalization:**

**Improved query performance: **
By reducing the number of joins or eliminating them altogether, denormalization can significantly enhance query execution speed.
**Simplified data model:** 
Denormalized structures can simplify application development and reduce complexity.
**Reduced resource consumption:**
Denormalization can decrease the demand for computational resources, such as CPU and memory, during query execution.
Save ssh login info to make easy remote ssh
Tags: linux, ssh
Published: 2023-05-21 18:11:04

Define ~/.ssh/config file with the following contents

```
Host meh
    HostName meh.example.com
    User admin
    Port 1234
    IdentityFile ~/.ssh/id_rsa
```
Use `ssh [host]` to connect to the host using the config file.

```
ssh meh
```

---

## reference
- [askubuntu.com](https://askubuntu.com/questions/1118136/how-to-save-a-frequently-used-ssh-host-for-access-via-terminal)
WordPress vs Other CMS: Pros and Cons
Tags: cms, webdev, wordpress, beginners
Published: 2023-05-21 18:09:56




When it comes to building a website, choosing the right content management system (CMS) is essential. WordPress is one of the most popular CMS platforms, but it’s not the only one. In this blog post, we’ll explore the pros and cons of WordPress compared to other CMS platforms.

## WordPress Pros:

**Ease of Use:** WordPress is known for its user-friendly interface, making it easy for beginners to build and manage a website.
**Customization:** WordPress provides a vast library of themes and plugins that allow users to customize their website’s appearance and functionality.
**Community Support:** With its large user base, WordPress has an extensive community of developers and users who provide support and share resources.
**SEO-Friendly:** WordPress is built with SEO in mind, providing features like customizable permalinks, easy content creation, and optimization plugins like Yoast.
**Cost-Effective:** WordPress itself is free, and many of its themes and plugins are also free or low-cost.


## WordPress Cons:

**Security:** As with any popular platform, WordPress is a target for hackers, and security vulnerabilities can lead to website hacks and data breaches.
**Speed and Performance:** WordPress can be slow and resource-intensive, especially with poorly optimized themes and plugins.
**Updates and Maintenance:** WordPress requires regular updates and maintenance to keep the website secure and running smoothly, which can be time-consuming.
**Customization Limitations:** While WordPress offers a wide range of customization options, there may be limitations in terms of design and functionality.


## Other CMS Pros and Cons:

**Drupal:** Drupal offers advanced customization options and a robust security framework, but it can be complex and challenging for beginners.
**Joomla:** Joomla is user-friendly and offers a wide range of features and extensions, but it can be slow and not as SEO-friendly as WordPress.
**Shopify:** Shopify is a popular ecommerce platform that offers easy setup and customization, but it can be costly and limited in terms of design and functionality.


In conclusion, each CMS platform has its strengths and weaknesses. WordPress is a popular choice for its ease of use, customization options, and community support. However, it’s not without its drawbacks, such as security vulnerabilities and maintenance requirements. When choosing a CMS, it’s essential to consider your website’s specific needs and choose a platform that best meets those needs.

_View more latest news on [My Blog](https://rohantgeorge.com/blog/)_
Title: Unleashing the Power of PostgreSQL's Indexing Techniques for Enhanced Query Performance
Published: 2023-05-21 17:55:13


## Introduction:
PostgreSQL, a versatile and powerful relational database management system, offers a variety of indexing techniques that can greatly improve the performance of your queries. In this informative blog post, we delve into the world of PostgreSQL indexing, exploring its techniques and showcasing how they can optimize the efficiency of your database.

## PostgreSQL Indexing:

- Gain a comprehensive understanding of indexing in PostgreSQL and its role in query optimization.
- Explore the widely used B-tree indexes and their internal structure, key-value organization, and search algorithms.
- Exploring Advanced Indexing Techniques:
- Dive into advanced indexing techniques available in PostgreSQL, such as Hash, GiST, SP-GiST, GIN, and BRIN.
- Discover the benefits and use cases of each technique for specific data types and query patterns.
- Understand the underlying data structures and query optimization strategies employed by advanced indexing techniques.
## Strategies for Performance Optimization:

- Learn effective strategies for selecting the appropriate indexes for your queries.
- Analyze query execution plans and leverage PostgreSQL's EXPLAIN feature to identify inefficient queries and potential index improvements.
- Explore the impact of indexing on different types of queries, including range queries, full-text search, and spatial queries.

## Index Maintenance and Optimization:

- Discover best practices for maintaining indexes to ensure optimal performance over time.
- Understand the trade-offs between indexing and data modification operations, such as inserts, updates, and deletes.
- Explore techniques for index tuning, including index compression, partial indexes, and multicolumn indexes.
## Monitoring and Troubleshooting:

- Learn how to monitor and analyze index usage and performance using PostgreSQL's system catalogs and monitoring tools.
- Identify and address common issues related to indexing, such as index bloat and fragmentation.
- Troubleshoot performance problems related to indexes and optimize their usage for specific workloads.
- By harnessing the power of PostgreSQL's indexing techniques, you can greatly enhance the performance and efficiency of your database. With a deeper understanding of indexing strategies, maintenance best practices, and troubleshooting techniques, you'll be well-equipped to optimize your PostgreSQL database and unlock its true potential.