Maths Fun Again .. Again
Some of the folks answered this in the comments to my previous entry as the answer to x being equal to
. However if that is true then what is the value of x in the following equation?
Getting interesting now I guess :-)
Posted by insidemyhead [Personal] ( July 27, 2007 09:17 PM ) Permalink | Comments[6]
How about a Semantic Community Portal?
Community can be defined as a group of users having common interests. As organizations become highly dynamic and the people that join them become more geographically dispersed, the need for improved ways to share and distribute data and information amongst the community or organization members has increased dramatically.
Speaking in terms of the Semantic Web, these community members share similar ontology items since in most probability their cultural backgrounds, work activities etc might be similar. "Semantic community portals" can make use of Semantic Web technology and shared community terms to create connections between people and people, and also between people and the information that they produce.
So how exactly would you define semantic community portal?
Orkut and LinkedIn are examples of community web portals where the people and their relationships were clearly defined using online social networking. However there is a strong connection between these social networking services and semantic community portals. For example consider Orkut or Linkedn using the FOAF ( Friend of a Friend ) ontology to describe its members profile and their relationships. This will bring these now separate social networking sites to inter operate with each other. This will help in bringing the people together in a 'universal social network'. For this to become a reality more and more of these social networking sites need to start using the FOAF and other related ontologies, in an attempt to make the data within them distributed and decentralized.
The onltologies that are typically most commonly used by the community web portals are the ones used to define people (vCard, FOAF) and documents ( RSS). However staying within these ontologies is far too limited for the currently evolving semantic web.
SIOC is an initiative that seems to be a step in the right direction from the semantic community portal perspective. Basically the SIOC tries to capture as much information as possible about the community web sites and the information that is contained within them. Have a look at the two figures below taken directly from the SIOC web site which clearly demonstrate the future of the semantic community portal.
SIOC has the ability to link all sorts of entries like Blogs, Forums, Mailing Lists from and amongst various community sites. Using SIOC we will have the ability to make the information contained within links in HTML documents, discussions in forums, trackbacks, replies, followups etc available explicitly for machine-processing. (That is the goal of the semantic web )
However, a full-fledged framework for community-driven ontology management should go beyond simple tagging and should enable merging of community portals with established practices for ontology management. The objective of community-driven ontology management is to provide means for a large number of users to build and adopt the Semantic Web, via practices for ontology management all in the community space. Such a portal will allow end users to define the structure of the content (i.e., develop ontologies), populate ontologies and define the ways in which this content is managed on Semantic Web community portals.
Reference: Berners-Lee, T., Hendler, J., & Lassila, O. (2001). The Semantic Web : Scientific American
Posted by insidemyhead [Sun] ( July 23, 2007 10:51 PM ) Permalink | Comments[0]
Maths Fun Again
Given that :

What is the value of x?
Posted by insidemyhead [Personal] ( July 20, 2007 08:17 PM ) Permalink | Comments[2]
Locker Mania - Answer
Although there were solutions to this provided by Murali and Eric in the comments section and they are correct. Just posting it here for more general viewing. BTW, I went through the C program written by Eric, it was really nicely written program with neat output as well. Really nice!
Anyway back to the answer.
The state of any locker N will remain unchanged from the beginining as long as N = P * Q, and P and Q happen to be distinct (There can be multiple combinations of P and Q). That means, given the 10th locker, its state will be toggled by the 1st and the 10th member. Its state will again be toggled by the 2nd member and then again by the 5th member, thus its state remaining unchanged. This is since the factors of 10 are (1,10) and (2,5)
For locker number N where N =P*Q, and P and Q are same, i.e locker numbers which are perfect squares, there will only be one state change and hence are the ones which will remain open in the end.
Example, locker number 9. Its state will be changed by (1,9) member and again by the (3,3). But since the 3rd member can only toggle once, we can see that the state if the 9th locker will be open ultimately. Same for all perfect squared numbered locker till 100.
Posted by insidemyhead [Personal] ( July 20, 2007 12:50 PM ) Permalink | Comments[0]
Locker Mania
There is a locker room in the club and they are numbered from 1 to 100. There are 100 members of the club who will enter the locker room in the following sequence. When the first member enters, he opens all the lockers. When the second member enters the locker room, he closes all even numbered lockers. When the next member enters the room, he toggles the state of every locker which is a multiple of 3.
This process continues till all the 100 members have been through the locker room. At the end of this process, which are the lockers that are open?
Posted by insidemyhead [Personal] ( July 17, 2007 07:40 PM ) Permalink | Comments[4]
Secure Remote Access (SRA) in 7.1
Sun Java Systems Enterprise Secure Remote Access version 7.x
The 7.0 release of Portal Server saw the introduction of the JMX Administration. All administrative interfaces in portal now used mbeans to manage the various servers and configuration. A single command line interface was provided for all the administrative activities ( viz. psadmin). The Portal Admin Server (PAS) is the admin server that holds all the configuration of the various mbeans known to the JMX Server. The PAS held its configuration/bootstrap information in LDAP.
Gateway, the main workhorse of Secure Remote Access (SRA) component of Sun's JES stack, resides in the DMZ ( De Militrized Zone) and hence doesnt or rather shouldn't have direct access to LDAP which is inside the corporate firewall. So as a workaround in 7.0 there was a requirement of installation of a local directory server on the Gateway host. This directory server was not required by the Gateway process per se, but was required to bootstrap the administrative interface of Portal Server (PAS). This local directory server contained only the bootstrap information to startup PAS and nothing else. Once the GW is started up using psadmin, this local directory server on the gateway node could very well be shut off and that wouldn't affect the gateway at all. This (installation of a local directory) however was a major restriction and was a big no no.
So in 7.1, release this restriction was done away with. The PAS module on the local gateway box uses a file based JNDI mechanism to load its configuration information and hence no need for a local LDAP on the gateway box. So far so good.
However it recently came to my attention that there was a bug in which it was reported that the LDAP port between GW and the Portal Server was required to be opened. I have traced the issue down and have done the fix for that. It should be checked in by EOD tomorrow. Once this fix is done in the code
base and the product patched with the fix, the flow of traffic from an administrative perspective should follow exactly the diagram below.
So in 7.1 the scenario, as far as the GW, Portal nodes and the firewall is concerned looks pretty much like this. Note this figure is only for as far as the administration of GW is concerned. What I mean by that is, executing of any SRA related psadmin commands on the gateway node. Once the step 8 is completed in the figure below, the gateway starts up and starts serving pages from the portal ( ofcourse the HTTP/HTTPS port for the portal server needs to be opened in the firewall as well, but like I mentioned the figure essentially talks about the admin interface only.)

