Category : middleware

web resilience and dns round robin

Nice piece of work on recent browsers resilience and dns round robin

the fade anything technique


You want to add something flash to your site.
A color loads, which you then want to change


Well cool “Fade Anything Technique”!

Really simple implementation, just copy fade anything and then any divs, etc with an id
of fade-xxx will fade from that color. Many more options, check out these highly recommended articles.


<script type="text/javascript" src="/fat.js">
<div style="width: 600px; border:1px dashed #23932B; padding: 10px;" id="fade-23932B" class="fade-23932B">

Troubleshoot Apache Startup


Here are a few tips, if you are having problems starting apache.

1. A common problem is trying to start Apache on a restricted port. This is where you configure apache to listen on port 80, changing the default 8080.

2. Another problem can be defining logging into directories that don’t exist.

3. If you get an error like User not allowed, or Group not recognized, etc – this is the User and Group statements within your apache configs.


1. On UNIX this is considered restricted and generally only available to the root user. On windows it is also commonly restricted, so requires an admin account.

2. This will generally output an error along those lines, into apache’s top level error log. Failing that you can try running apache with truss (search my site to find syntax) on Solaris, strace on Linux and trace on AIX.

3. You need to change to match the user running the command – or if root, the delegated user and group user is in.

Another tip is to run /etc/init.d/httpd configtest – which will effectively run httpd -t to syntax check the config. You can also perform a -S which checks and prints your virtual hosts.

If you getting compliants about modules, try running httpd -l to see compile in mods.


Nothing here – please see Solution 🙂


[tags]apache, Unix Coding School[/tags]

epoch generation and converting


You want to generate the current epoch offset for UNIX. The count forward since 8am on 1st Jan 1970.

Or conversely you want to see the date and time, for a given epoch offset.


You can use perl’s mktime or localtime – or just use my tools below.


Either enter epoch:

Or enter the date (plus time)


epoch offset or date will appear here


[tags]epoch, unix, 2038[/tags]

  1. techno park epoch year 2038 problem

Free online vertical text image creator

Enter the text to super-impose here and your colours





image will appear here

If you want to see the code here it is | Free online vertical text image creator

Vertical label creation


You want to generate a vertical image, with text over the top.


Here is some code I wrote, which is used extensively on my sites:



Give it a blast on this site, like this:

Automatically calculates size required. You can also add font=# – where # is 1 to 5, like this:

I’ve now created an online tool, using this code

libcurl lookup taking long time


You notice for some hosts curl and/or libcurl are taking 7 or so secs to lookup the host. But nslookup or dig respond almost immediately.


Try doing curl -4 -w “time_namelookup: %{time_namelookup}n” …. and try without the -4. If you see drastic differences, you could be falling foul of the IPV6 bug. To work around this, you can either just use -4 with curl or set CURLOPT_IPRESOLVE with libcurl.


I spents hours and hours and hours, trying to get this working with libcurl and perl. It turned out I need to upgrade to WWW::Curl::Easy version 3.0 – as opposed to version 2. Do a search on for Curl and it will tell you how to check your version.

