Press "Enter" to skip to content

Posts published in July 2006

Javascript Expanding List / Menu

An easy method to create an expanding list using javascript. I’ve incorporated the code into some server status pages to show or hide tables. Effective and clean looking.


An Expanding List

Click on the red right-arrows to expand the list.
Click on the green down-arrows to contract the list.

  • Topic A
    • Topic A1
    • Topic A2
      • Topic A21
      • Topic A22
      • Topic A23
    • Topic A3
  • Topic B

    • Topic B1
    • Topic B2
    • Topic B3

  • and here is how it works.
    Timer Display

    Animation, in its broadest sense means changing the content over time, usually withing small time intervals. In JavaScript, the key to animation is the setInterval function which causes a function to be called at periodic intervals.
    This is perhaps the most basic example illustrating the usage of the setInterval function. The current time and date can be read into a string using an operation something like this:

    timedate = new Date();

    What we want to do is to depict the “running” time in our browser, i.e., we want it updated every second with a new value. Here is the example:


    The current time and date on my system is:


    Borrowed from

    Creating shared SSH authentication keys

    Having multiple servers to entertain me and for website and application development, I found that entering passwords continually while switching from machine to machine very tiring. This enables cron jobs to run backups, and a mryiad of other automated tasks via an encrypted connection, thus not exposing my passwords over the network, some of which crosses wireless segments using such thigns as FTP, instead scp keeps things nice and garbled for anyone thinking to listen in.

    This is not only for Linux, but all Unix type boxes and even Windows! Yes, I said windows! I’ll publish another article to explain how to accomplish this one a windows machine.

    Here’s a quick and dirty tutorial of how to set up shared SSH keyss to authenticate to each server automagically, no more entering passphrases!

    Login to the first server (harry in this example) and create your key

    root@harry:/root# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase): [just hit enter]
    Enter same passphrase again: [just hit enter again]
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/
    The key fingerprint is:

    Now scp the rsa key to the destination server (case):

    root@harry:/home/dave# scp /root/.ssh/ case:.ssh/authorized_keys
    root@case’s password: [enter root’s password] 100% 392 0.4KB/s 00:00

    and presto…. you are done, now ssh to case

    root@harry:/home/dave# ssh root@case
    Last login: Fri Jul 21 08:45:20 2006 from harry
    Linux 2.4.22.

    root is instantly authenticated from harry because of the shared key.

    Now continue to replicate the process for each server/workstation/user that you wish. This can make life much easier for you however there is one drawback, see the note below.

    NOTE: once setting this up even changing root’s password will not resecure they connection or change the ‘key’ nor will it stop access from any machine with a shared user and key. In simpler terms much the same way giving away a key to your house, the one who posesses the address and key to the hosue may enter at any time, the only way to disallow access is to change the lock or destroy the key (in our world, the authorized_keys file).

    Happy hacking.

    Test king has proved itself to the students all over the world by conducting practice tests and training sessions through tests like VCP-101V and 1Y0-327 which are based on the real exam patterns. The Microsoft test number 70-350 is also a popular test among the computer students. Test king also offers training programs for Cisco in tests such as 642-873 and 646-588. Another known test is 642-372 which Cisco students take in order to prepare well for their certifications requirements.

    Excellerating WordPress

    While optimizing my databases and such I noticed that I had been making a fatal mistake with my WordPress database; marking comments as ‘spam’ through the comments moderation panel. This only marks the comment_approved feild in the row for that comment in the wp_comments table from ‘0’ to ‘spam’.

    In over a year I’d accumilated over 12K rows just for spam that needed to be parsed each time a particular post/page was to be displayed, and dragging down the performance of my blog. Instead of marking spam as such, deleting them completely seems to be the route to take.

    A quick query to run against your database in a utility such as phpMyAdmin follows to purge the tables of those entries for you;

    FROM `wp_comments`
    WHERE `comment_approved` = CONVERT( _utf8 ‘spam’
    USING latin1 ) ;

    Some tweaking may be needed far your particular setup, I’ll be submitting this as a feature request to the kind folks at WordPress or if time permits creating a quick and dirty plugin.

    Creating a Tarball

    Quick and dirty – How to create a “tarball”.

    By now everyone has seen the wonderfull myproject.tar.gz, I say wonderful as to extract the ‘project’ or whatever is contained in the tarball can be accomplished with a single command and viola, all the files are extracted with all of thier subdirectories and files in tact, complete with unix permissions.

    So you’d like to backup your website or project for distribution, easy enough

    tar everything up
    [server]$ tar -cf myproject.tar myprojectdir myotherprojectdir
    and gzip it
    [server]$ gzip myproject.tar
    the result is will net you myproject.tar.gz all ready to do as you will with.

    Explaination the -cf switch is simply create file, if you like you can use -vcf to display a verbose listing as tar moves along to ensure you are getting the intended files and directories.
    myprojectdir myotherprojectdir are just the directories you which to include, this list can be one, two, or more diectories.

    gzip will compress your .tar file and leave you with the resulting .gz, so of you want to retain a copy of the .tar be sure to make a copy before gzip.

    As mentioned earlier, to extract your shiny new tarball once you have it in the desired directory, you can do this with one command,
    [system]$ tar -xzvf myproject.tar.gz


    DHTML expandable lists

    How to create a DHTML expandable lists.

    Try the following example:

    .general {font-family:Verdana;font-size:11;color:white} .span_general {font-family:Verdana;font-size:9;color:white;border-style:solid;border-color:white;border-width:1px 1px 1px 1px;text-align:center;width:16;height:15;cursor:hand}

    function objectOver(x){"#9ff5ff"; }

    function objectOut(x){"white"; }

    function collapse(x){ var oTemp=eval("document.all.text_"+x); var oClick=eval("document.all.click_"+x);

    if("block"){"none"; oClick.innerHTML="+"; } else{"block"; oClick.innerHTML="-"; } }

    Text 1 TITLE

    text that is displayed under Text 1 TITLE
    another line of text here
    Text 1_1 TITLE

    Text under Text 1_1 TITLE catagory
    Text 1_2 TITLE

    This is a test of the emergency broadcasting system.
    Text 1_2_1 TITLE

    If there were a real emergency and you thought someone would care this
    information would be classified and you wouldn't know anyhows
    Text 1_3 TITLE

    Example for 1_3 text area...
    Notice in the code that the breaks all have a trailing slash....thus closing the br tag
    I'm trying to remember to use correct syntax before something breaks it.

    Javascript Collapsible Lists

    Javascript and DHTML can be used to make collapsible and expandable HTML lists that degrade cleanly (that is, are still usable for visitors who don’t have Javascript-enabled web browsers).

    This has been tested in Opera, Mozilla (Navigator) and Internet Explorer. Clicking on the arrows expands or collapses sections of the list:

    The code

    You need to create images called closed.png and open.png to be used for collapsed and expanded lists respectively. When adding more lists, the id values for the img and ul elements must be changed, and the parameters in the call to toggle() in the image’s onClick value must be changed to these ids.


    • document.writeln('Open list'); IBM
    • 80×86
    • Itanium
  • document.writeln('Open list'); Motorola
    • 680×0
    • PowerPC

    document.getElementById('collapsibleList').style.listStyle="none"; // remove list markers document.getElementById('iBMList').style.display="none"; // collapse list document.getElementById('motorolaList').style.display="none"; // collapse list // this function toggles the status of a list function toggle(image,list){ var listElementStyle=document.getElementById(list).style; if (listElementStyle.display=="none"){ listElementStyle.display="block"; document.getElementById(image).src="open.png"; document.getElementById(image).alt="Close list"; } else{ listElementStyle.display="none"; document.getElementById(image).src="closed.png"; document.getElementById(image).alt="Open list"; } }