Friday, March 12, 2010

IBM Cloud

It looks like arbitraty ports are firewalled by IBM (other than port 80 and 22 and maybe some others), so when I wanted to connect to one of my machine in the IBM Cloud on port 18080 http for example, I have to setup a reverse proxy for it.

<Proxy http://mywebsite:18080 >
Order deny,allow
Deny from all
Allow from 123.123.123.123
</Proxy>

ProxyRequests Off
ProxyPass / http://localhost:18080/
ProxyPassReverse / http://localhost:18080/

Sunday, March 7, 2010

Javascript stop event bubbling and stop browser default action

// stop event bubbling
function stopBubble(e) {
if( e && e.stopPropagation ) {
e.stopPropagation();
} else {
//IE
window.event.cancleBubble = true;
}
}

// stop browser default action, i.e, clicking an html link will open up that link.
function stopDefault(e) {
if( e && e.preventDefault )
//Other than IE
e.preventDefault();
else
//IE
window.event.returnValue = false;
}

function loadLi() {
var li = document.getElementsByTagName("li");
//alert(li.length);
for ( var i = 0; i < li.length; i++ ) {
li[i].onmouseover = function() {
this.style.backgroundColor = 'blue';
};

li[i].onmouseout = function() {
this.style.backgroundColor = 'white';
};
}
}

function loadAnchor() {
var anchor = document.getElementsByTagName("a");
for ( var i = 0; i < anchor.length; i++ ) {

anchor[i].onmouseover = function(e) {
this.style.backgroundColor = 'red';
stopBubble(e);
};

anchor[i].onmouseout = function(e) {
this.style.backgroundColor = 'white';
stopBubble(e);
};

anchor[i].onclick = function(e) {
iframe.src = this.href;
return stopDefault(e);
}
}
}

Spring Framework + RMI + JBoss

Use RMI port 1199 (other than the default port 1099, JBoss RMI) with org.springframework.remoting.rmi.RmiServiceExporter.

<bean id="escortLocationService" class="com.don.remoting.EscortLocationServiceImpl" >
</bean>

<bean id="rmi" class="org.springframework.remoting.rmi.RmiServiceExporter" >
<property name="service" ref="escortLocationService" />
<property name="serviceName" value="EscortLocationService" />
<property name="serviceInterface" value="com.don.remoting.EscortLocationService" />
<property name="registryPort" value="1199"/>
</bean>

<bean id="escortLocationServiceClient" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://127.0.0.1:1199/EscortLocationService" />
<property name="serviceInterface" value="com.don.remoting.EscortLocationService" />
</bean>

<bean id="escortLocationClient" class="com.don.remoting.EscortLocationClient" >
<property name="escortLocationService" ref="escortLocationServiceClient" />
</bean>

Friday, March 5, 2010

Oracle multiple case select statement

In a table, I have 3 columns (checkbox1, checkbox2, checkbox3) representing values about "Where does the knowledge come from?".
if checkbox1 == 1, that means the knowledge comes from "My_Course",
checkbox2 -> Internet,
checkbox3 -> Staff.

if the checkbox1,2,3 == 0, then it's empty string.

Basically I want to concatenate values from multiple columns into one value "Know_from_where":

select student_type,
(case checkbox1
when 1 then 'My_Course, '
when 0 then '' end ) ||
(case checkbox2
when 1 then 'Internet, '
when 0 then ''
end ) ||
(case checkbox3
when 1 then 'Staff, '
when 0 then '' end ) Know_From_Where
from infolit

Wednesday, March 3, 2010

springsource tool suite oracle jdbc driver + maven2 depend


<repository>

<id>repo1 maven org</id>

<name>repo1 maven org</name>

<url>http://repo1.maven.org/maven2</url>

</repository>



<dependency>

<groupid>ojdbc</groupid>

<artifactid>ojdbc</artifactid>

<version>14</version>

</dependency>




Then you have to download ojdbc14.jar from oracle website (or wherever) and do:
mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -Dpackaging=jar -Dfile=/path/to/ojdbc14.jar

Xml re-generated using http://www.simplebits.com/cgi-bin/simplecode.pl?mode=process

Friday, June 12, 2009

setting up hive + hadoop 0.20.0

Some errors:
I got FAILED: Unknown exception : Wrong FS: hdfs://10.1.1.x:9000/tmp/hive-hadoop/1201106067, expected: hdfs://slave:9000,
the solution: modify hadoop/conf/slaves to have the ip address 10.1.1.x (previously it was localhost

Curtin v1.0

- Facilitate an online forum for each class, where materials are shared, students can discuss problems, give reviews, see photos..and the forum can be accessed from facebook? so starting small by doing what?