Skip to main content

Posts

Showing posts from 2014

The Bidder Journey

It was time for another Rails Rumble event, and I was looking for Ideas what to build.  Through one of coding competition I came across a problem in which you have to write a algorithm to outbid computer. I am (always been ) fan of Computer Games, so I thought why not build a Game based on this problem. Rails Rumble is a 48 hrs coding competition in which you have to build one Rails application. At this point, I knew what to build and which framework to use, but I didn't knew how to built it or even its possible in Rails, so I presented my Idea in Open Source Friday  .  I dry run my Idea on white board and played  a demo with Gautam Rege ( @ gautamrege ) on white board. People liked the Idea, and suggested how it can be done. Sanjiv Jha got interested in this game and joined me in the journey. The day of competition arrived 19 Oct 2013. Sanjiv and I coded 2 days , Stack used in Bidder is Ruby 2, Rails 4, Bootstrap 2.3, jquery 1.9, we used  Pusher  for broadcasting

Generating preview for pdf and images using Carrierwave in Rails

This blog post will cover how to generate the preview of pdf files using Carrierwave gem. Carrierwave gem has an inbuilt " manipulate! " method which reads the file and loops over every page.  This " manipulate! " method works as expected for a pdf having 300-400 pages but when I uploaded a pdf having 1000+ pages my machine crashed!!! That is when I started debugging the code and found out that there is an issue with the manipulate method. Here is my original code. class MyUploader < CarrierWave :: Uploader :: Base include CarrierWave :: RMagick def cover manipulate ! do | frame , index | frame if index . zero ? # take only the first page of the file end end version : preview do process : cover process : resize_to_fit => [ 310 , 438 ] process : convert => : jpg def full_filename ( for_file = model . source . file ) super . chomp ( File . extname ( super )) + '.jpg'