Add multiple virtual host along with Passenger

Posted on January 5, 2010, under Uncategorized.

I was having few projects on my MAC and was really bugged up with maintaining the port numbers and other stuffs, a real cumbersome.

After, Jacek’s thought on this, I had set up the following:

Install the gem:

sudo gem install ghost

after that add a virtual host

sudo ghost add paddy.local (a choice of your virtual host)

Install the Passenger gem:

sudo gem install passenger
sudo passenger-install-apache2-module

After installing the apache module for passenger, you may have add the following lines (after installation it will tell based on your own enviroment)

(in your httpd.conf)

LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.8
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Also you may have to enable your virtual host too …by default, it may be disabled(commented) and you have to enable(uncomment) it

# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

Next, you have to add the vitual host for your rails app.

(httpd-vhosts.conf)

<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public    # <– be sure to point to ‘public’!
<Directory /somewhere/public>
AllowOverride all              # <– relax Apache security settings
Options -MultiViews            # <– MultiViews must be turned off
</Directory>
</VirtualHost>

And you have to restart your apache server and start your respective rails app.

Happy Developing with Virtual Host

BSNL 3G Speed

Posted on November 23, 2009, under Uncategorized.

After a long awaiting for the actual launch of 3G service in Chennai, its available now. I rushed up to the customer service center and got myself the 3G Sim Card and just tried the net speed which BSNL claims  upto 3.6 MBPS …but the result is shown in the below image

BSNL 3G Speed

BSNL 3G Speed

The performance of BSNL 3G is not that bad on the data, but still i need to check it up.

Here’s the setting that I have used:

Access Point Name: GPRSSOUTH.CELLONE.IN

User Name your mobile number ( 94xxxxxxxx )

Password your mobile number ( 94xxxxxxxx )

Dailup No *99# OR *99***1#

The download seems to be atleast ok, but the upload speed is way too less.

This is it …for now from my desk …catch you up later :-)

Cheers!

Search comma separated values db column in Rails

Posted on November 22, 2009, under MySQL, Rails.

I wanted to search for a value in DB and the column data is comma separated values say …

foo,bar,hey,hay

Now I wanted to find a record based on the value …say …hay

MySQL’s FIND_IN_SET comes into play and it works as follows

1
2
3
<%
Model.find(:first, :conditions => ["FIND_IN_SET(?,search_column)", search_string])
%>

Hope this helps!

Making will_paginate to work with acts_as_taggable_on_steriods

Posted on September 1, 2009, under Uncategorized.

After going through, few post on pagination for the tags, this worked for me.

1
2
3
4
<%
 size = Upload.find_tagged_with(params[:id]).length
 @uploads = Upload.paginate_tagged_with(params[:id], :total_entries => size, :page => params[:page], :per_page => 1)
%>

Installing MySQL Gem on Mac OSX with XAMPP

Posted on July 26, 2009, under Gems, MAC, MySQL.

I was having lot of trouble on installing the MySQL Gem for Mac OSX Leopard 10.5.9 via XAMPP. I have the XAMPP running and also mySQL. Here are the steps.

1. Install XAMPP for MAC

2. Install XAMPP Dev Package

3. From your terminal type the following command and you’ll see the following

1
sudo gem install mysql -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/ -- with-mysql-lib=/Applications/XAMPP/xamppfiles/lib -- with-mysql-include=/Applications/XAMPP/xamppfiles/include/ -- with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config

Results:

1
2
3
4
5
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed
Installing ri documentation for mysql-2.7...
Installing RDoc documentation for mysql-2.7...

Is Active

Posted on April 13, 2009, under Uncategorized.

def is_active?
(start_date .. expiry_date) === DateTime.now
end

Rspec bundle for Textmate

Posted on March 25, 2009, under MAC.

I was looking for a Rspec bundle for textmate and it is here with steps to follow and simply superb!

http://blog.emson.co.uk/2008/06/installing-the-latest-rspec-textmate-bundle/

Pads

Git Stash

Posted on March 10, 2009, under GIT.

Currently, I am working on few files and when you do a git pull, you may sometimes get a message as follows:

error: Entry 'app/views/alerts/index.rhtml' not uptodate. Cannot merge.

So you know, somebody has updated the code and you do need to commit the file so that the file can be merged and for some reason I don’t want to commit till i finish the work. This is where git stash comes into play. from your root of the app, do the following command

1
2
3
git stash 
git pull
git stash apply #Apply your changes

for more info http://www.kernel.org/pub/software/scm/git/docs/git-stash.html

Run Controller Spec

Posted on February 21, 2009, under Rails.

If you just wanted to run only the controller specs, then you have to use the following command

1
rake spec:controllers

Restore the deleted files with GIT

Posted on February 19, 2009, under GIT.

Today, it was a shock, that I have deleted few files without my knowledge. Fortunately, before deleting I had committed the files and so no much of tension. You can use the following commands to restore it.

View the list of deleted files:

1
git ls-files -d

This will list the deleted file and lets restore it now.

1
git ls-files -d | xargs git checkout --

Hope this helps somebody.

Cheers!