Copy Files and Git Status woes
Posted on December 29, 2011, under Git.
Recently when I upgraded from Leopard to Snow Leopard, I had to back up all files to my external HDD and when I restore it back and did a git status
git status
It had listed all the files in the repository and I thought I had to do a fresh checkout, but its not a optimal way nor a best solution. After doing a search in StackOverflow, i got the solution that i need to run the following:
git config core.filemode false
and that’s it …it was all done and just listed the modified files alone as expected.
Source / Credits to : StackOverflow
Virtual Hosts and Passenger
I wanted to have my local host based on the project name and its quite simple though, but needs some time to configure it …Let’s walk through, what I have done.
STEP 1: Install Ghost Gem
gem install ghost
STEP 2: Configure the vhost name
ghost add site1.local
STEP 3: Install & Configure Passenger
gem install passenger
Install Passenger for Apache
passenger-install-apache2-module
Follow the onscreen instructions and you may have to edit httpd.conf file and append the passenger module in httpd.conf like the one below (Do not COPY below as it would differ the path from mine)
LoadModule passenger_module /Users/rapbhan/.rvm/gems/ruby-1.8.7-p352@plm/gems/passenger-3.0.11/ext/apache2/mod_passenger.so PassengerRoot /Users/rapbhan/.rvm/gems/ruby-1.8.7-p352@plm/gems/passenger-3.0.11 PassengerRuby /Users/rapbhan/.rvm/wrappers/ruby-1.8.7-p352@plm/ruby
Restart apache now
sudo /usr/sbin/apachectl restart
Edit the vhost file
/private/etc/apache2/extra/httpd-vhosts.conf
and add the following code in there
ServerName project.local DocumentRoot /Users/rapbhan/projects/projectA/public Options -Indexes FollowSymLinks AllowOverride AuthConfig FileInfo Order allow,deny Allow from all ErrorLog "/private/var/log/apache2/projectA.local-error_log" CustomLog "/private/var/log/apache2/projectA.local-access_log" common RailsEnv development
Restart apache Again!
sudo /usr/sbin/apachectl restart
Installing Rmagick on Snow Leopard via BREW
In my other post, on installing Rmagick, I got the following error:
make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. Making install in include make[2]: Nothing to be done for `install-exec-am'. test -z "/usr/local/include" || .././install-sh -c -d "/usr/local/include" /usr/bin/install -c -m 644 'icc34.h' '/usr/local/include/icc34.h' /usr/bin/install -c -m 644 'lcms.h' '/usr/local/include/lcms.h' make[2]: Nothing to be done for `install-exec-am'. test -z "/usr/local/lib/pkgconfig" || ./install-sh -c -d "/usr/local/lib/pkgconfig" /usr/bin/install -c -m 644 'lcms.pc' '/usr/local/lib/pkgconfig/lcms.pc' tar: Unrecognized archive format: Inappropriate file type or format tar: Error exit delayed from previous errors.
and so I reverted back to home brew and it was quite successful
he he he
brew install imagemagick
and its all done without any errors
brew link imagemagick
All done with no errors! YAY!!!!!!!!
Installing Rmagick on Snow Leopard
Earlier when I was having Leopard, I used Mac Ports (as a newbie of MAC) and later i discovered its isn’t the best solution for Rmagick and some claim its not even good to install Ports.
After I upgraded to Snow Leopard, I was reluctant to install MySQL and Rmagick via Ports and so I Brew came to rescue for MySQL and now I have to install Rmagick without using ports and found the best way of doing it in CLI with just a single line of code.
curl https://raw.github.com/maddox/magick-installer/master/magick-installer.sh | sh
and once i had rmgick install, I installed the ruby gem:
gem install rmagick
GitHub URL for Rmagick: https://github.com/maddox/magick-installer
Hope this helps!
Error Messages {{attribute}} {{message}}
Recently I got this error message in a rails app
# {{attribute}} {{message}}
The Rails version was rails 2.3.8 and it was using i18n version 0.6.0 and after googling sometime found the solution
Add the code in config/preinitializer.rb
#Add this code in config/preinitializer.rb require 'rubygems' begin gem 'i18n', "~> 0.4.0" rescue LoadError # no biggie, optional anyway end
Ofcourse, you need to restart your webrick server to see in action.
Courtesy: StackOverflow.com
Refactoring to pass paramaters only if exists
I wanted to pass variables to will_paginate only if it exists i.e. if the variables exists then it should be passed.
Before Refactoring:
<% if(params.has_key?(:b_id) && params.has_key?(:t_id) && params.has_key?(:t_type)) %>
<%= will_paginate @products, :params => {:b_id => params[:b_id], :t_id => params[:t_id], :p_type => params[:t_type], :search => 'true'} %>
<% else %>
<%= will_paginate @products %>
<% end %>
After Refactoring:
<%= will_paginate @products, :params => (params.has_key?(:b_id) && params.has_key?(:t_id) && params.has_key?(:t_type)) ? params : "" %>
This will pass the variables only if it exists and if not then it wouldn’t pass anything.
Cheers!
Add multiple virtual host along with Passenger
Posted on January 5, 2010, under Shell Scripts.
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)
ServerName www.yourhost.com DocumentRoot /somewhere/public
BSNL 3G Speed
Posted on November 23, 2009, under Miscellaneous.
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
Search comma separated values db column in 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
<% 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
After going through, few post on pagination for the tags, this worked for me.
<% size = Upload.find_tagged_with(params[:id]).length @uploads = Upload.paginate_tagged_with(params[:id], :total_entries => size, :page => params[:page], :per_page => 1) %>