← Înapoi la Urmăritori

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 44
  1. Rate limiting examples 🙌🏼 With Rails 8 upgrade, developers can now leverage built-in rate-limiting controls directly within their controllers 🚀 Advantages Prevents Abuse: Rate limiting deters spamming, brute-force attacks, and abusive behavior by controll…

  2. Clear development log while start server 🗑 Do you find yourself manually clearing your Rails development logs often?

  3. Passing argument with Array#first and Array#last Methods Did you know that you can pass an argument to the Array#first and Array#last methods to return a specific number of elements from the beginning or end of the array?

  4. A better way to Convert a URL Query String to a Hash ✨ In Ruby on Rails, you might need to work with URL query strings when building web applications that interact with external APIs or handle user input.

  5. Validate keys of hash using `assert_valid_keys` 🚧 Have you heard of the assert_valid_keys method for the Hash class in Rails?

  6. Using `pluck` instead of `all` Instead of using the all method, which loads all records into memory, use the pluck method to retrieve specific columns from the database.

  7. Use render with `respond_to` You can use the render method to display content in a different format such as JSON or XML.

  8. Difference between `to_s` and `to_str` 🙌🏼 Let’s take an example of to_s and to_str here.

  9. Numerical validation using `validates_comparison_of` 🙌🏼 Do you know you can use validates_comparison_of with Rails 7.0 that provides a way to easily validate comparisons with another value, proc, or attribute?

  10. Usage of invert_where for inverting entire where clause 🙌🏼 With Rails 7.0, you can use invert_where to invert an entire where clause instead of manually applying conditions 💣 Reference - Rails PR #40249 Code snippet 📌 # Version: Rails 7.0 class User scope…

  11. Usage of authenticate_by for preventing timing-based enum attacks ⏳ 🙌🏼 Add authenticate_by when using has_secure_password. authenticate_by is intended to replace code like the following, which returns early when a user with a matching email is not found:…

  12. Freezing string to improve performance 🙌🏼 Advantage - If you freeze string object, it’ll not allocate new memory and it improves app performance by saving time for garbage collection 🔥 Reference - Ruby Optimization with One Magic Comment Code snippet 📌 def

  13. Always use is_a?

  14. Use of xxx_changed?

  15. Multiple each_xxx method on string 🙌🏼 Do you know there are multiple each_xxx methods available on String?

  16. values_at method to retrieve multiple non-sequential values 🙌🏼 Do you know you can use values_at to retrieve multiple non-sequential values from array or hash?

  17. Using underscore to make large number more readable ⚡️ Do you know we can use underscore to make large number more readable in ruby?

  18. Numerical comparison using `range` and `between` 😊 Do you know we can use range or between to do numerical comparison in ruby?

  19. Different ways to call a method in Ruby!

  20. Customize default getter/setter methods(attr_accessor) ✌🏼 Wanted to customize default getter/setter methods available in ruby called attr_accessor?

  21. Recently, the Indian govt announced vaccination for 18-45 age group from 1st May ✨ Anyone who wants to vaccinate in this age group can visit official website or install Arogya Setu App from Google Play to book a slot for vaccination.

  22. Symbols can best be described as identities.

  23. Use customized starting index with each_with_index while using Enumerator 🙌🏼 In your Ruby on Rails project, you can use each.with_index(starting-index) instead of each_with_index if you wanted to customize starting index of enumerator(Array) Code snippet 📌

  24. Ruby 3.0 Released ⚡️

    𝗥𝘂𝗯𝘆 𝟯.𝟬 is released and here are list of improvements ⚡️ 📌 In some benchmarks Ruby3.0 is three times faster than Ruby2.0 📌 Lot many performance improvements in Method Based Just-in-Time Compiler 📌 With Ractor, along with Async Fiber, Ruby will be a real…

  25. Easy way to clean Sidekiq Jobs Cheat-Sheet 💣 Easy way to clean Sidekiq Jobs Cheat-Sheet 💣 Code snippet 📌 ❯ require 'sidekiq/api' # Clear retry set ❯ Sidekiq::RetrySet.new.clear # Clear scheduled jobs ❯ Sidekiq::ScheduledSet.new.clear # Clear 'Dead' jobs ❯…

  26. Image from Unsplash There are certain characteristics that differentiate great developers from good developers.

  27. Array Operations 🗄

    Array operations in Ruby 🗄 Easy way to get the intersection, union, and subset of arrays in Ruby 👇🏼 Code snippet 📌 x = [1, 1, 2, 4] y = [1, 2, 2, 2] # intersection x & y # => [1, 2] # union x | y # => [1, 2, 4] # difference x - y # => [4]

  28. Handy numerical methods 🧮

    Handy numerical methods 🔖 Handy numerical methods you can use on daily basis in comparison statements in Ruby 🧮 Code snippet 📌 ❯ num = 10 ❯ num.even?

  29. Hash Deep Merge 🔄

    Difference between `merge` & `deep_merge` 🤔 Use deep_merge instead of merge if you want to merge two hash objects recursively 🌟 Code snippet 📌 ❯ person1 = { name: 'Rishi', address: { area: 'Baner' } } ❯ person2 = { name: 'Rishi', address: { city: 'Pune' }…

  30. Image from unsplash.com I’ve been nominated in the 2020 #Noonies, Hacker Noon’s annual awards!

  31. List all TODO tasks 🔖

    List all TODO tasks from Ruby on Rails Project 🔖 To get all # TODO tasks from your Ruby on Rails project you can use rake notes It’ll search for comments beginning with a specific keyword and also give filename and line 📋 Code snippet 📌 # list down all co…

  32. Better way to write website(URL) Validation ✨ Use URI::regexp(%w(http https)) in your Ruby on Rails model, to increase readability of website(URL) validation.

  33. Like operator in MongoDB 🧩

    Like operator in MongoDB 🧩 A good way to use operator LIKE in Ruby on Rails while using MongoDB 💡 Code snippet 📌 # app/models/mongoid/base_model.rb module Mongoid module BaseModel extend ActiveSupport::Concern module ClassMethods def _search_(k, v) if k &&

  34. Array Partition ⛓

    Better way to split an array using Partition ⛓ Imagine you could, in one line, split an array into two arrays based on a condition 🤔 Now stop imagining, you can do exactly that with partition 🤩 Code snippet 📌 # ok: let's split an array to an odd array and…

  35. Safe Navigation Operator (&.)

    Safe Navigation Operator (&.)

  36. Better way to write Email Validation ✨ Use URI::MailTo::EMAIL_REGEXP in your Ruby on Rails model, to increase readability of email validation.

  37. Convert Array of Hashes to Hash!

  38. Rails console from one of my Rails Project It´s better to wait for a productive programmer to become available than it is to wait for the first available programmer to become productive. — Steve McConnell What is ~/.irbrc file?

  39. Image from unsplash.com In last few years, social media has made the world a more connected place.

  40. Image from unsplash.com After a few years of continuous development, your rails application becomes larger and it’s good practice to do some cleanup.

  41. Credits: Google Images whenever gem is used when there’s need of run specific job at particular intervals, say - - send invoices - send daily reports - send reminder notifications etc..

  42. Credits: Google Images Validations They are used to ensure that only valid data is saved into your database. i.e. check user email presence, check email uniqueness etc.

  43. Workspace is used to organize your apps into tasks. i.e. you may keep your chat applications in one workspace and coding ide into other workspace.

  44. Hello!