Latest Blog

Leetcode 767 Reorganize String
September 28, 2024 | No Comments

You can solve this problem by using a max-heap (priority queue) to always try to place the most frequent character at each position, ensuring that no two adjacent characters are the same. Here’s how you can implement it: Here’s the complete solution: Explanation: Time Complexity: Example:

Read More

How to solve “Failed to connect to port after 215 ms: Couldn’t connect to server” with a Flask Backend
February 17, 2024 | No Comments

Problem Statement I have my Flask backend running on one server, and I use another computer, in the same network to send a post request to the Flask backend, I got an error like “Failed to connect to <ip> port <port> after 215 ms: Couldn’t connect to server” error. Nothing shows up in flask log. […]

Read More

How to start ssh-agent on Ubuntu
February 17, 2024 | No Comments

On Ubuntu, we can use this command It will output something like After this, we can use ssh-add Explain “eval $(ssh-agent -s)” The command eval $(ssh-agent -s) is a convenient way to start the SSH agent and set up the necessary environment variables in the current shell session. Here’s a breakdown of what each part […]

Read More

How to install helm on Mac OS
January 6, 2024 | No Comments

The easiest way is to use brew After this, to verify helm is installed successfully

Read More

Examples of Interacting with Cassandra or ScyllaDB using Python
January 2, 2024 | No Comments

To interact with Cassandra or ScyllaDB using Python, you can use the cassandra-driver library, which works for both databases. The following example demonstrates how to connect to a Cassandra or ScyllaDB cluster, create a keyspace, create a table, and perform basic CRUD (Create, Read, Update, Delete) operations.

Read More

I have a column in a SQLite table , it is a json array, how can I select unique elements in the column?
December 25, 2023 | No Comments

The values of the column like “[‘a’, ‘b’]”, “[‘a’]”, “[‘c’, ‘a’]” json_each(json_column): This function is used to expand the JSON array into a set of key-value pairs, where the key is the index or key within the array, and the value is the corresponding element. So that for each record of you_table, it will expand […]

Read More

How to handle primary key conflict in Sqlite using Python
December 25, 2023 | No Comments

Here is an example showing

Read More

Check if a file exists using Python
December 25, 2023 | No Comments

Using os.path Using pathlib (Python 3.4 or later)

Read More

in SQLite, is list or array type available?
December 25, 2023 | No Comments

SQLite does NOT have a built-in array data type. You can store a serialized representation of your array in a TEXT column. This could be a comma-separated list, a JSON array, or any other format that suits your needs. comma-separated list JSON array

Read More

Is Enum available in Sqlite?
December 25, 2023 | No Comments

SQLite does NOT have a native ENUM data type like some other database systems such as MySQL. However, you can simulate enums in SQLite using a combination of a CHECK constraint and a TEXT or INTEGER column. Here’s an example using a TEXT column: If you need to add new values to your “enum” or […]

Read More