Unix Bash Coloured Prompts

| Posted by watashii | Filed under Unix

To display coloured prompts upon user login (on Unix Bash shell, PuTTY client), perform the following modifications:

  1. Unix login and open the user’s profile in the home directory, eg /home/username/.profile
  2. In the .profile, add the following entry in a new line to execute the bash shell upon login, eg /usr/bin/bash
  3. The bash shell will refer to a .bashrc file.  If its not there, create it,  eg /home/username/.bashrc
  4. Add following entries in the .bashrc to enable the coloured prompt; showing the username, hostname and working directory:
    # Colored Prompts
    STARTGREEN='\[\e[0;32m\]';
    STARTBLUE='\[\e[1;34m\]';
    ENDCOLOR="\[\e[0m\]";
    PS1="$STARTGREEN\u@\h$ENDCOLOR:$STARTBLUE\w$ENDCOLOR $ ";

Tags: , , , ,

Weblogic Portal – Create Streaming Desktop Page Definition Error

| Posted by watashii | Filed under Programming, Web

Got the following error when (re)creating a streaming desktop from an updated .portal file, using the Create Desktop Wizard on Portal Admin Console.
javax.ejb.EJBException: SQL Error while trying to createPageDefinition: SQL [insert into PF_PAGE_DEFINITION ( PAGE_DEFINITION_ID, MARKUP_DEFINITION_ID, IS_PUBLIC, IS_HIDDEN, INTERSECTION_ID, PAGE_LABEL, WEBAPP_NAME) values (?,?,?,?,?,?,?)] database error code [25,222] SQL state [22028] .; nested exception is: java.sql.SQLException: Data exception -- row already exist in index AX1_PAGE_DEF on table PF_PAGE_DEFINITION.
To temporarily bypass this error this so the streaming desktop can be created with the wizard, remove all the Pages manually from the Library.

The problem is one of the Page definition(s) in the .portal file is corrupted which prevents the library page resource from being refreshed.  You will need to work out which page is causing the problem, then the redo the page in the .portal file via Weblogic Portal Workshop.

Tags: , , ,

Subversion – Allow Author Name Logging

| Posted by watashii | Filed under Programming, Software

To log the author name when trying to check-in files using Subversive/Eclipse over SVN, switch to SVN Repository Exploring perspective > right-click on your repository > edit the Location Properties > Advanced tab > and enable Override author name:


Read the rest of this entry »

Tags: , , , ,

Unix Shell – Check If Directory Is Empty

| Posted by watashii | Filed under Programming, Unix

Here is a simple unix shell command to check if a directory, $dir, is empty.

export $dir=/tmp/myfiles/
if [ "$(ls -A $dir)" ];
then
    echo "$dir NOT Empty";
else
    echo "$dir IS Empty";
fi

Tags: , , ,

Java Send Email (In a Jar)

| Posted by watashii | Filed under Programming, Web

Step 1

Download the JavaMail and Activation Framework library .jar files

• If using Java SE, you’ll need to download JavaMail, eg mail-1.4.3.jar

• If using below Java SE 6, you’ll need to download and include Activation Framework, eg activation-1.1.1.jar
Read the rest of this entry »

Tags: , , ,

Windows Vista Aurora Effect Using Photoshop (Tutorial)

| Posted by watashii | Filed under Photoshop

Here is a very simple tutorial for remaking the beautiful Windows Vista Aurora wallpaper effect, using Photoshop.  Full credit goes to tutorial9 for the steps which I followed.

My PSD source files are available below, if interested. Or click-on to follow my tutorial.

[aurora_watashii.zip] 1.6M
[aurora.png] 411kb (1900×1200)

Read the rest of this entry »

Tags: , , , ,

Start & Stop Weblogic Without Username & Password

| Posted by watashii | Filed under Oracle, Web

In a Weblogic Server domain running in production mode, username and password is always prompted during startup and shutdown (admin server and managed servers).  To bypass this manual step, we can store the username and password credentials in the boot.properties file (although this is somewhat the same as development mode)…

Read the rest of this entry »

Tags: , , ,

Weblogic Portal Authorization – Get and Check User’s Roles

| Posted by watashii | Filed under Programming, Web

The Authorization class provides runtime methods for security policies and roles checks.  The following code fragment obtains the set of roles the logged-in user belongs to.  Note the user must be authenticated first, see Authentication class.

String entAppName = ApplicationHelper.getNonVersionedAppName();
String webAppName = ApplicationHelper.getWebAppName(request);
EnterpriseRoleResource resource = new EnterpriseRoleResource(entAppName,webAppName,EntitlementConstants.P13N_ROLE_POLICY_POOL,"");
Map userRoles = Authorization.getRoles((P13nResource) resource);
if (Authorization.isUserInRole("Admin", userRoles)) {
	return true;
}

Global and Enterprise Application roles are obtained using EnterpriseRoleResource.  For Global, Enterprise, and Web Application roles, use WebappRoleResource.

com.bea.p13n.security.Authentication

Tags: , , , ,

Getting the HttpServletRequest from PortletRequest Object

| Posted by watashii | Filed under Programming, Web

In my JSF / icefaces based portlet running on Weblogic Portal, I got the following error:
com.icesoft.faces.webapp.http.portlet.PortletExternalContext cannot be cast to javax.servlet.http.HttpServletRequest

It turned out I cannot simply obtain the HTTPServletRequest object like this:

FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest portletRequest = (HttpServletRequest) ctx.getCurrentInstance().getExternalContext().getRequest();

In a portlet environment, to get the request/response objects, we must obtain the javax.portlet.PortletRequest/PortletResponse objects instead (which inherits methods from java.servlet.HTTPServletRequest/HTTPServletResponse):

FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();

However sometimes we may require the HttpServletRequest / HttpServletResponse object.  To obtain this, we must extract an attribute from the PortletRequest / PortletResponse object:

FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();
HttpServletRequest httpServletReq = (HttpServletRequest) portletReq.getAttribute("javax.servlet.request");

Tags: , , , , , ,

IOGraph – Capture Mouse Movements Into Art

| Posted by watashii | Filed under Software

IOGraph is a simple Java application that captures your mouse cursor movements on the screen and plots them on to a blank canvas picture.  All you need to do is run the application, minimize it, then perform your usual routines on your computer.  After a while you will see a cool looking graphic art that you can export.

The capture displayed here was taken for 1 hour at work on my dual monitor computer.  The large black dots represent how long the mouse have paused;  the longer, the larger.  Notice my right monitor was hardly ever used!

Tags: , , ,