Posted by insidemyhead [Personal] ( July 11, 2007 10:59 PM ) Permalink | Comments[2]
New Version of Eclipse Portal Pack with Action Support
I have uploaded the source code for the new version of Eclipse-Portalpack. I have been playing with the idea of making portlet development easy... and not just for rendering the view mode or the edit mode of the portlet but also in processing actions easily from the portlets. To this extent this is my first attempt in making this happen. Check it out and let me know if you find it useful and suggest any enhancements requests if any. I will be enhancing this further myself ( as there are areas I think that need it, but do let me know your suggestions )
Okay back to the new version. The new version supports the following new things :
- It is now built on the latest version of JAXB .i.e version 2.1.
- It has a new feature of adding a new portlet action very easily to your portlet, and to implement the action you just need to implement one method "execute()" in your action class and almost no code change to your portlet class is needed. You just specify what page to go to once the action is processed and the portlet has the code to automatically send you to the new page once the action is executed sucessfully. In case of an error that happens in your action's "execute()" method, the portlet will redirect you to the error page that gets created automatically for you when the portlet project was initially created.
Enhancements to this :
There are a couple of enhancements that I am still working on. If you think you can contribute to any of these please join in and contribute.
- There are enhancements to the GUI for action creation needs some work.
Suppose I want to develop a simple portlet which shows a form to collect some inputs from the user. The form might ask the user for his first name, last name and the email address. When the user submits this form, the data is collected at the server, and persisted to a data store. Once the data is persisted the user is shown a thank you page. Now assume the above needs to be done in a portlet. The scenario described above can be done using a portlet as shown below in the picture:

When developing this portlet the developer needs to write code in his processAction() method to do the following :
- Recognise the type of action this request is. In our case there is only one action so this case is simple.
- Collect the data from the form and populate a bean with that data.
- Put the bean in session data to be accessed in doView() mode.
- Now when the portlet container calls the doView() method, access the bean stored in session in previous step and do the actual action
- Dispatch the request to the destination JSP page.
All the above needs to be done by the developer whenever he writes a particular action. ( This is one way of doing this )
I wanted to make this a little easier to do, so I have added new code to the Eclipse Portal Pack project to make this easier. This is a very early version of it, so please bear with it, as I make further improvements. But feel free to try it out and give suggestions, or better still join on the project and contribute.
Developing the above portlet with the Eclipse Portal Pack Project
A screencast of creating a simple portlet project and a sample portlet is shown here.
Now that we have a sample portlet ready. Let's go about adding this new action that we wanted. Let's first create the JSP page that will show the form to the user in the view mode. By default the project would have created a JSP for the view mode called view.jsp in your /WEB-INF/jsps/ folder. Open this JSP file and add the following code to it.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<%@page import="javax.portlet.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects/>
<portlet:actionURL var="portletUrl" />
<form id="form1" name="form1" method="post" action="<%=portletUrl.toString()%>">
First Name : <input type="text" name="fname" type="text"><br/>
Last Name : <input type="text" name="lname" type="text"><br/>
Email : <input type="text" name="email" type="text"><br/>
<input type="submit" name="Submit">
</form>
The lines in bold indicate the form that will be displayed to the user in the view mode. It presents the user with fields to accept his first name, last name and email address and then there is the submit button which submits the form to the portlet via the portlet:actionURL variable defined above.
Now this is where the new Eclipse Plugin can help you in making your life easier. Let's call the action to collect the user data and put it to datastore as "CollectData". Right click on the portlet project in Eclipse, and down at the bottom you will see a menu entry called "Portlets->Create new Portlet Action" as shown below in the picture.

