teleren/devto huggingface dataset:
05 - Concurrency Control
Tags: programming, tutorial, beginners, apacheage
Published: 2023-07-13 14:15:22

In a multi-user environment where numerous transactions may access and edit the same data concurrently, concurrency control is an essential component of database management systems (DBMS) that assures data consistency and integrity. By coordinating the execution of transactions, concurrency control systems avoid conflicts and protect data integrity.

**The following are some significant theories and methods in concurrency control:**

**Transactions:** Logical units of work called transactions are made up of one or more database operations. It symbolizes a series of activities that should be carried out atomically, which means that either all of them succeed or none of them have any impact at all.

![my-images](https://res.cloudinary.com/practicaldev/image/fetch/s--xy3wEe_E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fymtc83bkqsccecc5841.png)

**Isolation Levels:** The level of transactional isolation is determined by the use of isolation levels. Different levels of isolation offer various concurrency and consistency guarantees. READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE are examples of common isolation levels.

**Locking:** Locking is a common concurrency control method. To limit access and modification, it entails obtaining and releasing locks on database objects. Locks can be shared (read locks) or exclusive (write locks). By ensuring that only one transaction may alter a data item at once, locking helps to avoid conflicts and preserve consistency.

**Multiversion Concurrency Control (MVCC):** MVCC is a locking option that is frequently employed in isolation levels based on snapshots. To give each transaction a consistent snapshot of the database at the moment of its commencement, MVCC produces several copies of a data item rather than obtaining locks. Because of this, read operations can continue without being blocked even when there are concurrent write operations.

**OCC (Optimistic Concurrency Control):** OCC gives optimistic assurances and operates under the premise that conflicts between transactions occur seldom. Without obtaining locks, transactions continue, and conflicts are examined at the commit phase. The impacted transaction is rolled back and restarted if conflicts are found. The blocking and costs associated with locking are reduced by OCC, but rigorous conflict detection and resolution procedures are needed.

## Closing Remarks

In a multi-user database context, concurrency control is crucial for maintaining data integrity and making sure that transactions go through as intended. To coordinate transaction execution, avoid conflicts, and offer the required level of isolation and consistency guarantees, DBMS uses a variety of methods, including locking, MVCC, and OCC.
[Digest] Java, Kotlin, Spring, Cloud, and More - Episode 4
Tags: digest, java, cloud, spring
Published: 2023-07-13 14:12:16

Hi everyone! Here are some news for this week.

🎉 [What's new in Kotlin 1.9.0](https://kotlinlang.org/docs/whatsnew19.html): our dearly beloved Kotlin version 1.9.0 is released now! It has K2 compiler (Beta), new features, stabilisation of existing API, and many more. There is also a nice video overview by Anton Arhipov.

💾 [(Hopefully) the final article about equals and hashCode for JPA entities with DB-generated IDs](https://jpa-buddy.com/blog/hopefully-the-final-article-about-equals-and-hashcode-for-jpa-entities-with-db-generated-ids): how you should and should not override `equals`/`hashСode` for JPA Entity in different scenarios, including considerations for Hibernate proxy behaviour.

💡 [Gathering the streams](https://cr.openjdk.org/~vklang/Gatherers.html): enhancement proposal for Java Streams API with intermediate operation `gather` which will let you do things that cannot be accomplished using streams right now (for instance, fixed window and sliding window).

☁️ [We have left the cloud](https://world.hey.com/dhh/we-have-left-the-cloud-251760fb): one more story on why and how the company left the cloud and how much money they saved.

🧭 [From Java and Microservices to Dgraph: A Big Bang Migration Journey of a 14M Users App](https://levelup.gitconnected.com/from-java-and-microservices-to-dgraph-a-big-bang-migration-journey-of-a-14m-users-app-38b2b2eeb42c): the story of migration from Java microservice backend to Dgraph + GraphQL, and what problems you may face during this journey.

---

*Dream your code, code your dream.*
Help: How do I create an engaging blog website?
Tags: help, discuss, career, webdev
Published: 2023-07-13 14:09:15

Hi there dev writers and readers,
I recently created a blog website and I have no users, 

Am here to request for your advice on how I can scale the site and get more writers and get readers as well.

Here is the link to the website, https://melbite.com

Your comments will help alot.
What is localeCompare in JS(Javascript) ?
Tags: javascript, programming, tutorial, development
Published: 2023-07-13 14:04:12

The `localeCompare()` method in JavaScript allows for comparing two strings within the current locale. By utilizing this method, you can obtain a numerical value that indicates the relative positioning of a reference string in relation to the provided string, determining whether it comes before, after, or is the same in terms of sort order

***If you don't understand the above definition, don't worry. You will grasp the concept after reading the following example***

The following are the possible return values of the localeCompare() method:

  -1 - The reference string comes before the given string in sort order.

  1 - The reference string comes after the given string in sort order.

  0 - The reference string is the same as the given string.

**Example:-**

```js
const str1 = "about";
const str2 = "aware";

const result = str1.localeCompare(str2);

console.log(result); // -1
```

In this example, the `localeCompare()` method returns `-1` because the string str1 comes before the string str2 in the current locale.

To gain a deeper understanding, let's explore another analogy. In the provided code example, the output is `-1`. To comprehend this, let's envision a dictionary where we encounter the words "about" and "aware." In this case, the position of "about" precedes "aware," which explains why the output is -1.

**The `localeCompare()` method takes two arguments:**

The reference string - The string that is being compared to the given string.
The given string - The string that is being compared to the reference string.

**The `localeCompare()` method also supports two optional arguments:**

**locale** - The locale that should be used to compare the strings. If this argument is not specified, the current locale will be used.
**options** - An object that specifies the options for the comparison. The following are the supported options:
        sensitivity - The sensitivity of the comparison. The possible values are "CI" (case-insensitive) and "CC" (case-sensitive).
        numeric - Whether to treat the strings as numbers. If this option is set to true, the strings will be compared as numbers, regardless of their content.

The `localeCompare()` method is a useful tool for comparing strings in a locale-sensitive way. It can be used to sort strings in a user's preferred language, or to compare strings that contain diacritics or other special characters.

Thank you for reading this blog, follow me on Twitter, I regularly share blogs and post on Javascript, React, Web development and opensource contribution

Twitter- https://twitter.com/Diwakar_766

Github- https://github.com/DIWAKARKASHYAP
Toggle Switch Field for Nova 4
Published: 2023-07-13 13:47:11

### Toggle Switch Field for Nova 4

##### * Toggle Switch Field for Nova 3 go to
https://github.com/naifalshaye/toggle-switch

### Requirements
- PHP 8.0 or higher
- Nova 4

## Installation

You can install the package into a Laravel app that uses Nova via composer:

```bash
composer require naif/toggle-switch-field
```

## Usage

Table column migration
```
$table->boolean('toggle')->nullable()->default(true);
```
Add the field to Nova Resource

```
  public function tools()
    {
    # You can set the toggle switch color by color code.
        return [
            new ToggleSwitchField::make('toggle')->color('#3AB95A'),
        ];
    }
```

## Screenshots

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


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


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


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


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


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



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


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


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


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


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


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


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


## Support:
naif@naif.io

https://naif.io

Bug Tracker:

https://github.com/naifalshaye/chatgpt-nova4/issues

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
PostgreSQL: GIST Indexes
Tags: apach, postgres, database
Published: 2023-07-13 13:39:12

PostgreSQL, a widely used open-source relational database management system. One of its notable capabilities is its ability to handle a wide array of types of indexes, including the Generalized Search Tree (GIST) index for enhancing query performance within PostgreSQL.

## GIST Indexes

GIST indexes are a specialized type which handle complex data types like geometric shapes, full-text search, and network addresses in PostgreSQL. They are structured as balanced search trees, capable of handling intricate data structures. GIST indexes relies on the dividing the data into overlapping rectangles or boxes which contain data points. These boxes are then organized in a hierarchical tree structure.

During query execution, PostgreSQL navigates through the GIST index tree to locate the relevant data at the root node and moves down the branches based on the query conditions enabling GIST indexes to effectively handle queries with efficiency and accuracy.

## How GIST indexes improve accuracy

GIST indexes play a crucial role in enhancing query performance by enabling PostgreSQL to swiftly locate the relevant data as now PostgreSQL can efficiently use the index to boost the process of identification of the required data instead of having to scan the entire table. GIST indexes can enhance the performance of full-text search queries, streamline network address queries, and optimize queries involving multi-dimensional data. By utilizing GIST indexes, PostgreSQL can efficiently handle these complex queries and deliver results more promptly.

## Conclusion

GIST indexes in PostgreSQL offer substantial benefits for optimizing query performance involving complex data types and multi-dimensional data. With their ability to divide data into overlapping rectangles or boxes and establish a hierarchical tree structure, GIST indexes enable PostgreSQL to efficiently locate the necessary data without the need for complete table scans. By leveraging GIST indexes, you can significantly enhance query performance, maximize performance gains and optimize your database operations.
Which player can play an MKV file?
Tags: mkv, mac, software, player
Published: 2023-07-13 13:39:09

The MKV format is one of the most popular containers for storing video, audio and subtitles. It is very famous for its versatility, but unfortunately some media players cannot play this format. To facilitate the work and user experience, you will need to install an additional [mkv players](https://mac.eltima.com/best-mkv-players/) on Mac. So let's talk about one of these programs, Elmedia Player.

Elmedia Video Player is a versatile application for Mac that can easily play multiple video formats, including MKV, without additional codecs or plugins.
Not only does it support all file types, but it also has a wide range of features and offers users full playback control. Elmedia Player features include playlists and bookmarks, video and audio settings, subtitle support, and more.
User scripts and why they are GREAT!
Tags: webdev, javascript, programming, typescript
Published: 2023-07-13 13:37:08


## Userscripts: Expanding Browser Functionality
Userscripts have become a fantastic invention for individuals who desire to utilize their web browsers for more than just checking emails. Extensions such as Tampermonkey or Greasemonkey empower users to create or install scripts that enhance the functionality of websites, web apps, and services. This simple yet effective approach enables users to augment their browsing experience in ways that are not typically supported by browser extensions.

However, it is crucial to be mindful of the potential risks associated with userscripts and to carefully consider the source and trustworthiness of the scripts one installs. While this powerful system provides ample opportunities, it is essential to exercise caution to prevent exploitation by third parties. Fortunately, certain security features mitigate some of these risks. For instance, userscripts do not function within the context of online banking applications, ensuring a higher level of safety.

Moreover, developers can specify precisely on which websites their scripts can be executed. Creating your own script is a straightforward process—simply click on "New script" in the browser extension, and you're good to go. However, for more experienced web developers who prefer languages like TypeScript and comprehensive IDEs like VSCode, writing code in the web editor provided by the browser extension may become cumbersome.

To simplify the process of setting up a development environment, I recently published a template on GitHub. This template not only offers a clean project structure but also provides tooling to generate the config header of the userscript and to compile an app icon into a base64 string, which can be attached to the config. By leveraging TypeScript, the template facilitates the development process and yields a finalized script ready for upload upon the completion of the build process.

I recently utilized this template to enhance the media library of the Second German Television by adding a "picture-in-picture" function to all videos. If this piques your interest, you can find the template on my GitHub account [here](https://github.com/JosunLP/UserScriptProjectTemplate). Feel free to explore and utilize it to enhance your browsing experience.

Best regards, and have a delightful Thursday!

Yours sincerely,
Josun
Disable anonymous bind for OpenLDAP in Centos7
Tags: linux, devops, cloud, ubuntu
Published: 2023-07-13 13:34:24

LDAP bind is a process which the client tries to authenticate themselves to the server. Depends on the server set up, such bind request sent from client may contain no credentials (i.e. anonymous bind).

In this guide, I will share how to configure the LDAP bind feature.

Concept
Before diving into the configuration, it’s better to know the types of LDAP bind.

Anonymous bind
Anonymous bind is that you present no distinguished name (you may treat it as an account name) and password in the bind request, the LDAP server will treat you as an anonymous. Usually, we will combine it with LDAP Access Control (ACL) to prevent anonymous from knowing some sensitive data if you decide to open part of the LDAP data to the public.

![Anonymous bind](https://joeho.xyz/static/9f45fa993cf2b1170cedbece161f8435/f21e7/anonymous-bind.png)


Unauthenticated bind
Unauthenticated bind allows you to present distinguished name and no password. By default, it’s disabled, as many applications don’t realize that they can still bind to LDAP server with incorrect password.

Authenticated bind
Authenticated bind requires the client to provide distinguished name and password.
![Authenticated bind](https://joeho.xyz/static/78cdac773420763569a43a7ac1498676/3e286/authenticated-bind.png)


Disable anonymous bind for OpenLDAP
By default, you can query LDAP data as an anonymous

```
ldapsearch -LLL -x -b "dc=abc,dc=local" '(uid=joe)'
```
![Anonymous query](https://joeho.xyz/static/0b37b65bc96438cfa38e1363ccbe9dac/3c024/anonymous-query.png)

Now, we will disable it. Create a disable_bind_anon.ldif with below content

```
dn: cn=config
changetype: modify
add: olcDisallows
olcDisallows: bind_anon
Apply the configuration
```

```
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f disable_bind_anon.ldif
```
If we try again, we can no longer query the user

```
ldapsearch -LLL -x -b "dc=abc,dc=local" '(uid=joe)'
```
![Disallowed anonymous query](https://joeho.xyz/static/f6eebf0341572a4516b7b0bd4dcbe56b/508ef/disallowed-anonymous-query.png)

Conclusion
In this guide, we discuss what bind is, types of bind and how to disable anonymous bind.

Original Post: [Disable anonymous bind for OpenLDAP in Centos7 | Joe Ho Blog](https://joeho.xyz/blog-posts/disable-anonymous-bind-for-openldap-in-centos7/)
A Pure CSS 3D Maze! - Chrome only
Tags: codepen, css, html, frontend
Published: 2023-07-13 12:55:17

🌎 100% Natural ingredients!
🚳 No images 
📵 No JavaScript 
👨‍💻 Just CSS - And a sprinkling of HTML

Like most CSS projects of mine, I had no idea whether this was possible before I started, and learnt some things along the way. I tried to keep the graphics a simple as possible to help with the animations and to fit with the retro vibe of the original 3D mazes from the 1990's. If you watch the YouTube about making it you can see the style to begin with was very different. I was thinking more like the style of Legend of Grimrock.
I'm happy with the familiar controls, the elevators (to make it more interesting), and the subtle depth shading... I'm not sure I've seen this done in 3D CSS Art before. 

Anyway I hope you like it :) 

💥 CHROME ONLY!! 

Firefox is okay but very slow.

Sorry Safari people 🥺
💀 I've tried but it's just not going to happen :(

The making of: 
📺 [youtu.be/Z0VHM4KcMFQ](https://youtu.be/Z0VHM4KcMFQ)

First person to send me a screen shot of the end screen wins...
Your time starts now!!! 🏁

P.S. If you have any ideas how to help with Safari then please let me know x



🔗 [linktr.ee/ivorjetski](https://linktr.ee/ivorjetski)

{% codepen https://codepen.io/ivorjetski/pen/poQpveN %}
Day 4: Polyfill for Object.keys()
Tags: day4, 100daysofcode, javascript
Published: 2023-07-13 12:30:00

Today, we'll create a polyfill for the Object.keys() method. The Object.keys() method returns an array of a given object's own enumerable property names. Our goal is to create a function called myKeys that will implement this behavior.

```javascript
// Test case
const obj = { name: "Bob", age: 1000 };
console.log(Object.myKeys(obj)); // Output: ["name", "age"]
```

## Plan

To solve this problem, we'll follow these steps:

- Implement the myKeys function to retrieve the enumerable property names of the object.
- Use a loop or a built-in method to iterate over the object's properties and collect the keys.
- Return an array containing the collected keys.
- Check if the Object.myKeys property exists.
- If it doesn't exist, create a new property called myKeys on Object and assign it a function.
Unleashing the Power of Indexing in PostgreSQL: Boosting Performance and Efficiency
Tags: apacheage, database, postgres
Published: 2023-07-13 12:24:51

As developers, we're always on the lookout for ways to optimize our applications and enhance database performance. In the realm of relational databases, PostgreSQL shines as a robust and versatile choice. One of its standout features is its powerful indexing system, which can dramatically improve query speed and overall efficiency. In this article, we will explore the world of indexing in PostgreSQL, uncovering its importance and discovering how different indexing techniques can unlock the full potential of your database, leading to lightning-fast data retrieval and a smoother user experience.

## B-tree Indexes
B-tree indexes are the default and most commonly used index type in PostgreSQL. They are well-suited for range queries, equality checks, and sorting operations. B-tree indexes organize data in a balanced tree structure, allowing for efficient data retrieval.

## Hash Indexes
Hash indexes in PostgreSQL are designed for fast equality checks.
They work efficiently for exact-match lookups, such as searching for a specific value in a column. Hash indexes are suitable for scenarios where the distribution of data is relatively uniform.

## Generalized Search Tree (GiST) Indexes
GiST indexes provide a flexible framework for indexing complex data types. They are capable of indexing various data types, including geometric data, full-text search, and arrays. GiST indexes support advanced search operations and enable efficient querying for specialized data structures.

## Generalized Inverted Index (GIN) Indexes
GIN indexes are specialized indexes used for full-text search and array data. They are optimized for complex data types and provide faster search capabilities compared to GiST indexes. GIN indexes create an inverted index that maps values to a list of row locations where the values occur.

## Block Range INdex (BRIN) Indexes
BRIN indexes are designed to optimize the retrieval of large tables. They divide the table into ranges based on a sorted column, improving performance by minimizing the amount of data that needs to be scanned. BRIN indexes are particularly useful for tables with a large number of rows.

## Partial Indexes
Partial indexes allow indexing a subset of rows in a table based on specified conditions. They are beneficial when a particular subset of data is frequently queried, improving query performance by reducing the size of the index

## Expression Indexes
Expression indexes are created based on expressions or computed values. They can index derived values, enabling efficient querying of complex calculations

These are just some of the indexing techniques available in PostgreSQL. Each index type has its own strengths and use cases, and understanding their characteristics can help developers optimize query performance and enhance the overall efficiency of their PostgreSQL databases.
Heroes of Code and Magic: VCMI game engine analysis
Tags: programming, coding, gamedev
Published: 2023-07-13 12:13:30

Sometimes you might wish to feel nostalgic and play your favorite old game, but certain things in such games may seem outdated. So, to breathe new life into an old project, some enthusiasts set the goal to recreate and improve its source code. We decided to use the PVS-Studio static analyzer and check how VCMI developers cope with this task.

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


Read [here](https://pvs-studio.com/en/blog/posts/cpp/1058/) and enjoy!