Wednesday, September 03, 2008

/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

Recently I ran an update to my Ruby Gems using the following command

sudo gem update --system

and I got this strange Error:

/usr/bin/gem:23: uninitialized constant Gem::GemRunner(NameError)

I googled and found a fix to this problem.
Add the line in bold to the file /usr/bin/gem:

#!/usr/bin/env ruby
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++

require 'rubygems/gem_runner'
require 'rubygems'
Gem.manage_gems

required_version = Gem::Version::Requirement.new(">= 1.8.0")
unless required_version.satisfied_by?(Gem::Version.new(RUBY_VERSION))
puts "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
exit(1)
end

# We need to preserve the original ARGV to use for passing gem options
# to source gems. If there is a -- in the line, strip all options after
# it...its for the source building process.
args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]

Gem::GemRunner.new.run(args)

And it works perfectly

Friday, August 29, 2008

Ruby Script to pull documents over http

I Recently Got a Strange problem, quite a strange requirement from one of the clients.They needed to build a query whose result will be an XML. We need to get that XML on the local system over HTTP without any login credentials.
The Biggest catch was, apart from the files themselves, we even had to fetch the metadata along with the documents.
Here is a Ruby Script that helped us:

require 'net/http'

Net::HTTP.start("www.safewlabs.com") { |http|
resp = http.get("/images/SAFEW.jpg")
open("safewlogo.jpg", "wb") { |file|
file.write(resp.body)
}
}
puts "File Copied"


Description: The Script above uses the net/http library of Ruby. Ruby Net HTTP API resides here. We first access the URL of the server where the Particular file is hosted.Then in the variable put the response of the getmethod of the http protocol.In this case it uses the absolute path of the file.Once done, Ruby file I/O method open is used, where we open a new file on our local system and write the fetched information into it (file.write(resp.body)).

The Copied file is stored in the same folder as the script.You can also set a target folder for it.

Monday, June 02, 2008

Bangalore RUG gets a site at sploup.com


Bangalore RUG recently got a site for the first time.This came out of the need to set the ball rolling for activity more than just a discussion group.As agreed by fellow moderators,Sidu and Satish, this group is a knowledge centric group and there needs to be a central place for all Ruby, Rails knowledge.Then I think the group might serve it's right purpose.I googled for a such a place to create site,and it stumbled upon sploup.com. Which is a place where you can create sites for groups.

In this place I could:
1.Get a place to share the code (Download Section)
2.Calender to Mark the calenders
3.Direct connect for the community members
4.Share Photos and Publicize the group.

Well the only thing which I felt was strongly missing is the Blogging part.I wanted to run a community blog,a much better resource center for Ruby and Rails ,anything for that matter than books.

The interface comes with a dashboard and a lot of good features though,select themes,customize them considerably,manage users,manage content,create pages.You can add questions for people who want to join new.

This is a good option to keep the site for a group or a community.

Thursday, May 22, 2008

Hardy Heron comes to the town


As you can see from my previous posts, I like to review each version of Ubuntu sooner or later.Now, this is quite early, as we are only a month old into Hardy Heron the latest offering of Ubuntu from Canonical. This thing runs like a complete treat to the eyes of the user and you can easily make out that this has been made to make linux reach out to the desktop users, who want a virus free but user friendly interface.
Now, whats so special about this version.Well I feel the best thing about the server is inbuilt KVM support and incorporation of JeOS, a version with which you can make virtual appliances using VMware.It has firefox 3 beta 5 installed looks good.

However,desktop has all the offerings similar to Gutsy.The number of free and third party software have increased in the repositories.There was a major security vulnerability discovered in the Open SSL key but that was fixed, a fix was provided as a part of the update package.

Now,about the device support, its really amazing as the case with all other distros. I even tried Kubuntu, and a remixed KDE 4 version of Kubuntu, but KDE 4 still has sometime before it gets fully adopted.At least thats what I feld after using it. The management of desktop is much beautiful and easy with the plasma and widget fundamantals, a completely new concept in the world of desktops, but loses on stability and is still buggy.In sometime however,it is going to rule the desktops for sure.

