How to Add an IP address for Non-SUSE Linux

Posted in System Admin with tags on October 9, 2008 by harryche2008

These are the steps to add the second IP address to your existing network adapter under non-SUSE distributions of Linux.

  1. Become root on your system, either by logging into that account or using the su command.
  2. Change your current directory to the /etc/sysconfig/network-scripts directory with the command:

    cd /etc/sysconfig/network-scripts

  3. Check for existing network adapters with the command:

    ls ifcfg-*

    In most instances, you will see the files ifcfg-eth0 and ifcfg-lo. If you see other files with any other names and are unfamiliar with configuring TCP/IP, you may want to consult with your system administrator before proceeding or contact support@oclc.org.

  4. Edit /etc/hosts and add a line for your new address and name such as:

    24.249.162.195 ezproxy.yourlib.org

  5. To create the new interface, you will copy ifcfg-eth0 to ifcfg-eth0:0 with the command:

    cp ifcfg-eth0 ifcfg-eth0:0

    Next, edit icfg-eth0:0 and change the DEVICE line to be similar to:

    DEVICE=eth0:0

    and change the IPADDR line to be similiar to:

    IPADDR=24.249.162.195

  6. To activate the new IP address, issue a command similar to:

    ./ifup eth0:0

How to add initial files of RSpec for a new project

Posted in Ruby on Rails with tags on September 10, 2008 by harryche2008

Follow these steps and you will have a basic skeleton of rspec workspace:
rails stuff
cd stuff
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
script/generate rspec
script/generate rspec_scaffold Thing name:string

How to fix “no file to load …” errors when installing Substruct shopping cart code

Posted in Uncategorized on August 26, 2008 by harryche2008

If you’re using substruct, and installing the code following the installation directions given on its website, you may run into problems like “no file to load xxx” errors when trying to initialize the databases by running:

rake substruct:db:bootstrap

The problem is that some of the files that come along with the source have wrong file extention names, like ../extract_options.rb0000644, which really should be ../extract_options.rb, without those weird numbers. I don’t know how it got in there. But once you corrected those file names, then everything should be fine.

How to setup a Subversion repository for a new project

Posted in web project on August 26, 2008 by harryche2008

To setup SVN for a New Project

1. Find a location for the SVN repository, then do:

svnadmin create path/to/repos

2. Add something to the repository for initial import. Create a directory “myproject”, then import it:

svn import -m “New import” myproject file:///path/to/repos/myproject

3. Start a new svnserve process for remove checkout/checkin:

svnserve -d –listen-port=3691 -r /path/to/repos

*note* default port is 3690, using different port allows you to setup svn for different projects on one server

4. Right click on a Windows folder, and do a checkout svn://ip_address:port/

5. Now add a new user to allow access to svn repository, edit /path/to/repos/conf/passwd file, add a line like:

user = userpwd

Then add or uncomment the lines in /path/to/repos/conf/svnserve.conf :

anon-access = none
auth-access = read
auth-access = write

password-db = passwd

Finally, restart the svnserve process.

How to get real self.id in :finder_sql

Posted in Ruby on Rails on August 11, 2008 by harryche2008

Sometimes you will have to use :finder_sql for complicated queries in an activerecord association, there is just simply no way around it. Now it’s important to get the calling model’s id, self.id, to construct correct SQL statements.

The problem is if you’re not careful, you will get weird id number for #{self.id}, which is actually the object_id, not the id from the database record.

The trick is not let #{self.id} to be evaluated immediately in the :finder_sql, but rather later when the whole sql is generated. For example, instead of using

:finder_sql => ".... t.user_id = #{self.id} ..."

use

'.... t.user_id = #{self.id} ...'

Notice it’s in single quote now. That will cause self.id to return the real id from the database, not the object_id.

Fix: Qmail virtualdomains pop3 not working

Posted in Qmail on August 9, 2008 by harryche2008

Sometimes, after setting up a pop3 account with qmail, everything seems working except that qmail doesn’t seem to be able to receive any emails sent to your new pop3 address. One common problem is with your pop boxes setup config file .qmail. Make sure in your .qmail file for that account has:

./Maildir/

Pay special attention to the trailing “/”, if absent, then it won’t work.

How to use multiple submit buttons for Ajax forms(form_remote)

Posted in Ruby on Rails on August 1, 2008 by harryche2008

The problem with form submission through an ajax remote call in Rails is that the Form.serialize doesn’t know which submit button is clicked, and it doesn’t include the value of the button clicked in the submission data.

There are many ways to do this, including extending the native Rails submit_tag helper, but the potential problem with that is all submit_tag will generate the extra code for handling the multiple submit buttons, which isn’t something you might want.

An easy way(especially you just have one or two forms that you need to do this) is to just add a hidden field in the form, and then in your extra submit button’s onclick event, set that hidden field value to whatever you want, so that in the controller end, you can just check for that hidden field.

Example:

 

<%= submit_tag “Save changes” %> <%= hidden_field_tag(:goal_status, “”) %> <%= submit_tag “Accomplished”, :o nclick => “$(‘goal_status’).value = ‘done’” %>

Problem with installing Image Science

Posted in Uncategorized on July 30, 2008 by harryche2008

When installing Image Science, it requires FreeImage and Rubyinline. When installing FreeImage, ‘make’ reports some error saying no g++ found.

To install g++, on CentOS, do this:

yum install gcc-c++

Solution to ftp login problem with CentOS vsftp server

Posted in Uncategorized on July 29, 2008 by harryche2008

Sometimes after starting vsftpd service, you still can’t login through ftp. You keep getting errors like:

500 cannot change home directory to …

The problem is with security policy, you need to make sure “Allow ftp to read/write in the user home directories” is checked.

Or, just use

/usr/sbin/setsebool -P ftp_home_dir 1

Solution to error from “gem install mysql”

Posted in Ruby on Rails on July 29, 2008 by harryche2008

On Mac/CentOS, sometimes you get errors when trying to “gem install mysql”.
To fix this, if your Mac is intel based, do:

$ sudo -s
$ ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-dir=/usr/local/mysql

you might want to change “/usr/local/mysql” part to whatever is correct on your system.