Posts

Rails performance boost using Passenger/Unicorn Out-Of-Band Work GC

Hello, have u tried Out-Of-Band GC? Its available in passenger 4 and unicorn its give a very good performance boot to application at cost of some extra memory footprint (in my case 1.6 times than actual memory) Don't forget to to disable auto gc during requests GC.disable # Don't run GC during requests is the  main key here Tune frequency according to application for maximum performance  #unicorn GC_FREQUENCY = 5 #for passenger  Trigger out-of-band GC every 5 requests. use PhusionPassenger::Rack::OutOfBandGc, 5  http://blog.newrelic.com/2013/05/28/unicorn-rawk-kick-gc-out-of-the-band/ http://blog.phusion.nl/2013/01/22/phusion-passenger-4-technology-preview-out-of-band-work/  Also have your ruby tuned for GC so that it can serve more requests without frequent GC runs http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126 https://gist.github.com/burke/1688857

Curb gem Installation problems on Ubuntu

Install the follows libs sudo apt-get install libcurl4-gnutls-dev  libcurl4-openssl-dev curb gem compiles natively using system libs and it requires curl headers to complile with is not installed by default. Install the libs and run  gem install curb It should install smoothly.. \m/ 

10 tips for securing nginx

10 tips for securing nginx

truncate and link text helper in rails

snippet to truncate text and link to see more Code this in application helper.   def truncate_and_link( text,options ={})     length = options[:length]     return text if length.blank?     url = options[:url] || '#'     output = raw truncate(text, :length => length)     output += link_to('more', url) if text.size > length     output.html_safe   end Useful when eg linking big posts

rails 3.2 with jruby and mysql with rvm in ubuntu

If was trying to migrate one of the app from ruby to jrby to try out the threading benifits. this wasn't an easy task :D well the gem dependency did not create a big issue. the problem came when connecting to mysql with jdbc driver I had replaced  gem 'mysql2' with   gem 'activerecord-jdbcmysql-adapter' in Gemfile But it refused to load the driver saying : "The driver encountered an unknown error: cannot load Java class com.mysql.jdbc.Driver' I searched but Google could not answer me :( then I started looking into activerecord-jdbsmysl-adapter gem and came upon the the file  activerecord-jdbc-adapter / activerecord-jdbcmysql-adapter / lib / active_record / connection_adapters /jdbcmysql_adapter.rb  I just copy pasted the code in a application.rb config with a condition if jruby used just after the bundler code if defined?(JRUBY_VERSION)   require 'jdbc/mysql'   Jdbc::MySQL.load_d...

Send devise compatible forgot password mail through action mailer in rails

Image
To have multiple forgot password templates and send it through mailer in rails it is quite easy Just Cheers...!!

Using rvm in Kde Konsole

rvm (ruby version manager) needs a small change in konsole setting to make rvm use work right click on the terminal and select 'edit current profile' change the command from /bin/bash to /bin/bash --login Apply and boom you are ready to use rvm in terminal.