1️⃣ Reverse a String str = "Sadhna" def reverse_str ( str ) reversed = "" str.each_char { | chr | reversed = chr + reversed } reversed end puts reverse_str(str) 2️⃣ Check if String is Palindrome def palindrome? ( str ) reversed = "" str.each_char { | chr | reversed = chr + reversed } str == reversed end puts palindrome?( "madam" ) # true puts palindrome?( "ruby" ) # false 3️⃣ Count Vowels in a String def count_vowels ( str ) vowels = "aeiouAEIOU" count = 0 str.each_char { | ch | count += 1 if vowels. include ?(ch) } count end puts count_vowels( "Sadhna" ) 4️⃣ Reverse an Array def reverse_array(arr) reversed = [] arr.each_index do |i| reversed << arr[arr.length - 1 - i] end reversed end puts reverse_array([1, 2, 3, 4]).inspect 5️⃣ Find Maximum in Array def max_element ( arr ) max = arr[ 0 ] arr.each { | el | max = el if el > max } max ...
Posts
- Get link
- X
- Other Apps
🔹 General Rails Project Setup Questions What does the command rails new neo_app do? Creates a new Rails application named neo_app with a default folder structure, Gemfile, and configuration files. What is the difference between rails new appname and rails new . ? rails new appname creates a new folder. rails new . initializes a Rails project in the current directory. What is the purpose of the Gemfile generated by Rails? Defines Ruby gems required for the project. Managed via bundle install . 🔹 Database Option ( -d postgresql ) What does -d postgresql mean in rails new ? Configures Rails to use PostgreSQL as the database instead of default SQLite. How do you configure database credentials in Rails? Inside config/database.yml using environment variables (or Rails credentials). How do you create the database after setup? rails db:create What are the advantages of PostgreSQL over SQLite in Rails? Better performance ...
- Get link
- X
- Other Apps
Q1: Tell me about a project you’re most proud of. What was your role and impact? Answer (Simple): “One project I’m really proud of is working on a finance project with NeoVerify . Neo is a company that helps auto lenders in the US make better loan decisions . They do this by using the lender’s own past loan data and applying AI and machine learning to build a custom scoring model . My role was to work on the backend side, where I helped in building APIs, designing the database, and supporting the scoring logic . The goal was to make the loan approval process faster and reduce manual work. The impact was big — lenders were able to automate most of their underwriting process . This saved them a lot of time and cost , helped their sales team close loans faster , and at the same time reduced risk because decisions were more data-driven. I felt proud because my contribution helped create a system that was smarter, faster, and safer for the client’s business.” Q2: How do you handle ...
Ruby on Rails MVC
- Get link
- X
- Other Apps
Ruby on Rails MVC Like most of the other frameworks, Rails is also based on MVC pattern. It basically works as following: Requests first come to the controller, controller finds an appropriate view and interacts with model which in turn interacts with database and send response to controller. Then controller gives the output to the view based on the response. Model The models are classes in Rails. They interact with database, store data, handles validation, transaction, etc. This subsystem is implemented in ActiveRecord library. This library provides an interface between database tables and Ruby program code that manipulates database records. Ruby method names are automatically generated from database tables field names. View View represent data in a particular format in an application for the users. It handles HTML, CSS, JavaScript and XML in an application. They do what controller tells them. This subsystem is implemented in ActionView library. This libr...
Download database from aws
- Get link
- X
- Other Apps
default: &default adapter: mysql2 encoding: utf8 pool: 5 username: scadmin password: 4w3som3C4t! host: stg-09-29.cqilo8w4uzxl.us-west-1.rds.amazonaws.com port: 3306 # socket: /var/run/mysqld/mysqld.sock development: <<: *default database: syncrew_development test: <<: *default database: syncrew_test production: <<: *default database: syncrew_production pool: 35 mysqldump -u scadmin -p -h stg-09-29.cqilo8w4uzxl.us-west-1.rds.amazonaws.com syncrew_production > latesttt_sql_20102021.sql mysqldump -u database_name -p -h host database_name > latesttt_sql_20102021.sql Download it from browser http://3.101.121.6/latesttt_sql_20102021.sql
RVM and Gemset
- Get link
- X
- Other Apps
GemSet- A gemset is just a container you can use to keep gems separate from each other. Creating a gemset per project allows you to change gems (and gem versions) for one project without breaking all your other projects. Each project need only worry about its own gems. RVM- RVM is a command-line tool for managing multiple ruby versions and also uses a separate gemset for each rails app. RVM is a command-line tool that allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. [ source: https://rvm.io/ (official rvm website) ] Ruby Version Manager, often abbreviated as RVM, is a software platform for Unix-like operating systems designed to manage multiple installations of Ruby on the same device. The entire ruby environment including the Ruby interpreter installed RubyGems, and documentation is partitioned. [ source: Wikipedia ] Why we need RVM Let’s see an example. S u ppose, you have ...