I think my discussion went off the track to review KDE4 instead of Hardy.So things are much the same now, except for educational and accessibility software.Edubuntu now comes as an add on instead of a separate distro and accessibility things like Orca comes pre-installed, you just need to configure it.

The screenshot shows the preference settings for accessibility software.All in all this is a great distro for desktop users.

Thursday, March 20, 2008

Why is Debian and Ubuntu a cut above others ?

Debian and Ubuntu is definitely a cut above all the distros.They are the true symbol of freedom provided by the Open Source software.
Debian for instance is the most robust OS on earth.A very long testing cycle and a stringent process for certifying the software, a super process and yes the end result is satisfying.When you look at etch, its a a marvel , a masterpiece of software and Debian community.It comes with 18,733 software declared stable by the master team and an ever reliable word.I have been using the system for months without a single malfunction or strange behavior or even a single crash or hang.Effortless is what i can say and smooth in use.No hassles of compatibility of Software and everything is available in the 3 DVDs.Install it and fetch the updates.

Ubuntu, comes with a special spirit, a spirit of humanity and a great community to backup.I thank Mr Shuttleworth to be upto his commitment and promises of Software Libre.The people behind Ubuntu and the users,that have shown the response to it.The way they have eased the desktop computing in Linux is commendable,and now forms a serious threat to windows.See the trend, people have already voted and asked Dell to bring out PCs with Ubuntu.Dell responded superbly and XPS I tell you has amazing device drivers compatibility.Even the remote control for presentation works out of the box.

The way they Ubuntu is expanding its business all over the world will see it become a software for human beings, from Linux for human beings.

Sunday, March 16, 2008

Installing RMagick and ImageMagick on Linux

Many of the Rails applications in today's scenario are web based applications and are mostly ecommerce, social networking products or concepts pertaining web 2.0 domain.Images and their manipulation form an integral part of these applications.Imagemagick is a library which reads the image formats and encodings.RMagick is a library written in Ruby for reading and manipulating Images in your rails applications.

It's actually a challange to Install the versions of ImageMagick and RMagick which are exactly compantible with each other.Doing this on Ubuntu is another pain.However after a lot of trial and error,I figured out the most simple way to install ImageMagick and RMagick.I have Feisty,Gutsy and Etch with me and I had a hard time finding a suitable RMagick for them.

I would always reccomend the source installation of Imagemagick, because we just can trust that the version available in the Festy,Gutsy or Etch repos are the ones we want and whether it is compatible or not.So leave "sudo apt-get install imagemagick" and even "gem install rmagick" out of question.

To download Imagemagick goto ImageMagick Dowload Page and select a suitable mirror for download.After a lot of "Head Banging" or listening to Dreamtheater Songs,I concluded that the version "ImageMagick-6.3.8-11.tar.gz" is the one which we should ideally download.
Once downloaded, unzip the file:

tar xvzf ImageMagick-6.3.8-11.tar.gz

Then,chandge the directory and goto ImageMagick Directory:

cd ImageMagick-6.3.8-11
./configure

Once configured it will list the Image formats.
then do a make by

make
sudo make install

Once this is over we go over to install RMagick.Goto RMagick Download Page and download RMagick-2.2.2.tar.gz from the site. After all the trials, these versions of RMagick and Imagemagick are well compatible with each other and also work well on Rails version 2.0.2.

Untar the RMagick, and follow the commands:

tar xvzf RMagick-2.2.2.tar.gz
cd RMagick-2.2.2
ruby setup.rb
ruby setup.rb install

Once this is over,you can check the configuration by writing the command:

identify -list format

The Ideal output is :

