Unix Bash Coloured Prompts
| Posted by watashii | Filed under UnixTo display coloured prompts upon user login (on Unix Bash shell, PuTTY client), perform the following modifications:
- Unix login and open the user’s profile in the home directory, eg /home/username/.profile
- In the .profile, add the following entry in a new line to execute the bash shell upon login, eg /usr/bin/bash
- The bash shell will refer to a .bashrc file. If its not there, create it, eg /home/username/.bashrc
- 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: bash, bashrc, color, profile, prompt
Weblogic Portal – Create Streaming Desktop Page Definition Error
| Posted by watashii | Filed under Programming, WebGot 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: error, portal, streaming desktop, weblogic
Subversion – Allow Author Name Logging
| Posted by watashii | Filed under Programming, SoftwareTo 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:
Tags: eclipse, hook, subversion, subversive, svn
Unix Shell – Check If Directory Is Empty
| Posted by watashii | Filed under Programming, UnixHere 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: directory, empty, shell, unix
Java Send Email (In a Jar)
| Posted by watashii | Filed under Programming, WebStep 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: classpath, jar, java, mail
Windows Vista Aurora Effect Using Photoshop (Tutorial)
| Posted by watashii | Filed under PhotoshopHere 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)
Tags: aero, aurora, Photoshop, tutorial, vista
Start & Stop Weblogic Without Username & Password
| Posted by watashii | Filed under Oracle, WebIn 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)…
Tags: encrypt, password, security, weblogic
Weblogic Portal Authorization – Get and Check User’s Roles
| Posted by watashii | Filed under Programming, WebThe 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: authentication, authorization, portal, roles, weblogic
Getting the HttpServletRequest from PortletRequest Object
| Posted by watashii | Filed under Programming, WebIn 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: javax, jsf, portlet, request, response, servlet, weblogic portal
IOGraph – Capture Mouse Movements Into Art
| Posted by watashii | Filed under SoftwareIOGraph 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!







