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.
May 7, 2024
In Rails, a partial is a reusable view template that allows you to encapsulate a portion of a view into a separate file. Partials are useful for organising and reusing code, especially when certain components or elements are repeated across multiple views within an application.
We can create a partial by creating a new file with a name that begins with an underscore (
And to render a partial within another view, use the
#rails
We can create a partial by creating a new file with a name that begins with an underscore (
_). For example, _sidebar.html.erb or _header.html.erb.And to render a partial within another view, use the
render method with the name of the partial file (without the underscore) as an argument. For example, <%= render 'sidebar' %> will render the _sidebar.html.erb partial within the current view.#rails
Syed Sibtain
System Analyst
May 2, 2024
The
#rails
rails routes command generates a comprehensive list of all routes defined in our Rails application, displaying the HTTP method, URL pattern, controller, and action associated with each route.#rails
Syed Sibtain
System Analyst
Apr 29, 2024
find your rails code smells by using a gem called
then run
it will print the flog score for the all files that has score more than or equal to 10. Generally we should make sure flog score should be less than 10.
Note: The more the flog score , the more pain the code is in.
#rails #code-smells #flog
flog . Flog finds the most tortured code in your codebase.
gem install flogthen run
flog app libit will print the flog score for the all files that has score more than or equal to 10. Generally we should make sure flog score should be less than 10.
Note: The more the flog score , the more pain the code is in.
#rails #code-smells #flog
Satya
Apr 26, 2024
In Ruby,
Example:
In this example,
#ruby
instance variables are variables that belong to a specific instance of a class. They are prefixed with the @ symbol and are accessible within the instance methods of that class. Instance variables allow objects to maintain state and store information unique to each instance.Example:
class Person
def initialize(name, age)
@name = name
@age = age
end
def say_intro
puts "Hello, my name is #{@name} and I am #{@age} years old"
end
end
# Create a new instance of Person
person1 = Person.new("John", 18)
# Call the say_intro method
person1.say_introIn this example,
@name is an instance variable of the Person class, representing the name of each Person object created. The initialize method is a constructor that sets the value of @name when a new Person object is created. The say_intro method uses the instance variable @name to give the intro of the person with their name and age when called.#ruby
Syed Sibtain
System Analyst
Apr 25, 2024
The
Example Explanation
#devops #docker
docker stats command is a powerful tool provided by Docker to monitor the resource usage of running containers. It provides a real-time stream of various metrics such as CPU usage, memory usage, network I/O, block I/O, and the number of processes (PIDs) running inside each container. This command is particularly useful for performance analysis and ensuring that containers are running within their resource limits.Example Explanation
docker stats db370fc6b784
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
db370fc6b784 minikube 43.70% 1.243GiB / 2.148GiB 57.87% 35.4MB / 414MB#devops #docker
Nisanth
Apr 24, 2024
We can check the default value for a given column using postgres query like this:
Same can be used for constraints like
#database #postgres #query
SELECT column_name, column_default
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';Same can be used for constraints like
is_nullable as following:
SELECT column_name, is_nullable
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';#database #postgres #query
Vaibhav Yadav
Senior System Analyst
Apr 23, 2024
active_record_doctor performs variety of health checks to identify and rectify common database issues like missing foreign key constraints, missing NON NULL constraints, missing presence validations, incorrect presence validations on boolean columns and many more. Ref: https://github.com/gregnavis/active_record_doctor#rails #database
Sujay
Apr 22, 2024
while integrating
#devops #sentry#gitlab
sentry with gitlab ip whitelisting needs to be done on gitlab server (self-hosted)#devops #sentry#gitlab
Sagar Ghorse
Apr 22, 2024
The
#devops #kubernetes
kubectl cordon NODE_NAME command is used in Kubernetes to mark a node as unschedulable, meaning no new pods will be scheduled onto that node. Existing pods on the node will continue to run unless explicitly terminated or moved.#devops #kubernetes
Soniya Rayabagi
Apr 22, 2024
Debugging Kubernetes pod on helm
Adding
#devops #kubernetes #helm
helm upgrade unleash-app-toggle . --debugAdding
--debug can provide more insight if the error persists, showing exactly what values are being passed to each template.#devops #kubernetes #helm
Nisanth
Showing 24 to 26 of 82 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