Skip to main content

Posts

UNIX - Process/Jobs

Playing the commands fg , ctrl+z , bg and jobs In this post I would like to share few basic process or job specific tricks in UNIX. 1. If you want to run a process in bacground just add a & as suffix with a space  Eg: [root@localhost kannan]# ruby test.rb & here this process test.rb will run in background  2. If you want list available background tasks/processes/jobs , just use the command 'jobs' Eg: [root@localhost kannan]# jobs here the result would be  [1]+ Running ruby test.rb  3. If you want to bring a background process in front (foreground) just use fg [#<job number>] Eg [root@localhost kannan]# fg #1  It will bring the above 'ruby test.rb' process in front. 4. If you want to again move a already running process to background , use two combination of commands     a. First pass Ctrl+Z , here you will get a message like 'stopped' don't get upset, it will jus...

RVM with rails1.2.1 and rails 3.2.x

rvm install ext-rvm-list \curl -L https://get.rvm.io | bash -s stable source /etc/profile.d/rvm.sh rvm automount rvm list whereis ruby rvm list ruby rvm list rubies rvm install 1.8.7 rvm install 1.9.3 rvm list rvm set default ruby-1.8.7-p371 rvm --help rvm default ruby-1.8.7-p371 rvm list gem list yum install gcc-c++ yum install openssl rvm pkg install openssl rvm pkg install iconv rvm list rvm use ruby-1.9.3-p327 svn co http://b3.flexis.net:3001/omie_dev_r3 cd omie_dev_r3/ ls rvm list bundle install yum install postgresql postgresql-devel gem install pg -v '0.14.1' bundle install cd .. cd omie_dev ls rvm list rvm use ruby-1.8.7-p371 clear ruby -v gem install rails -v 1.2.1 gem install imagesize -v 0.1.1 gem install parseexcel 0.5.2 gem install payment -v 1.0.1 gem install pdf-writer -v 1.1.3 gem install pdfkit -v 0.5.0 gem install pg -v 0.14.0 gem install postgres -v  0.7.9.2008.01.28 gem install rmagick -v 2.13.1 gem install rubyzip -v 0.9.4 gem install simple_xlsx_writer -v ...

Errno::ENOENT: No such file or directory

HTML to PDF conversion is very easy in rails and pdfkit will be useful in this case, wkhtmltopdf tool will be supporting tool so you can easily convert an html to pdf.  In my experience I used the following steps: gem install pdfkit -v 0.5.0 gem install wkhtmltopdf -v 0.1.2 gem install wkhtmltopdf-binary Some times this sequence will not work, so I use the following as per the instruction from  https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF Be careful to download the appropriate wkhtmltopdf tar ball, it depends on your os architecture, like i386 or 64 wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2 mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf chmod +x /usr/local/bin/wkhtmltopdf Try to convert html to pdf after restarting your web servers.  If you get any error like: Errno::ENOENT: No such file or directory then I have a str...

Invalid json result

In rails some times we are getting invalid json outputs say for example, as per the json standard, both the attributes and its values should be enclosed with double quotes (") but in some of the ruby patches has issues with that. If you are facing such issues then this post will be useful: Changes what we have to make in the file 'core.rb' which is located at: LIB_PATH/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/json/encoders in your rails server, the LIB PATH is /usr/local/lib required function is "encoder"  line# 52 New Code ======== define_encoder Hash do |hash|         returning result = '{' do           result << hash.map do |key, value|             key = ActiveSupport::JSON::Variable.new(key.to_s) if               ActiveSupport::JSON.can_unquote_identifier?(key)             "\"#{...

openssl load error

If you found any payment issue due to openssl (like require 'openssl' fails) then you have to be very careful. Exact error might be: LoadError: no such file to load -- openssl This error occurred because you have installed your ruby without openssl support. So first install openssl then install ruby with openssl support.  If you still getting the error then you can follow the steps: 1. Check whether the openssl package is installed, if not please use 'yum install openssl' 2. Still the issue not solved then install openssl-dev, also make sure  the library 'libruby' is installed  3. Still the issue not solved then check the ruby lib has the directory called  'openssl'  Note: In my server, the ruby lib is located at: /usr/local/lib/ruby/1.8/, better you can search the exact ruby's lib through 'whereis ruby' command 4. If openssl directory is not in your ruby lib then possibly you might get the openssl load error, then ...

Going to convert your existing Rails 1.2.1 apps to 3.2.3 ? then this post may help you!!!

Rails 1.2.1 => Rails 3.2.3 Actually, we started a product on 2007 with rails 1.2.1, at that time we were busy in the core development and we sincerely forgot to look about the rails updates!! in-between 3-4 years rails jumped to 3.x.x then only we realized that we are doing some funny things so started to review about 3.x.x  Almost we are out-dated, but still it is not too far .. We realized that this is right time to convert our existing 1.2.1 apps to 3.2.3 so first we have started to find the practical difficulties and possibilities and learned the followings. The following is the major things for us, you guys may meet some more, but any way it will be helpful for someone.  Lets checkout one by one. 1. RVM will helps us to manage different ruby and gems version in a same system 2. All required gems should be maintained through Gemfile, it will be useful when the time of deployment 3. You have to understand, learn and change the file route.rb 4. .rhtml is no longer ...

Rails 1.2.1 with Ruby 1.8.x installation tips

ROR Setup (Ruby 1.8.6 , patch level 111, rails 1.2.1, CentOs 6.2 62 bit, Postgres 8.3) Make sure rpmforge included in your yum.repo ‘s, you can make it is available through cd /tmp/ wget  http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm --import  http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm Download and install ruby 1.8.6 cd /tm/ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.bz2 tar jxf ruby-1.8.6-p111.tar.bz2  cd ruby-1.8.6-p111 ./configure make Note: If you found any error like make gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c array.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c bignum.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c class.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c...