Ubuntu 12.10 Server Setup for Ruby on Rails, Passenger, Nginx.
Monthly Archives: March 2013
Merging Pdf’s in Rails application
Alright, I had a lot of fun today trying to figure out how to merge pdf’s in our Rails application.
We are using pdfkit to create our pdf’s. What I needed to do was to take several pdf’s and merge them into one large pdf. Frankly I did not think it was even possible. I found several Ruby gems that were supposed to do the job but everyone I tried was just another PITA dead end.
After getting pointed in the right direction by @m3talsmith, I ended up solving my issue the old school way. So, if you have done this before with Ruby gems stick with it. If not, here we go…
I first started with an empty array for pdfs. Then I went thru a couple of processes to add all the pdfs to the pdfs array.
After that, comes the old school. Using Ghostscript (gs) we joined…
View original post 57 more words
How to Get Free Email Hosting for Your Domain
Detecting Mobile Browser via Gem
Step 1: Install the gem ‘browser’
gem install browser
Step 2: Add it to Gemfile or environment.rb
gem "browser" #=> Rails 3 config.gem "browser" #=> Rails 2
Step 3: Implement
require "browser"
browser.name # readable browser name browser.safari? browser.opera? browser.chrome? browser.mobile? browser.tablet? browser.firefox? browser.ie? browser.ie6? # this goes up to 9 browser.capable? # supports some CSS 3 browser.platform # return :mac, :windows, :linux or :other browser.mac? browser.windows? browser.linux? browser.blackberry? browser.meta # an array with several attributes browser.to_s # the meta info joined by space
Example:-
<% if browser.ie6? %> <p>You're running an older IE version. Please update it!</p> <% end %>