Fueling Curiosity, One Insight at a Time

At Codemancers, we believe every day is an opportunity to grow. This section is where our team shares bite-sized discoveries, technical breakthroughs and fascinating nuggets of wisdom we've stumbled upon in our work.

Apr 2, 2025
PostgreSQL's jsonb type stores structured JSON data efficiently. Unlike json, it's binary-optimized, supports indexing, and queries faster.
🔹 Why Use jsonb?
• Stores structured data in a single column.
• Faster queries (no reparsing needed).
• Supports indexing for quick lookups.
• Flexible schema—great for dynamic data.
• Allows key-value updates without rewriting the whole object.
• Removes duplicate keys automatically.
jsonb gives you NoSQL flexibility with SQL power! 🚀

#postgres
nived.hari
Nived Hari
System Analyst
Apr 1, 2025
Aliasing in Ruby
Aliasing in Ruby helps to eliminate code repetition by providing an alternative name for an existing method, allowing it to be called in different ways without duplicating the logic.
For example,


module QuestionsHelper
  def can_modify_question?(question)
    !question.survey.has_answers?
  end

  alias_method :can_edit_question?, :can_modify_question?
  alias_method :can_delete_question?, :can_modify_question?
end


#ruby #aliasing
puneeth.kumar
Puneeth kumar
System Analyst
Mar 28, 2025
Turbo provides a built-in way to show a loading state on form submission using the turbo_submits_with attribute! 🚀
Instead of manually handling the button's disabled state or adding a spinner, you can simply use:



<%= form.submit t("post.create"), 
  data: { turbo_submits_with: t('loading.saving') } %>


• When the form is submitted, Turbo automatically
replaces the button text with the value provided in turbo_submits_with (e.g., "Saving...").

• Button is also disabled until the request completes.
• Once the request completes, the button reverts to its original text.
No extra JavaScript needed! 🎉

This is a great way to enhance UX with minimal effort. #Rails #Turbo #TIL
nived.hari
Nived Hari
System Analyst
Mar 21, 2025
while using form.number_field in rails if we enter a floating point value eg: 23.45 then browser default validation kicks in syaing: Please enter a valid value. The two nearest valid values are 23 & 24 .
In order to allow the floating point value we can add form.number_field, step: "0.01" . Then we can add upto two decimal point vlaue.

#CU6U0R822 #form-tag-helper
satya
satya
Mar 21, 2025
to terminate google chrome sessions -> pkill -9 "Google Chrome" .
#terminate-session
satya
satya
Mar 20, 2025
Ruby Heredoc Syntax & Rails .squish method:
• Bad - Regular heredoc (<<) keeps all whitespace


query = <<SQL
    SELECT *
    FROM users
SQL
# Result: "    SELECT *\n    FROM users\n"


• Good - Squiggly heredoc (<<) removes leading whitespace

```
query = <<
SQL
SELECT *
FROM users
SQL
# Result: "SELECT \nFROM users\n"
```

• *
Best - Rails .squish removes all extra whitespace/newlines


query = <<~SQL.squish
    SELECT *
    FROM   users
    WHERE  active = true
SQL
# Result: "SELECT * FROM users WHERE active = true"


#ruby-heredoc #rails-squish
satya
satya
Mar 20, 2025
TimescaleDB

When working with time series data like stock prices, website traffic, or error logs, the volume of data grows rapidly over time. In traditional relational databases like PostgreSQL and SQL, this can lead to slower query performance as the dataset becomes larger.

One alternative is to use NoSQL databases, but they come with their own challenges, such as lack of strong ACID compliance, complex querying, and difficulties in handling structured relational data.

TimescaleDB, which is built on top of PostgreSQL, offers a powerful solution by introducing hypertables - a special type of table optimised for time series data. Hypertables enable faster read and write operations, automatic partitioning, and efficient data compression. Additionally, TimescaleDB provides advanced analytical functions, making it easier to perform complex queries for reporting, trend analysis, and forecasting. This makes it a great choice for applications that require efficient storage and analysis of large-scale time series data.

#databases #time_series_data #timescale_db #postgres
puneeth.kumar
Puneeth kumar
System Analyst
Mar 19, 2025
We can't use turbo frame for table rows, because html doesn't allow external tag like turbo frame inside the table.

The workaround this is to just have unique id for element you want to modify and use turbosteam to modify only that element.

#rubyonrails #turbo #turboframes #spa
aditya.vishwakarma
Aditya Vishwakarma
System Analyst
Mar 19, 2025
in ruby https://nil.to|nil.to_i => 0 & https://nil.to|nil.to_f => 0.0
#ruby, #nil-conversion
satya
satya
Mar 18, 2025
Steps to merge one repo into another

Step 1: Clone Repo1 locally


git clone  repo1
cd repo1


Step 2: Fetch all the branches and commits from Repo2


git remote add repo2 
git fetch repo2


Step 3: Create a branch


git checkout -b merge-repo2


Step 4: Merge keeping full history


git merge --allow-unrelated-histories repo2/main (Since the repositories have separate histories, this option allows Git to combine them, potentially requiring manual conflict resolution)


Step 5: Resolve Merge Conflicts


git add .
git commit -m "Resolved merge conflicts"


#git
sujay
sujay

Showing 2 to 5 of 77 results

Ready to Build Something Amazing?

Codemancers can bring your vision to life and help you achieve your goals