Then if you like me upgrade, you need to also modify all your code from: Curl::easy::setopt($curl, … to $curl->setopt( …


10 simple techie tips for lazy people


Don’t know about you, but I’m generally quite lazy. Why roll the mouse and click the screen,
when with a quick control c I can copy some text. 🙂


Learn 10 simple short cuts, which can save you hours.



Copy some text – select it then control c
Now it is in the clipboard.


Click where you want to paste it and control v to paste it. 😉

You can also right click with your mouse to cut and paste.


Minimise all windows, by holding down the windows key and press m


Kick off explorer, by holding down windows key and press e


Do a find by holding down windows key and press f


Switch between windows by holding down alt and pressing tab


Reverse tab through a HTML form, by holding down the shift key.


Open a web link in a new window, by holding down shift and clicking it


To type in a new web address, hold down alt and press d


Save a document with control s, print it with control p, undo a change with control z – sorry got carry away. 🙂


HTTP Basic Auth with HTTP headers and libcurl


Came across an interesting problem with curl.

For curl to perform HTTP Basic Authentication, it is easy to pass –user to the curl command, but harder with libcurl.

Suspect there is an attribute that can be set, but I monitor a multitude of web sites through some perl scripts and libcurl. I did n’t want to have to modify my wrapper scripts, which mesh perl hashes with the code that drives curl (via libcurl).

I do allow for headers though, having needed to pass different things through, like HTTP_REFERER, LAST_MODIFIED, etc.

Therefore I just needed to pass the HTTP BASIC Authentication through as a header.


First off you need to base64 encode the user and password.

Use Google’s tool


We then strip out the equals and pass following through to curl or libcurl:

@myheaders=('Authorization: Basic YWRtaW46YWRtaW4');

Curl::easy::setopt($curl, Curl::easy::CURLOPT_HTTPHEADER, @myheaders);

Or from the command line:

curl ... -H'Authorization: Basic YWRtaW46YWRtaW4'

Obviously you need to put your user, followed by a colon and your password – to obtain the correct base64 encoding back – strip the equals out and away you go.


Simple Basic Encryption – Main differences between algorithms





Symmetric Algo – one key to encrypt and decrypt.

Asymmetric Algo – separate key to encrypt and decrypt.

Stream ciphers – encrypt each bit in sequence.

Block ciphers – encrypt specific blocks of bits.

Hash/Message Digests – one way ciphers, create fingerprints of data.

Simple Basic Encryption – Most commonly used algorithms


Want to know the encryption short or long names.


DES – Digital Encryption Standard. Symmetric block encryption algorithm

3DES – Triple DES. Symmetric block algo – uses DES three times.

RC4 – Rivest Cipher #4. Symmetric algo uses stream encryption.

RSA – Rivest, Shamir, Adelman. Symmetric block algo.

IDEA – International Data Encryption Algo, symmetric block algo – used by PGP.

AES – Advanced Encryption Standard (Rijndael) – symmetric block algo.


Demo of des3, rc4 and aes256 – using abc123 as password and thecatsatonthemat

$ echo thecatsatonthemat |  openssl enc -des3 -a -e -k abc123
$ echo "U2FsdGVkX1/I03dG1d8bGYycfojc4x/S5uU1YIf1QRPRw+9AgKhVCw==" | openssl enc -des3 -a -d -k abc123
$ echo thecatsatonthemat |  openssl enc -rc4 -a -e -k abc123
$ echo "U2FsdGVkX1+NuZk94r5kJdFfw8gsjlO9ZV7BDXLwm+3PNg==" |  openssl enc -rc4 -a -d -k abc123
$ echo thecatsatonthemat |  openssl enc -aes256 -a -e -k abc123
$ echo "U2FsdGVkX1/bGQ0rtpGi6CjkeAyyEgQjnxkSWBQ6q7XLgAApdWHA5BdEuK24r/NY" |  openssl enc -aes256 -a -d -k abc123


Wiki links

Creating favicon.ico


You want to create a favicon.ico from Unix.


  1. Open your image with GIMP
  2. If your image is not a square then resize the canvas with GIMP
  3. Scale the image to 16×16 pixel (Image, Scale image)
  4. Save as favicon.pnm or favicon.ppm with raw encoding
  5. Close GIMP


Then to convert favicon.pnm or favicon.ppm using the command line utility ppmtowinicon:

$ ppmtowinicon -output favicon.ico favicon.pnm


$ ppmtowinicon -output favicon.ico favicon.ppm


Kewl tip on creating a favicon.ico with ppmtowinico – thanks to 🙂

Blogging Tip – do your quotes turned to dots when pasting


One annoying thing I recently discovered, when copying code from my blogs (yes I use my own tips too! 🙂 ), quotes seem to turn into dots. Both for single and double quotes.


The answer to this was explained in a blogging book, that apparently the quotes on a keyboard refer to feet and inches – not speech! 😉

The solution is simply to use ASCII notation.


Therefore a double quote becomes &#34; and a single &#39;


Simple Basic MySql – beginning mysql mysqlshow


You want to perform command line display of mysql dbs with mysqlshow.


Is this demo, I show the options for mysqlshow.

mysqlshow is a real easy way to quickly view your dbs, tables and rows.


Show Databases

$ mysqlshow -i -u'root' -p'xxxxxx'
|   Databases   |
| demo          |
| mysql         |
| test          |

Show number of tables under each db

$ mysqlshow -v -i -u'root' -p'xxxxx'
|   Databases   | Tables |
| demo          |      1 |
| mysql         |     15 |
| test          |      0 |
5 rows in set.

Show total number of rows for each db

[[email protected] ~]$ mysqlshow -v -v -i -u'root' -p'xxxxx'
|   Databases   | Tables |  Total Rows  |
| demo          |      1 |            7 |
| mysql         |     15 |         1383 |
| test          |      0 |            0 |
5 rows in set.


Simple Basic MySql – beginning mysql db management


You want to know how to do the following, through mysql command line interface:

    Connect to the mysql daemon
    Show the databases your user has access
    Show tables defined under that db
    Show schema for given table



mysql -u'username' -p'password' -h'mysql_host'

mysql_host is optional if the daemon is running on the same host.

Show databases

show databases;

Show tables

show tables;

Describe tables

use demo;
describe demo;

For example:

mysql> show databases;
| Database |
| demo     |
| test     |
2 rows in set (0.00 sec)

mysql> use demo;

Database changed
mysql> show tables;
| Tables_in_demo |
| demo_table     |
1 row in set (0.00 sec)

mysql> desc demo_table;
| Field | Type         | Null | Key | Default | Extra |
| id    | mediumint(9) |      | PRI | 0       |       |
| day   | varchar(20)  |      |     |         |       |
| val   | tinyint(4)   |      |     | 0       |       |
3 rows in set (0.10 sec)


Simple Basic Java Software – analysing arguments from command line


You want a simple bit of java code that takes arguments from the command line and displays them.


Good demo on how to obtain and handle java arguments.

public class Arguments {

  public static void main(String argv[]) {

    if(argv.length > 0) {

      System.out.println("args exec w " + argv.length + " args");

        for(int i=0;i...


Here is a demo:

# java Arguments -a -x -y
args exec w 3 args
argv[0] = -a
argv[1] = -x
argv[2] = -y


First steps in vb scripting for windows / DOS


Starting out with a new series of tips, getting started with vb scripting. Microsoft have an excellent guide on the site, which I’ve link at the bottom of this post.


Below is the typical ‘hello world’ script


C:\Documents and Settings\Admin > copy con test.vbs
Wscript.echo "Hello World."
1 file(s) copied.C:\Documents and Settings\Admin > cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.Hello World.

Switch to a different user in MS Windows / DOS


You want to switch user from the MS DOS prompt.


Use runas

runas /?


Switch user to other id (Then just run explorer and browse to directory)

runas /user:[email protected] c:\winnt\system32\cmd.exe

Where user-id is the USER you wish to change to. For example Admin. xxx represents the hostname of the box or domain.

You can also just use local, if changing to user on the same box, like this:

C\:Documents and Settings\Admin runas /user:localmarcus "c:\WINDOWS\system32\cmd.exe"
Enter the password for localmarcus:
Attempting to start c\:WINDOWS\system32\cmd.exe as user "localmarcus" ...


Setting file permissions from command line in windows


You want to modify permissions in Windows from the DOS prompt command line.


Use cacls

cacls /?


Here are the commands to modify MS Windows/DOS files and directories.

  • Display file permissions. Replace filename with your file name.
> cacls filename
...filename            NT AUTHORITYSYSTEM:F
  • Modify permissions. Here we are granting full access to the user, replace user with desired user name.
> cacls filename /E /G user:F
processed file: C:...filename
  • Here we see the permissions have been reset:
> cacls filename
...filename           PCxxxxxxxxxuser:F


Useful PHP tool to create an image with superimposed text


You want to create an image text label.


Use GD library that can be built-in to PHP. Or just use my free on-line tool to create it, as shown in example below.

Once GD is built in – use this PHP code to generate the label.


This shows the label .

You can use this to generate black blank images, with white superimposed text over the top:

generate black blank images, with white superimposed text .. click this link, change text "label" – then save to your machine.


ssh-keygen syntax to create .ssh dirs and add an initial key

ssh-keygen -t dsa -b 1024 [ -c comment ]

MySQL backup db script


You want to back up your mysql database.


This script is good for backups, as it will generate a dump – zipped and as the day of the week is used (in the backup file name), automatically rolls every 7 days.

Run it daily or every other day. If you want a months worth, guess can just change the date command, etc.



[ $# -ne 1 ] && {
    echo "Usage: $0 db"
    exit 1

dbd="/PATH_TO_YOUR_BUS/$db.$(/bin/date +%a)"    # set the path
alias mysqldump="/usr/bin/mysqldump"            # you may need to modify this
alias gzip="/bin/gzip"                          # may need to change this too
# set your password and user
mysqldump --user=root --password=your_password $db > $dbd 
gzip --best --force $dbd
exit 0


Step by step howto – display a warning before leaving site


Sometimes there is an audit requirement, to let customers know a link is off your site and therefore you take no further responsibility for it. For example, a reference to an external associate site.


I’ve just used some simple javascript code, which is triggered by the click (onclick event). This pops up a warning, which can be accepted or rejected. Accepting goes to the desired site, whilst reject just aborts.


Or you can see it in its own page here: demo of accepting to leave a site

Here is the source code of the link:

function Terms() {'/common/demoP/popup.html','windowName','width=500,height=300');
    if (!popup.opener) popup.opener = self;

Hi there - below you'll see a link to  When you click it, a popup will appear that you need to accept to follow the link.

<a href="#" onClick="Terms()">

Here is the source of the popup:

function supressError() { return true; }

function load(url) { window.onerror = supressError;
    opener.location.href = url;

Warning you are about to leave my cool site,
only click 'Leave' if you absolutely want too! <form> <input type=submit value="Don't Leave!" onClick="javascript:self.close()"> <input type=submit value="Leave" onClick="javascript:load('');self.close()"> </form>


Step by step – HowTo implement encryption for Weblogic 6.1 (WLS6.1)


You want to implement encryption between the web server and the backend Weblogic server.


Save yourself the 8 hours it took me to debug this one! 🙂

Handed to you on a plate – clear simple and proven. 😉

Generate a self signed cert as describe in my Generating a self signed cert with openssl

One gotcha is if your WLS has only an export license, which then requires a maximum of 56bits encryption via a 512 byte cert.


Therefore you need to generate the cert like this (2 years):

openssl req -newkey rsa:512 -days 730 -keyout newreq.pem -out newreq.pem

To check if you have an export license,

grep -i export /opt/bea/license.xml

– will show something like this:

license component="SSL/Export" expiration="never …

Another suggested tip by BEA is to ensure the files (cert, key and ca cert) should all end with the extension .pem.

Once you have the new key, cert and your CA cert (default demoCA/cacert.pem), copy it into /opt/bea/wlserver6.1/config/bpmdomain/myserver (or the location where you have Weblogic installed).

In our version we use wlintegration – so our path is /opt/bea/wlintegration2.1/config/bpmdomain/myserver


Subsequently these files are referenced from config.xml as explain below(replace file names with the ones you created and your ca):


For apache to work, need to modify configs to look something like this (after copying your cacert file to location designated below):

...IfModule mod_weblogic.c...
WebLogicHost hostname
WebLogicPort 7002
SecureProxy On
trustedCAFile yourcafile.pem
RequireSSLHostMatch false
ConnectTimeoutSecs 60
Debug Off
ErrorPage https://xxxx/outage.html

Notice the different port (7002) – default Weblogic SSL port. You need to ensure this is open from the firewall.

See my perl perl network connectivity checking tips here
You can use listenport code as well to listen on 7002 on application server, then scanport code to attempt to connect from the web server.

Therefore ensure it will work, even before entering change control! 🙂

– WebLogic Forum at Tek-Tips

Weblogic admin script for command line monitoring


You want to be able to view BEA Weblogic Server status from the command line.


Works beautifully with weblogic 6.1 and wlintegration 2.1 on Solaris – untested with Weblogic 7 or 8, etc.


If your is different, update to correct path – same with password and port (7001).
To obtain the JVM stats, just run it like this:

./wladmin GET -pretty -type JVMRuntime
===================    wladmin script ==========================

# script to run command line weblogic stuff

[ $# -eq 0 ] && {

echo "
Usage: $0 Command


$0 GET -pretty -type Server
$0 GET -pretty -type Server
$0 GET -pretty -type Security
$0 GET -pretty -type WebAppComponent
$0 GET -pretty -type WebAppComponent Runtime -property Status
$0 GET -pretty -type Application
$0 GET -pretty -type Realm
$0 GET -pretty -type ServletRuntime
$0 GET -pretty -type JVMRuntime
$0 GET -pretty -type JDBCConnectionPool
$0 GET -pretty -type JDBCConnectionPoolRuntime
$0 GET -pretty -type Machine
$0 GET -pretty -type Cluster
$0 GET -pretty -type ClusterRuntime
$0 GET -pretty -type JTA
$0 GET -pretty -type JTARuntime
$0 GET -pretty -type ExecuteQueue
$0 GET -pretty -type ExecuteQueueRuntime

exit 1


. /opt/bea/wlserver6.1/ > /dev/null

java -cp $CLASSPATH weblogic.Admin -url localhost:7001 -username system -password YOUR_PASSWORD $*

exit 0
===================    wladmin script ==========================

The HeapFreeCurrent is the value of interest.

Capture can then be automated with a script run by cron, that additionally pumps out the date to correlate timings with stats.