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 16, 2025
SEO Best Practices:
• Meta titles should be between 50–60 characters long (including spaces).
• Meta descriptions should be between 120–160 characters (including spaces).
• Use a single H1 tag per page, followed by a clear and consistent hierarchy of H2 and H3 tags across all pages.
• All images should have meaningful
• Ensure there are no broken links; tools like Screaming Frog can help detect them.
• Include canonical tags to avoid duplicate content issues.
• Add social meta tags (Open Graph, Twitter Cards) for better link previews.
• The site should have a robots.txt file and a sitemap.xml for better crawling and indexing.
#SEOBestPractices #SearchEngineOptimization
• Meta titles should be between 50–60 characters long (including spaces).
• Meta descriptions should be between 120–160 characters (including spaces).
• Use a single H1 tag per page, followed by a clear and consistent hierarchy of H2 and H3 tags across all pages.
• All images should have meaningful
alt
tags for accessibility and SEO.• Ensure there are no broken links; tools like Screaming Frog can help detect them.
• Include canonical tags to avoid duplicate content issues.
• Add social meta tags (Open Graph, Twitter Cards) for better link previews.
• The site should have a robots.txt file and a sitemap.xml for better crawling and indexing.
#SEOBestPractices #SearchEngineOptimization
Mohammad hussain
System Analyst
Apr 14, 2025
In Rails,
When we define a
Example:
This ensures a consistent ordering across the app without needing to manually add
It's especially useful when displaying comments, messages, tasks, or anything that should appear in the order they were created.
Caution:
In that case, we would need to call
#rubyonrails
default_scope
is a way to automatically apply a query condition to every query for a model.When we define a
default_scope
, it always gets added unless we manually remove it.Example:
default_scope { order(created_at: :asc) }
This ensures a consistent ordering across the app without needing to manually add
.order(created_at: :asc)
every time.It's especially useful when displaying comments, messages, tasks, or anything that should appear in the order they were created.
Caution:
default_scope
can sometimes be annoying if we want a different order temporarily.In that case, we would need to call
.unscope(:order)
to remove it manually.#rubyonrails
Syed Sibtain
System Analyst
Apr 11, 2025
Instead of manually checking if a key exists in a hash, you can just say:
Now whenever you do:
Ruby will assume
#ruby
counts = Hash.new(0)
Now whenever you do:
counts[:apple] += 1
Ruby will assume
counts[:apple]
starts at 0
, so no errors — just clean, readable code.#ruby
Nived Hari
System Analyst
Apr 7, 2025
Traits are reusable groups of attributes that we can apply to factories conditionally.
They help avoid duplication and let us customise factories based on different test scenarios.
We can define a trait inside a factory block using the
And then we can use them in our specs. And traits can override any attribute defined in the factory
#CU6U0R822 #rspec
They help avoid duplication and let us customise factories based on different test scenarios.
We can define a trait inside a factory block using the
trait
keyword
FactoryBot.define do
factory :user do
name { "John Doe" }
trait :admin do
role { "admin" }
end
trait :with_profile_picture do
after(:build) do |user|
user.profile_picture.attach(
io: File.open(Rails.root.join('spec/fixtures/files/test.jpg')),
filename: 'test.jpg',
content_type: 'image/jpeg'
)
end
end
end
end
And then we can use them in our specs. And traits can override any attribute defined in the factory
create(:user, :with_profile_picture)
create(:user, :admin, :with_profile_picture)
#CU6U0R822 #rspec
Syed Sibtain
System Analyst
Apr 2, 2025
define_singleton_method
dynamically adds a method to a single object instance without modifying the class itself. This is useful when you need custom behaviour for an individual object at runtime.It only modifies the behaviour of a single object in memory at runtime. It does not persist any changes to the database or schema.
user = User.new(name: "Sibtain")
user.define_singleton_method(:greet) do
"Hello, my name is #{name}!"
end
puts user.greet # => "Hello, my name is Sibtain"
#CU6U0R822
Syed Sibtain
System Analyst
Apr 2, 2025
PostgreSQL's
🔹 Why Use
• 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
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
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,
#ruby #aliasing
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
System Analyst
Mar 28, 2025
Turbo provides a built-in way to show a loading state on form submission using the
Instead of manually handling the button's disabled state or adding a spinner, you can simply use:
• When the form is submitted, Turbo automatically
replaces the button text with the value provided in
• 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
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
System Analyst
Mar 21, 2025
while using
In order to allow the floating point value we can add
#CU6U0R822 #form-tag-helper
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
Mar 21, 2025
to terminate google chrome sessions ->
#terminate-session
pkill -9 "Google Chrome"
.#terminate-session
satya
Showing 1 to 5 of 77 results
Ready to Build Something Amazing?
Codemancers can bring your vision to life and help you achieve your goals
- Address
2nd Floor, Zee Plaza,
No. 1678, 27th Main Rd,
Sector 2, HSR Layout,
Bengaluru, Karnataka 560102 - Contact
hello@codemancers.com
+91-9731601276