saurabh@localhost:/etc/ld.so.conf.d$ identify -list format
Format Module Mode Description
-------------------------------------------------------------------------------
A* RAW rw+ Raw alpha samples
AI PDF rw- Adobe Illustrator CS2
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format
AVI* AVI r-- Microsoft Audio/Visual Interleaved
AVS* AVS rw+ AVS X image
B* RAW rw+ Raw blue samples
BMP* BMP rw- Microsoft Windows bitmap image
BMP2* BMP -w- Microsoft Windows bitmap image v2
BMP3* BMP -w- Microsoft Windows bitmap image v3
C* RAW rw+ Raw cyan samples
CAPTION* CAPTION r-- Image caption
CIN* CIN rw+ Cineon Image File
CIP* CIP -w- Cisco IP phone image format
CLIP* CLIP -w+ Image Clip Mask
CMYK* CMYK rw+ Raw cyan, magenta, yellow, and black samples
CMYKA* CMYK rw+ Raw cyan, magenta, yellow, black, and opacity samples
CR2 DNG r-- Canon Digital Camera Raw Image Format
CRW DNG r-- Canon Digital Camera Raw Image Format
CUR* CUR rw- Microsoft icon
CUT* CUT r-- DR Halo
DCM* DCM r-- Digital Imaging and Communications in Medicine image
DICOM is used by the medical community for images like X-rays. The
specification, "Digital Imaging and Communications in Medicine
(DICOM)", is available at http://medical.nema.org/. In particular,
see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
and supplement 61 which adds JPEG-2000 encoding.
DCR DNG r-- Kodak Digital Camera Raw Image File
DCX* PCX rw+ ZSoft IBM PC multi-page Paintbrush
DFONT* TTF r-- Multi-face font package (Freetype 2.3.5)
DNG DNG r-- Digital Negative
DOT DOT --- Graphviz
DPS DPS --- Display Postscript Interpreter
DPX* DPX rw+ SMPTE 268M-2003 (DPX 2.0)
Digital Moving Picture Exchange Bitmap, Version 2.0.
See SMPTE 268M-2003 specification at http://www.smtpe.org

EPDF PDF rw- Encapsulated Portable Document Format
EPI PS rw- Encapsulated PostScript Interchange format
EPS PS rw- Encapsulated PostScript
EPS2* PS2 -w- Level II Encapsulated PostScript
EPS3* PS3 -w+ Level III Encapsulated PostScript
EPSF PS rw- Encapsulated PostScript
EPSI PS rw- Encapsulated PostScript Interchange format
EPT EPT rw- Encapsulated PostScript with TIFF preview
EPT2 EPT rw- Encapsulated PostScript Level II with TIFF preview
EPT3 EPT rw+ Encapsulated PostScript Level III with TIFF preview
FAX* FAX rw+ Group 3 FAX
FAX machines use non-square pixels which are 1.5 times wider than they
are tall but computer displays use square pixels, therefore FAX images
may appear to be narrow unless they are explicitly resized using a
geometry of "150x100%".

