Friday, August 04, 2006

Generate Self signed Java JKS Keystore using input from Batch file

Here is a batch file used to create your self signed Java keystore for SSL

Often you encounter a situation where a BATCH file, much the same as a shell script, will do the job as your installer or configuration tool.


@echo off
cls
echo SSL Certificate Generator
echo.

SET /P MACHINE_NAME=Enter machine name or Q(Quit)

IF %MACHINE_NAME%==q goto end
IF %MACHINE_NAME%==Q goto end

echo Generating certificate for machine %MACHINE_NAME%

keytool -genkey -alias %MACHINE_NAME% -dname "CN=%MACHINE_NAME%, OU=OpenLogbooks, O=OpenLogbooks, L=Lichfield, S=Staffordshire, C=UK" -keyalg RSA -keypass password -storepass password -keystore mykeystore.keystore
keytool -export -alias %MACHINE_NAME% -storepass password -file mykeystore.server.crt -keystore mykeystore.keystore

:end

Monday, July 17, 2006

Bash Shell, search for a file

This is not a *nix blog, but the more I work with deploying and managing the deployment of Ajax framework based applications into the same environment I do find myself resorting to Shell scripts.

Example:
I need to find the name of the ear file being deployed

for ent in dist/*
do
if [ "$ent" != "${ent%.ear}" ]
then
echo processing $ent ear file
# take everything from before the .ear input from
# ent variable and store it in app_name
app_name=${ent%.ear}
fi
done

Monday, July 10, 2006

AJAX and WEB2.0 Frameworks

For years there have been hundreds of Quick cool effect javascript libraries and script collections around, but now there are several brilliantly designed and developed open source toolkits and frameworks available. Some of which work hand in hand with eachother. Like the NetBeans jMaki project shows the Yahoo and the Dojo toolkits working together in one deployment

Windows Explorer Tip...

Use some of the the Windows Explorer switches to open Explorer in the Folder View with the specific folder selected.

C:\WINDOWS\explorer.exe /e,/select,D:\eclipse\workspace

add the /root switch to make this the Root folder in the Folder pain

C:\WINDOWS\explorer.exe /e,/select,/root, D:\eclipse\workspace

Monday, May 08, 2006

To SED or to PERL

I found a feature in SED where your regular expression delimeters are not required to be / they can be anything, as long as they are paired up.

Search and replace a string in a file when the new string contains forward slashes '/' as in a file path


Using SED:

sed -e 's&@ORACLE_BASE@&'$ORACLE_BASE'&g' test.txt > test2.txt

[oracle@server scripts]$ clear
[oracle@server scripts]$ cat test.txt
Peter says, "the oracle base is at: $ORACLE_BASE"
[oracle@server scripts]$ sed -e 's&@ORACLE_BASE@&'$ORACLE_BASE'&g' test.txt > test2.txt
[oracle@server scripts]$ cat test2.txt
Peter says, "the oracle base is at: /u01/app/oracle"
[oracle@server scripts]$


perl -p -i.bak -e 's{\@ORACLE_BASE\@}{$ENV{ORACLE_BASE}}' test.txt

Sunday, March 12, 2006

AJAX, , WEB 2.0 or just plain Web Development

No more Internet Options and multiple clicks to clean your browser caches....
A great utility to prevent this is diskclean found at http://www.robertenfemke.nl/~diskclean/

All of the J2EE developers I have worked with all end up touching some HTML Renderer at some time or another. You find that they still want a JSP to quickly test a component. Why spend endless time with a complete object model when you just want a Harness for some of your code.

In comes the annoying Browser cache, great to ensure performance a prevent overloading of you webserver and J2EE containers, but horrendous when you write endless lines of code and you just can't see any changes.

In comes DiskClean to the rescue, you can find it at http://www.robertenfemke.nl/~diskclean/

Create a quick launch short cut and run it to clean everything, or run it interactively and clean exactly what you want
"C:\Program Files\DiskClean\dclean.exe" /q

Monday, March 06, 2006

Use Regular Expression to retrieve a substring

Use regular expressions to retrieve a substring, the match ([{}:x0-9a-f]*) below retrieves any substring of characters matching the any greedy match of characters within the square brackets...

String search = "The beginning part this is the substring which should be retrieved and here is the end part";
Pattern pattern = Pattern.compile("The beginning part ([x0-9a-f]*) and here is the end part");
Matcher match= pattern.matcher(search);
String result = "nothing":

if (match.matches()){
result = match.group(1);
}
else{
return null;
}

System.out.println("Result of the match: " + result);

OUTPUT: Result of the match: this is the substring which should be retrieved


Sunday, March 05, 2006

100% CPU Usage in IE6

Just a few lines of HTML an CSS to get IE to utilise 100% CPU...
http://www.sunpig.com/secondbest/2006/02/100_cpu_usage_in_ie6.html

Use JavaScript don't re-invent it.

Something that got me realising that my JavaScript was probably rewritting elements of JavaScript which are already provided by the Scripting Engine (ECMA Script) . It may be an entry about DHTML and related libraries, but it would still serve as a reminder to make sure your Web 2.0/AJAX solution isn't over the top...

http://www.digital-web.com/articles/keep_javascript_simple/
... They should remember that JavaScript is not Java. It is a programming language in its own right with its own purpose, functionalities, and structures. It does not need to become Java either. If they want to write Java they should write Java. If they want to write JavaScript they should learn how to write it properly.... also see
http://www.quirksmode.org/