Posts

Showing posts from February, 2023

diferent data structure sin ruby:: good blog withgithub link code :: very very good link here

 https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby

ancestors in rails

 https://evanahouse.medium.com/inheritance-in-ruby-the-ancestors-chain-65c813aea71#:~:text=ancestors%20is%20a%20class%20method,hierarchy%20of%20increasing%20parent%20rank.&text=When%20the%20.,respective%20ancestors%20chain%20is%20returned.

Method Lookup in Rails

Method Lookup in Rails :: Link ::   https://www.honeybadger.io/blog/ruby-method-lookup/ The process (or path) Ruby follows in figuring this out is what we call  method lookup . Ruby has to find where the method was created so that it can call it. It has to search in the following places to ensure it calls the right method: ...................................................... 1. Singleton methods 2. Methods in mixed-in modules 3. Instance methods 4. Parent class methods or modules 5. Object, Kernel, and BasicObject ...................................................... Singleton methods: Ruby provides a way for an object to define its own methods; these methods are only available to that object and cannot be accessed by an instance of the object. Methods in mixed-in modules: Modules can be mixed into a class using  prepend ,  include , or  extend . When this happens, the class has access to the methods defined in the modules, and Ruby goes into the modules...

what are the structs in rails

 https://www.rubyguides.com/2017/06/ruby-struct-and-openstruct/#:~:text=What%20is%20a%20Struct%20in,coordinates%20(%20x%20%26%20y%20).

What is object and class in rails

 https://ruby-doc.org/docs/ruby-doc-bundle/Tutorial/part_01/objects.html

docker in rails

 https://www.educative.io/blog/docker-with-rails

Oop

 https://www.google.com/amp/s/www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP%3famp=1

Objects in ruby

 https://zetcode.com/lang/rubytutorial/objects/

how to make rails app with and without ruby on rails app

 https://shopify.engineering/building-web-app-ruby-rails

crud

 https://medium.com/@nancydo7/ruby-on-rails-crud-tutorial-899117710c7a

Cron Job

 cron_job.txt Link ::  https://www.hostinger.in/tutorials/cron-job cron job special strings  :  Cron Job Special Strings @hourly. The job will run once an hour. @daily or @midnight. These strings will run the task every day at midnight. @weekly. Use this to run jobs once a week at midnight on Sunday. @monthly. This special string runs a command once on the first day of every month. @yearly. ... @reboot. cron jobs are great for computers that work 24/7, such as servers.  Like any other program, cron has limitations you should consider before using it:  The shortest interval between jobs is 60 seconds. With cron, you won’t be able to repeat a job every 59 seconds or less.  Centralized on one computer. Cron jobs can’t be distributed to multiple computers on a network. So if the computer running cron crashes, the scheduled tasks won’t be executed, and the missed jobs will only be able to be run manually.  No auto-retry mechanism. Cron is designed to r...

Rails app flow

 https://www.thoughtco.com/rails-application-flow-2908211

Sidekiq in rails

 https://tudip.com/blog-post/how-to-use-sidekiq-in-rails-for-background-processing/

Cron job rails with whenever gem

 https://dev.to/risafj/cron-jobs-in-rails-a-simple-guide-to-actually-using-the-whenever-gem-now-with-tasks-2omi

Background jobs in rails

 https://davidmles.medium.com/a-quick-look-at-background-jobs-in-ruby-43e6176aeee5

deploy app with passenger and nginx

 https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04

deployment of rails app using heroku

 https://www.codecademy.com/article/deploy-rails-to-heroku

deployment of rails application using heroku

deployment of rails application using  heroku using 7.x  https://devcenter.heroku.com/articles/getting-started-with-rails7 using 6.x https://devcenter.heroku.com/articles/getting-started-with-rails6 using 5.x  https://devcenter.heroku.com/articles/getting-started-with-rails5

deployment of rails application using capistrano

 https://www.jetbrains.com/help/ruby/capistrano.html

Deployment of rails application at linux

 https://www.ralfebert.com/tutorials/rails-deployment/

Deployment of rails application at amazon

rails gems

 https://www.moesif.com/blog/api-guide/development/api-resources-for-ruby-developers/

Full stack developer Questions and Answers

 https://www.springboard.com/blog/software-engineering/full-stack-developer-interview-questions/

Request Response Cycle in Rails

  Link ::  https://www.nopio.com/blog/ruby-rails-popular-job-interview-questions/ 7. Explain request/response cycle. Here is the request/response cycle: Let’s explain request/response flow in Rails: The user opens their browser and enters a URL. The browser sends a GET request to the URL. The request hits the Rails Router (config/routes.rb). The router receives the request information from the web server and based on that, decides which controller action should be called. If a request matches to any path in the routes file, the corresponding controller and action will be called. The controller receives the parameters from the router and passes them into appropriate model methods. The model queries a database to fetch data. The Database returns stored data to the model. The model manages the data and returns it to the controller. The controller feeds the received data to the view. The view renders the page as HTML, prepares a response and forwards it to the controller. The cont...

interview coding questions

