Skip to main content

Posts

Showing posts from 2016

Ruby On Rails with Nginx With Passenger Deployment?

Ruby On Rails  with Nginx With Passenger Deployment? Ruby Installation #sudo apt-get update #sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev #wget http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz #tar -xzvf ruby-2.2.3.tar.gz #cd ruby-2.2.3/ #./configure #make #sudo make install #ruby -v Rails Installation Since Rails ships with so many dependencies these days, we're going to need to install a Javascript runtime like NodeJS. This lets you use Coffeescript and the Asset Pipeline in Rails which combines and minifies your javascript to provide a faster production environment. To install NodeJS, we're going to add it using a PPA repository: sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs gem install rails -v 4.2.4 MongoDB I...

Sending Mobile SMS in Ruby on Rails using twilio

Sending Mobile SMS in Ruby on Rails using twilio? gem install twilio-ruby In Controller U need to add the  require 'twilio-ruby' @account_sid = 'AC3ddc5567a441ea2fdf0a460452599aa6'  @auth_token = '9aefac893c9c9214770046ecb796d6c8' @client = Twilio::REST::Client.new(@account_sid, @auth_token) p @client.account @client.account.messages.create(from: '+12019044303', to: '+919538947694',body: 'Hello koteshwarrao welcome to my blog') Notes: From number is nothing but twillo number To Number is from whom u need to send the message Use Only Live credentials only @account_sid is twilio account id @auth_token is twilio auth token Before Sending any message to mobile the mobile number need to be verified to twilio account.

PayUMoney Integration in Ruby on Rails

PayUMoney Integration in Ruby on Rails Generating Cheksum in Payu    Hash or Checksum = sha512(key|txnid|amount|productinfo|firstname|email|u df1|udf2|udf3|udf4|udf5||||||salt) Controller Code Will be def payumoney   @key = "gtKFFx"   @salt =  "eCwWELxi"   val = "#{key|txnid|amount|productinfo|firstname|email|u df1|udf2|udf3|udf4|udf5||||||#{@salt}"  @checksum = Digest::SHA512.hexdigest("#{val}") end <form action="https://test.payu.in/_payment" method='post' id='sub'  >     <input type="hidden" name="key" value="<%=@key%>">     <input type="hidden" name="hash" value="<%=@checksum%>">     <input type="hidden" name="txnid" value="TXN1234">     <input type="hidden" name="amount" value="200">     <input type="hidden" name=...

PayUMoney Integration in Ruby on Rails

PayUMoney Integration in Ruby on Rails Generating Cheksum in Payu    Hash or Checksum = sha512(key|txnid|amount|productinfo|firstname|email|u df1|udf2|udf3|udf4|udf5||||||salt) Controller Code Will be def payumoney   @key = "gtKFFx"   @salt =  "eCwWELxi"   val = "#{key|txnid|amount|productinfo|firstname|email|u df1|udf2|udf3|udf4|udf5||||||#{@salt}"  @checksum = Digest::SHA512.hexdigest("#{val}") end <form action="https://test.payu.in/_payment" method='post' id='sub'  >     <input type="hidden" name="key" value="<%=@key%>">     <input type="hidden" name="hash" value="<%=@checksum%>">     <input type="hidden" name="txnid" value="TXN1234">     <input type="hidden" name="amount" value="200">     <input type="hidden" name=...

Document Preview in Rails?

Document Preview in Rails? Display the doc preview  in iframe? <iframe src='https://docs.google.com/viewer?url=www.google.com/doc/kotesh.docx&embedded=true' frameborder='0'></iframe> Display the doc preview  in new page? <a href= "https://docs.google.com/viewerng/viewer?url=url=www.google.com/doc/kotesh.docx&embedded=true" target= "_blank">Doc PreView</a>

Production deployment steps in rails?

Production deployment steps in rails? List of steps for Production deployment 1)In app folder -> git pull origin master 2)bundle install --path vendor/bundle 3)rake assets:precompile RAILS_ENV=production 4)touch tmp/restart.txt 5)If u want to restat server level command is  sudo service nginx restart 6)Stop the nginx server command is sudo service nginx stop 7)Starting the nginx server command is sudo service nginx start

Cronjob in ruby on rails

1)Install whenever gem 2)In application folder run the wheneverize. 3)In schedlue.rb file every 3.hours do runner "MyModel.some_process" rake "my:rake:task" command "/usr/bin/my_great_command" end 4)Write the rake task 5)namespace :events do   desc "Rake task to get events data"   task :fetch => :environment do     events = Event.nba_search     events.each do |item|       item.each do |hash|         @event = Event.new({         # Code to instantiate an event         })         @event.save       end     end     puts "#{Time.now} - Success!"   end end end 6)whenever --update-crontab

Ruby Encoder Steps

List Of steps for RubyEncoder 1)Downlolad the https://www.rubyencoder.com/profile.html -> Or else we can download in this link also 2)Copy above file in this directory -> /usr/local/bin  (RubyEncoder-2.2-Evaluation-Linux-x86_64-Install) 3)Give the permissions chmod 755 RubyEncoder-2.2-Evaluation-Linux-x86_64-Install 4)Run the RubyEncoder-2.2-Evaluation-Linux-x86_64-Install command 5)Open Existing Project   i)Add button click   ii)Choose for destination   iii)Click on encode button   iv)select the platform which one we want to encode     1)FreeBSD     2)Linux     3)Windows     4)Macos x  6)Set the destination folder.  7)Click on install button.

Iquanti Apptitude Test for ror

Iquanti Apptitude Test for ror ? Anagrams Max. Marks 100 Given two strings A and B, check if they are anagrams. Two strings are said to be anagrams, if one string can be obtained by rearranging the letters of another. Examples of anagrams are dog, god; abac, baac; 123, 312 abab, aaba; dab, baad are not anagrams. INPUT : First line of the input is the number of test cases T. It is followed by T lines, each line has two space separated strings A and B; OUTPUT For each test case, print "YES" if they are anagrams, otherwise print "NO". (without quotes) Constraints 1 <= T <= 10 A and B both contain only lower case latin letters 'a' to 'z' and digits 0 to 9. Length of each string A and B does not exceed 5*10^5 (500000), Sample Input(Plaintext Link)  3 abcd bcda bad daa a1b2c3 abc123 Sample Output(Plaintext Link)  YES NO YES ==================== 4. Prime or Not Max. Marks 100 Given the number N check whether it i...

Basic Ruby Programs for Interview?

Basic Ruby Programs for Interview? # require 'prime' # # p Prime.first(10) # Prime.each(100) do |prime| #   p prime  #=> 2, 3, 5, 7, 11, ...., 97 # end #Prime number programe  def prime_numbers max for i in (2..10) do     for j in (2..i) do         break if i%j == 0     end     p "#{i} is a prime number." if i == j end  end #Factorial Programe n = gets n = n.to_i def fact(n)   if n == 0     1   else     n * fact(n-1)   end end p fact(n) #Reverse Number Programe x = 12345 y = 0 while x > 0 do     y = y*10     y = y + (x%10)     x = x/10   puts y     end puts "What character do you want to make the pyramid out of?" character = gets.chomp puts "How many rows of #{character}'s do you want?" row_count = gets.chomp.to_i character_count = 1 width = 100 row_count.times do put...