FITS* FITS rw- Flexible Image Transport System
FRACTAL* PLASMA r-- Plasma fractal image
FTS* FTS rw- Flexible Image Transport System
G* RAW rw+ Raw green samples
G3* FAX rw- Group 3 FAX
GIF* GIF rw+ CompuServe graphics interchange format
GIF87* GIF rw- CompuServe graphics interchange format (version 87a)
GRADIENT* GRADIENT r-- Gradual passing from one shade to another
GRAY* GRAY rw+ Raw gray samples
HISTOGRAM* HISTOGRAM -w- Histogram of the image
HTM* HTML -w- Hypertext Markup Language and a client-side image map
HTML* HTML -w- Hypertext Markup Language and a client-side image map
ICB* TGA rw+ Truevision Targa image
ICO* ICON rw+ Microsoft icon
ICON* ICON rw- Microsoft icon
INFO INFO -w+ The image format and characteristics
IPL* IPL rw+ IPL Image Sequence
JNG* PNG rw- JPEG Network Graphics
See http://www.libpng.org/pub/mng/ for details about the JNG
format.
JP2* JP2 rw- JPEG-2000 File Format Syntax
JPC* JPC rw- JPEG-2000 Code Stream Syntax
JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JPG* JPEG rw- Joint Photographic Experts Group JFIF format
JPX* JPX rw- JPEG-2000 File Format Syntax
K* RAW rw+ Raw black samples
K25 DNG r-- Kodak Digital Camera Raw Image Format
KDC DNG r-- Kodak Digital Camera Raw Image Format
LABEL* LABEL r-- Image label
M* RAW rw+ Raw magenta samples
M2V MPEG rw+ MPEG Video Stream
MAP* MAP rw- Colormap intensities and indices
MAT* MAT rw+ MATLAB image format
MATTE* MATTE -w+ MATTE format
MIFF* MIFF rw+ Magick Image File Format
MNG* PNG rw+ Multiple-image Network Graphics (libpng 1.2.15beta5)
See http://www.libpng.org/pub/mng/ for details about the MNG
format.
MONO* MONO rw- Raw bi-level bitmap
MPC* MPC rw+ Magick Persistent Cache image format
MPEG MPEG rw+ MPEG Video Stream
MPG MPEG rw+ MPEG Video Stream
MRW DNG r-- Sony (Minolta) Raw Image File
MSL* MSL rw+ Magick Scripting Language
MSVG* SVG rw+ ImageMagick's own SVG internal renderer
MTV* MTV rw+ MTV Raytracing image format
MVG* MVG rw- Magick Vector Graphics
NEF DNG r-- Nikon Digital SLR Camera Raw Image File
NULL* NULL rw- Constant image of uniform color
O* RAW rw+ Raw opacity samples
ORF DNG r-- Olympus Digital Camera Raw Image File
OTB* OTB rw- On-the-air bitmap
OTF* TTF r-- Open Type font (Freetype 2.3.5)
PAL* UYVY rw- 16bit/pixel interleaved YUV
PALM* PALM rw+ Palm pixmap
PAM* PNM rw+ Common 2-dimensional bitmap format
PATTERN* PATTERN r-- Predefined pattern
PBM* PNM rw+ Portable bitmap format (black and white)
PCD* PCD rw- Photo CD
PCDS* PCD rw- Photo CD
PCL PCL rw- Printer Control Language
PCT* PICT rw- Apple Macintosh QuickDraw/PICT
PCX* PCX rw- ZSoft IBM PC Paintbrush
PDB* PDB rw+ Palm Database ImageViewer Format
PDF PDF rw+ Portable Document Format
PEF DNG r-- Pentax Electronic File
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.3.5)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.3.5)
PFM* PFM rw+ Portable float format
PGM* PNM rw+ Portable graymap format (gray scale)
PGX* PGX r-- JPEG-2000 VM Format
PICON* XPM rw- Personal Icon
PICT* PICT rw- Apple Macintosh QuickDraw/PICT
PIX* PIX r-- Alias/Wavefront RLE image format
PJPEG* JPEG rw- Progessive Joint Photographic Experts Group JFIF
PLASMA* PLASMA r-- Plasma fractal image
PNG* PNG rw- Portable Network Graphics (libpng 1.2.15beta5)
See http://www.libpng.org/ for details about the PNG format.
PNG24* PNG rw- opaque 24-bit RGB (zlib 1.2.3)
PNG32* PNG rw- opaque or transparent 32-bit RGBA
PNG8* PNG rw- 8-bit indexed with optional binary transparency
PNM* PNM rw+ Portable anymap
PPM* PNM rw+ Portable pixmap format (color)
PREVIEW* PREVIEW -w- Show a preview an image enhancement, effect, or f/x
PS PS rw+ PostScript
PS2* PS2 -w+ Level II PostScript
PS3* PS3 -w+ Level III PostScript
PSD* PSD rw+ Adobe Photoshop bitmap
PTIF* TIFF rw- Pyramid encoded TIFF
PWP* PWP r-- Seattle Film Works
R* RAW rw+ Raw red samples
RAF DNG r-- Fuji CCD-RAW Graphic File
RAS* SUN rw+ SUN Rasterfile
RGB* RGB rw+ Raw red, green, and blue samples
RGBA* RGB rw+ Raw red, green, blue, and alpha samples
RGBO* RGB rw+ Raw red, green, blue, and opacity samples
RLA* RLA r-- Alias/Wavefront image
RLE* RLE r-- Utah Run length encoded image
SCR* SCR r-- ZX-Spectrum SCREEN$
SCT* SCT r-- Scitex HandShake
SFW* SFW r-- Seattle Film Works
SGI* SGI rw+ Irix RGB image
SHTML* HTML -w- Hypertext Markup Language and a client-side image map
SR2 DNG r-- Sony Raw Format 2
SRF DNG r-- Sony Raw Format
STEGANO* STEGANO r-- Steganographic image
SUN* SUN rw+ SUN Rasterfile
SVG* SVG rw+ Scalable Vector Graphics (XML 2.6.27)
SVGZ* SVG rw+ Compressed Scalable Vector Graphics (XML 2.6.27)
TEXT* TXT rw+ Text
TGA* TGA rw+ Truevision Targa image
THUMBNAIL* THUMBNAIL -w+ EXIF Profile Thumbnail
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 3.8.2)
TIFF64* TIFF --- Tagged Image File Format (64-bit) (LIBTIFF, Version 3.8.2)
TILE* TILE r-- Tile image with a texture
TIM* TIM r-- PSX TIM
TTC* TTF r-- TrueType font collection (Freetype 2.3.5)
TTF* TTF r-- TrueType font (Freetype 2.3.5)
TXT* TXT rw+ Text
UIL* UIL -w- X-Motif UIL table
UYVY* UYVY rw- 16bit/pixel interleaved YUV
VDA* TGA rw+ Truevision Targa image
VICAR* VICAR rw- VICAR rasterfile format
VID* VID rw+ Visual Image Directory
VIFF* VIFF rw+ Khoros Visualization image
VST* TGA rw+ Truevision Targa image
WBMP* WBMP rw- Wireless Bitmap (level 0) image
WMF* WMF --- Windows Meta File
WMZ* WMZ --- Compressed Windows Meta File
WPG* WPG r-- Word Perfect Graphics
X* X rw+ X Image
X3F DNG r-- Sigma Camera RAW Picture File
XBM* XBM rw- X Windows system bitmap (black and white)
XC* XC r-- Constant image uniform color
XCF* XCF r-- GIMP image
XPM* XPM rw- X Windows system pixmap (color)
XPS XPS r-- Microsoft XML Paper Specification
XV* VIFF rw+ Khoros Visualization image
XWD* XWD rw- X Windows system window dump (color)
Y* RAW rw+ Raw yellow samples
YCbCr* YCbCr rw+ Raw Y, Cb, and Cr samples
YCbCrA* YCbCr rw+ Raw Y, Cb, Cr, and opacity samples
YUV* YUV rw- CCIR 601 4:1:1 or 4:2:2

