Thursday, September 29, 2011

Install 64-bit CentOS on 64-bit Windows 7 using VirtualBox

My Laptop is ThinkPad T410 with Intel Core i5 M520 @ 2.4GHz and Windows 7 Enterprise 64-bit. I want to install a CentOS 5.6 64bit as a guest OS using VirtualBox.

But had the error "Your CPU does not suupoort long mode. Use a 32bit distribution."

It turns out that I have to turn off a BIOS setting for VT-d which is enabled by default. After that, when you create a new machine, enable Settings->System->Acceleration->Enable VT-x/AMD-v. Then everything works smoothly.


Wednesday, September 7, 2011

How to find DB2 servers in Windows?

I have a couple of DB2 databases configured in a machine and the original ODBC profile file cannot be found. How can I know where is the server for a database? Control panel-> Administrative Tools-> Data Sources (ODBC) doesn't provide the host.

Actually you can use DB2->Set-up Tools->Configuration Assistant. When it starts, click menu Configure -> Export Profile -> All ...

Search the node of your DB in the profile file, then you will find the host name or ip address.

[NODE>MYDB]
ServerType=DB2LINUX
Nodetype=U
Protocol=TCPIP
Hostname=10.116.152.112
Portnumber=50000
Security=0


Chrome and NTLM authentication

There is an IIS web server in my company network. I did use Chrome on my Windows machine to access that web site without providing my credentials. However, after I did some change some where, it has been asking me the user name and password since then.

Finally I figured out why. Chrome uses Windows "Internet options" for NTLM authentication. If you place the web site in "Trusted sites" and Chrome won't try NTLM authentication. Only the web site in "Local Intranet", Chrome will use NTLM authentication and you can access that site without credentials.

Transfer database connections between two Eclipse workspaces

I have two Eclipse workspace A and B, and created several database connections in workspace A. How can I get all those connections set up in workspace B without do it one by one?

  1. Go to workspaceA/.metadata/.plugins/org.eclipse.datatools.connectivity
  2. Copy ServerProfiles.bak and ServerProfiles.dat to  workspaceB/.metadata/.plugins/org.eclipse.datatools.connectivity
  3. Restart Eclipse

JRuby Rails 3 render a file on a windows server

I want to render public/401.html if the user is not authorized to access the web site.

My environment is jruby 1.6, rails 3.0.5, and tomcat 7.0.11 on windows.

And I found the code from "JRuby cookbook"

PUBLIC_DIR = if defined?($servlet_context)
$servlet_context.getRealPath('/')
else
"#{RAILS_ROOT}" + '/public'
end

Unfortunately this code still didn't work, still got "Missing template".

The reason is windows path. PUBLIC_DIR will be "c:/tomcat/webapps/myapp" and the file is "c:/tomcat/webapps/myapp/401.html". When rails searches the view paths, it tries to add each item in view paths as a prefix of your file. One of the view paths is "c:/", then the path which rails tries to search looks like "c:/c:/tomcat/webapp/myapp/401.html". Of course, Rails cannot find the file.

$servlet_context.getRealPath('/').gsub(/^\w:/, "").gsub(/\\/, "/")