1.  what is the problem in the below code  authors = Author.all authors.each do |author| puts author.name author.books.each do |book| puts book.name end end my answer :  [11:25 AM] dwijendra (Guest) authors = Author.all books = authors.map(&:books).flatten authors.each do |author| puts author.name author.books.each do |book| puts book.name end end ​ [11:26 AM] dwijendra (Guest) authors = Author.includes(books:[:author]).all books = authors.map(&:books).flatten authors.each do |author| puts author.name author.books.each do |book| puts book.name end end 2.  How to get the 1000 output id's ::   user_permissions id user_id permisssion_id 1 001 1000 2 001 1001 3 002 1000 my answer ::  [11:33 AM] dwijendra (Guest) user_id.map(&:permission_id).count ​ [11:35 AM] dwijendra (Guest) user_id.select(&:permiss...

Interview questions toptal coding imp

 https://www.toptal.com/ruby/interview-questions

SOLID principle in rails

 https://www.honeybadger.io/blog/ruby-solid-design-principles/#:~:text=The%20Liskov%20substitution%20principle%20states,that%20it%20can%20be%20extended.

How intializer do work in backend in rails

Observer examples in rails

 https://borgs.cybrilla.com/tils/observers-in-rails/#:~:text=Observer%20pattern%20is%20used%20when,on%20his%2Fher%20activity%20status.

TEST YOUR CUSTOM ROUTE IN RAILS

 https://levelup.gitconnected.com/how-to-write-custom-routes-in-rails-872df2ca4d39

RAKE AND ADD CUSTOM RAKE TASKS

 https://medium.com/geekculture/writing-custom-rake-tasks-f656f43336cc

rake tasks and rake

 https://www.rubyguides.com/2019/02/ruby-rake/ https://www.seancdavis.com/posts/how-to-write-a-custom-rake-task/

Helper methods in rails

 https://www.rubyguides.com/2020/01/rails-helpers/

Rails sessions

 https://www.javatpoint.com/ruby-on-rails-session

Garbe collection how it works

 https://www.google.com/amp/s/stackify.com/how-does-ruby-garbage-collection-work-a-simple-tutorial/amp/

toptal coding questions

 https://www.toptal.com/ruby-on-rails/interview-questions

interview questions

 # remove duplicates and nil array = [1, 1, 2, 3, nil] array_duplicate = array.compact array_nil = array.reject? {|c| c.empty} # find items matching string "Si" array = ['Simple', 'Ample', 'Sit'] def check_array     if array end  # find users where the score is more than 100 array = [   { name: 'Dan', score: 110 },   { name: 'Mike', score: 57 },   { name: 'Jill', score: 120 } ] #sum of values hash = {"a"=>10, "b"=>20, "c"=>30} hash1 = hash.merge(hash[0]).merge([]hash1]).merge([hash[2]) sum_of_values = hash1.inject[sum+] # find common items from below arrays array1 = [1, 2, 3 ] array2 = [0, 5, 2] print array3 = array1 & array2 # use below methods with proper arguments def func1(*input)   puts input end def func2(**input)   puts input end # for example def math(x, y) end math(2,3) # use metaprogramming to refactor these methods def admin?   role ==  'admin' end def marketer?   rol...

Method overriding example and super

 https://medium.com/@mattrice12/method-overriding-and-super-f19cf7274c4

Sti

 https://medium.com/@GeneHFang/single-table-inheritance-in-rails-6-emulating-oop-principles-in-relational-databases-be60c84e0126

Single table inheritance and polymorphic associations very very good example

 https://www.google.com/amp/s/www.freecodecamp.org/news/single-table-inheritance-vs-polymorphic-associations-in-rails-af3a07a204f2/amp/

Delegate .ethod with example in rails

 https://medium.com/@pk60905/using-delegate-in-rails-527332da7f96

interview == what is the problem is in this code

 class CommentsController < ApplicationController   def users_comments   params[:username] = "talha"     posts = Post.all     comments = posts.map(&:comments).flatten     @user_comments = comments.select do |comment|       comment.author.username == params[:username]     end   end end

Interview link of meta programming

 https://engineering.entelo.com/responsible-use-of-ruby-metaprogramming-5561701887fb

question intr

 Input - [1, 1, 2, 3, 3, 3, 4, 5] output - { 1 => 2, 2 => 1, 3 => 3, 4 => 1, 5=> 1}

Sti in rails :: Difference between single table inheritance and polymorphic association

 https://www.netguru.com/blog/single-table-inheritance-rails

api program methods in rails

 class Api::V1::FactsController < ApplicationController before_action :find_fact,only: [:show, :update, :destroy] def index  @facts = Fact.all render json: @facts end  def show render json: @fact end  def create @fact = Fact.new(fact_params) if @fact.save  render json: @fact else  render error: {error: 'Unable to create fact'},status: 400  end end  def update if @fact  @fact.update(fact_params) render json: {message: 'Fact successfully updated.'},status: 200 else render json: {error: 'Unable to update fact.' },status: 400 end def destroy if @fact  @fact.destroy render json: {message: 'Facts successfully destroyed'},status: 200 else render json: {error: 'Unable to delete fact'},status:400 end end private  def fact_params params.require(:fact).permit(:fact, :likes, :user_id) end def find_fact @fact = Fact.find(params[:id]) end  end