* native blob support


If it shows the list of Formats, then congratulations !! you have configured ImageMagick correctly with RMagick.If you are getting an error "libmagick.so.10 Cannot open Shared Object File",means one of the library paths has not been configured correctly during the compilation.Run

sudo ldconfig

Before this make sure that you have /usr/local/lib in your /etc/ld.so.conf/libc6.conf file.
After that do remove the previous installation and install again.

Monday, March 10, 2008

Gutsy Gibbon up and running


I might be one of the last people to write a review to gutsy gibbon the Ubuntu 7.10.I had it running on my Compaq E733 AU laptop with AMD Athlon 64 bitX2,1 Gigs of Ram and 120 GB HDD and NVedia graphics card.Despite the good support of linux by the Nvedia hardware, I had a hard time bringing up the XServer.

Well after popping in the live cd,it took some time to boot into the command line after 3 failed attempts to bring up the xserver.
You will also be prompted to select a suitable monitor for your system, I tried 2-3 configurations and then selected 1024 option which worked fine.It added the following lines to the /etc/X11/xorg.conf file:

Section "Monitor"
Identifier "Failsafe Monitor"
Vendorname "Compaq"
Modelname "Compaq 1024"

Then I did a restart of the gdm /etc/init.d/gdm restart,in order to restart the Gnome display manager.Once the Live CD is up, you can click on the install icon and follow the steps easily to install Ubuntu on your system.

Now once we boot into our Ubuntu system for the first time after installtion, specially the HP/Compaq Laptops with Nvedia graphics cards, will get an option of installation of device drivers that are restricted through the "Restricted Drivers Manager". This will automatically detect your Nvedia hardware and give an option of installing the propritory device drivers.This will make it download the drivers and installation.

Once this is done you can enjoy all the 3D effects provided by the system.You can do a right click and goto "Change Desktop Background".There you get an option of "Visual Effects".You can activate the default Compiz Fusion by selecting "Extra" inside the visual effects.

Gutsy comes with a default desktop search option and all the software is quite stable.It is fast and breathtaking.Gutsy is just what you need to Install for an great desktop experience with maximum ease.