So here is what we want to do, we want to define a new action called CollectData, which we want implemented by a class of our choice, in this case lets say com.sun.portal.test.actions.CollectDataAction, and when our action is complete we want the portlet to take us to the page defined in /WEB-INF/jsps/done.jsp. So fill up the dialog box as shown below and click Ok. ( Like I said this is the first version so I haven't added any error checking as of yet, it will be coming pretty soon though ).

On clicking Ok, you will see a new action class called CollectDataAction created under the package com.sun.portal.test.actions. Open this class in Eclipse and it will appear as below:
package com.sun.portal.test.actions;
import javax.portlet.ActionRequest;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.sun.portlet.core.actions.ActionExecuteException;
import com.sun.portlet.core.actions.BaseActionFormBean;
public class CollectDataAction extends BaseActionFormBean { public CollectDataAction(ActionRequest request) {
super(request);
}@Override
public boolean execute(RenderRequest portletRequest,
RenderResponse portletResponse) throws ActionExecuteException {
// Put your logic of executing the action for this request here.
return true;
}
So as you can see, all you need to do is implement the method "execute()" in your CollectDataAction.java class. In the execute() method, you can access the form parameters that your view.jsp sent in as getParameter(String), getParameterNames() and getParameterValues(String) as usual.
Also to invoke this action the only other thing you will need to do is, add a hidden field in your view.jsp form called ACTION_NAME, and its value must exactly be the action you want executed when the form is submitted, which in our case is "CollectData". So our view.jsp page in completion will look as below :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<%@page import="javax.portlet.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects/>
<portlet:actionURL var="portletUrl" />
<form id="form1" name="form1" method="post" action="<%=portletUrl.toString()%>">
First Name : <input type="text" name="fname" type="text"><br/>
Last Name : <input type="text" name="lname" type="text"><br/>
Email : <input type="text" name="email" type="text"><br/>
<input type="hidden" name="ACTION_NAME" value="CollectData">
<input type="submit" name="Submit">
</form>
The only changed line is shown in Bold and Italic.
That's all that is needed to implement this action from your side. Ofcourse, you need to write the done.jsp file to which the portlet will dispatch the view after the action is executed.
To summarise, to implement any new action, all you need to do in addition to writing the source JSP and the target JSP is :
- A hidden variable called ACTION_NAME in the source JSP page form.
- Implement the execute() method in your Action Bean.
Rest of the stuff is handled for you!!
Let me know if you like it, by posting your comments.
Posted by insidemyhead [Sun] ( July 03, 2007 04:03 PM ) Permalink | Comments[46]
Possible answer to the 123 black hole
Here is a explanation of the mathemagical black hole (123) in my opinion. If we consider the transformation on x as a function f(x), such that f(x) = E(x) O(x) T(x)
where E(x) = Number of even digits in x, O(x) = Number of odd digits in x and T(x) = Number of digits in x
Then for all x,
f(x) < x
So eventually as we recurse this process, at some point f(x) will fall below 1000. In that case the only possibilities for E(x) O(x) and T(x) are
1 2 3
2 1 3
3 0 3
Each of the above in the next iteration will give 123. Hence the proof.
Posted by insidemyhead [Personal] ( July 03, 2007 02:39 PM ) Permalink | Comments[0]
Another Mathemagical Black Hole
Read about another mathemagical black hole.. Really interesting one.
Take any natural number, treat it as a string. For example: 24,89,62,698.
- Count the number of even digits. In this case 7 even digits.
- Count the number of odd digits. In this case 2
- Count the total number of digits. In this case 9
So the new number now is 729. Repeat the above process. Even digits (1), odd digits (2), total digits (3). So the new number is 123. And now any more iterations will return 123 only. So in this case 123 is the mathemagical black hole.
All numbers in this universe are drawn to the number 123 by this process. Never to escape. Try it out.
Posted by insidemyhead [Personal] ( July 02, 2007 07:49 PM ) Permalink | Comments[0]

