TILs - 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.

Published
Author
user-image
Ayush Srivastava
System Analyst
Lambda
A lambda is a way to define a block & its parameters with some special syntax.
You can save this lambda into a variable for later use.
The syntax for defining a Ruby lambda looks like this:

Ruby

say_something = -> { puts "This is a lambda" }

Published
Author
user-image
Ayush Srivastava
System Analyst
Scopes
Scopes are custom queries that you define inside your Rails models with the scope method.
Every scope takes two arguments:
1. A name, which you use to call this scope in your code.
2. A lambda, which implements the query.
It looks like this:


Ruby

class Fruit < ApplicationRecord  
   scope :with_juice, -> { where("juice > 0") }
end


Published
Author
user-image
Satya
RSpec double is a method provided by the RSpec library for creating test doubles, also known as mocks. Test doubles are objects that stand in for real objects in your system during tests.
Published
Author
user-image
Satya
if we are using tailwindcss-rails gem we don't need cssbundling-rails gem because tailwindcss-rails gem is a standalone version of Tailwind CSS that integrates with rails asset pipeline. It's a simpler and more direct alternative for rails applications because it doesn't require Node.js at all.
Published
Author
user-image
Ayush Srivastava
System Analyst
.abs method in Ruby is used to return the absolute value of a number. The absolute value of a number is its distance from zero, regardless of direction. In other words, it's the number without its sign.
Here's an example:

Ruby

num = -10
puts num.abs # Outputs: 10


In this example, num.abs returns 10 because the absolute value of -10 is 10.
Similarly, for a positive number:

Code

num = 10
puts num.abs # Outputs: 10


Published
Author
user-image
Syed Sibtain
System Analyst
How to drop DB and add new database dump in Mongo db.
1. Open terminal and enter mongo
2. Enter show dbs to list all the databases
3. Enter use and select the database.
4. Enter db and this will show the selected database (optional)
5. Enter db.dropDatabase() and it will drop the database and show the following response { "dropped" : "", "ok" : 1 }

To add a new data dump, use the below command.
1. mongorestore --db
Published
Author
user-image
Mahrukh Mir
Gestalt Principles:
It explains how humans perceive visual aspects and how the human brain creates order from chaos. The human brain organizes and simplifies complicated visuals composed of numerous components into a single entire system. Humans will look for patterns and structure to create an image rather than seeing distinct, separate components.

Some Gestalt Principles are as follows:

1. Similarity:
when two elements appear to be similar, we group them together. We also prefer to believe they serve the same purpose.
Elements with similar shapes, sizes, color's, or orientations are believed to be related.

2. Proximity:
The elements that are close together appear to be more linked than things that are farther apart.

3. Closure:
When there are gaps or missing portions, our brain fills in the gaps to perceive a full shape or entity.

4. Focal point:
Visual elements that stand out will catch and hold the viewer's attention right away.

5. Invariance:
People can distinguish objects regardless of their shape, rotation, or scale.

6. Continuity:
Elements placed on a line or curve appear to be more connected than elements not arranged on a line or curve.
Published
Author
user-image
Soniya Rayabagi
We can rename the current local Git branch name by,
• Switch to the main via the command git checkout master.
• Enter the following command to rename a Git branch git branch -m old-name new-name .
• To ensure that the rename was successful, retrieve the current status of the branch using the git branch -a.
Published
Author
user-image
Soniya Rayabagi
We can Rename the current local Git branch name by,
• Switch to the main via the command git checkout master.
• Enter the following command to rename a Git branch git branch -m old-name new-name .
• To ensure that the rename was successful, retrieve the current status of the branch using the git branch -a.
Published
Author
user-image
Mainak
If we import a server component inside a client component, it will be treated as a client component but if we pass a server component to a client component as a child prop, it will not be converted to the client component and will be treated as a server component. This gives more granular control on what to show at what component. Composable child components will still be treated as client components as it is not passed as a child to the client component.

Showing page 38 of 83

Ready to Build Something Amazing?

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