Segmentation Fault while doing bundle install

I recently encountered this error of segmentation fault while doing bundle install in one of my rails application.

After a bit of googling I found out its an issue with ruby 1.9.3.

Here is the solution:

 

rvm pkg install iconv
 rvm pkg install openssl
 rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr

 

Installing and setting up GIT

INSTALLING GIT
Installing from Source:
In short, on a Unix-based system, you can download the Git source code from the Git Download Page, and then run
something along the lines of :

$ make prefix=/usr all ;# as yourself
$ make prefix=/usr install ;# as root

You will need the expat, curl, zlib, and openssl libraries installed – though with the possible exception of expat, these will normally already be there.

Linux
If you are running Linux, you can likely install Git easily via your native package management system:

$ yum install git-core
$ apt-get install git-core

Mac 10.4:
In both Mac 10.4 and 10.5, you can install Git via MacPorts, if you have that installed. If not, you can install it from here.
Once MacPorts is installed, all you should have to do is:

$ sudo port install git-core

If you prefer to install from source, these articles may be helpful:
Article: Installing Git on Tiger
Article: Installing Git and git-svn on Tiger from source

Mac 10.5
With Leopard, you can also install via MacPorts, but here you have the additional option of using a nice installer, which you can download from here: Git OSX Installer
If you prefer to install it from source, these guides may be particularly helpful to you :
Article: Installing Git on OSX Leopard
Article: Installing Git on OS 10.5

SETUP AND INITIALIZATION
Git Config
The first thing you’re going to want to do is set up your name and email address for Git to use to sign your commits.

$ git config –global user.name “Rushabh hathi”
$ git config –global user.email “rushabhhathi@gmail.com”

That will set up a file in your home directory which may be used by any of your projects. By default that file is ~/.gitconfig
and the contents will look like this:
[user]
name = Rushabh Hathi
email = rushabhhathi@gmail.com

If you want to override those values for a specific project (to use a work email address, for example), you can run the git config command without the –global option while in that project. This will add a [user] section like the one shown above to the .git/config file in your project’s root directory.

Resizing the image without chaning its dimensions using paperclip

Hi,

In a recent application, the need of the hour was to reduce the file size of an image without changing its dimensions.

Now, this can be acheived by reducing the quality of the image.

ImageMagick library has a “convvert” command which does exactly the same..

for eg(on the terrminal) : convert image1.jpg -quality 10 image2.jpg

image1.jpg—>original image

image2.jpg—->final image

 

According to the paperclip wiki there is a :quality parameter which is allowed.

I tried that but for some reasons , I was not able to get it running.

I also tried using :convert_options but it did not work too.

 

Thus , I wrote my own processor and got the stuff working. Here is the model and processor code :

#######Model code###########

class Passet < ActiveRecord::Base
attr_accessible :caption, :markup, :media_passet, :pcontent_id
has_attached_file :media_passet,
:styles => {
: original => {
:geometry => “256×256<”,
:processors => [:qresize]
}
}
belongs_to :pcontent
end

 

###################Processor code########################

make a file called qresize.rb in #{Rails.root}/lib/papaerclip_processors

The path is mentioned because this path is loaded automatically….

module Paperclip
# handles compression of image by reducing its quality
class Qresize < Processor
def initialize file, options = {}, attachment = nil
super
@format = File.extname(@file.path)
@basename = File.basename(@file.path, @format)
end
def make
src = @file
dst = Tempfile.new([@basename, @format])
dst.binmode
begin
parameters = []
parameters << “:source”
parameters << “-quality 10″
parameters << “:dest”
parameters = parameters.flatten.compact.join(” “).strip.squeeze(” “)
success = Paperclip.run(“convert”, parameters, :source => “#{File.expand_path(src.path)}[0]“, :dest => File.expand_path(dst.path))
rescue PaperclipCommandLineError => e
raise PaperclipError, “There was an error during the Size Reduction  for #{@basename}” if @whiny
end
dst
end
end
end

 

This is a general code for image resizing and probably at this stage, we may not require to write a processor.

But the advantage of doing this is that we can extend this to do a lot more as and when requirement comes.

Also, we can handle our video and audio processing by this easily.

The other option is to pass a block(lambda or Proc) to :styles hash but I personally feel this is a much cleaner approach.

 

Hope it helps.