Skip to content

Archive for


PHP/JSON: A working example – log update on a background process (Part 2/2)

phpPHP side (Server side)

On the server side, here is the code for the start_proc.php which starts a background process Read more »


Ajax/Prototype/JSON PeriodicalUpdater: A working example – log update on a background process (Part 1/2)

PrototypeThis blog shows a real working Ajax.PeriodicalUpdater example (not just a hello world or non stop show timer). The example uses the PeriodicalUpdater to display a constantly updated log file from a background process running on the webserver. When the process finishes, the PeriodicalUpdater stops itself. Also a simple short PHP script is shown how to launch and check the status of a background process.  Read more »


How to use CSS SyntaxHighlighter 2.0 with Ajax/Prototype

CSS SyntaxHighlighterThe default method to use SyntaxHighlighter 2.0 is via SyntaxHighlighter.all() declared in the Javascript section of the main page. What this method does is to register the SyntaxHighlighter.highlight() to call when the main page is loaded. The highlight method then searches for all the <PRE> tags (default configured tag name) and checks any class names containing the ‘brush:’ keyword. If so, then proceeds with syntax highlighting. Read more »


CSS SyntaxHighlighter 2.0: Notes on using with TEXTAREA and PRE

CSS SyntaxHighlighterThe CSS SyntaxHighlighter 2.0 can be used with <pre> or <textarea> tags. However if you have to use with <textarea>, you may have some little surprise that it won’t be <textarea> anymore once the content is highlighted. Because the highlighter will replace the DOM node (same applied to <pre> tag) – according to the source code ) in shCore.js. You will get a new <div> node instead – that’s the only way to have colorful syntax highlight on your page. Read more »


Ajax: a simplified version of file upload form using IFRAME

I have been trying to create file upload form in Ajax. Most of the tutorials I found are using <IFRAME> technique as a hidden frame. In OpenJS, it gives an excellent tutorial. In a nutshell, the file upload form redirects the reload action into the hidden frame. Then uses the top window to fetch the results (using JSON) when the hidden frame is loaded which indicates a file has been uploaded. This technique involves setting up the onload and onsubmit event handlers while the main page is loaded.

However, my scenario is slightly different that the <DIV> box in my page is inserted dynamically with different forms, like Ajax.Updater(‘action_box’, ‘action_form.html’), during the users navigation. So that I cannot rely on setting up onsubmit and onLoad event handlers when the main page is loaded. Here is a slightly modified and simplified version of the one in OpenJS to cater for this scenario. It is imperative that you understand the OpenJS tutorial first. Read more »


Prototype/Ajax: workaround to serialize forms with multiple submit buttons

PrototypeI have started learning to use Prototype (Javascript client framework) for a few days. So far I found it very good and saved me a lot of my work in developing webpages. Then I hit an existing bug when Prototype serializes a form with multiple submit buttons. Prototype always serializes the first submit button, even if you click the second button. Read more »


Ubuntu 64 bits: file command does not display which programe generated core

ubuntulogoOn Ubuntu 64 bits, when you run ‘file /core’, it doesn’t show the executable file generated the core file.


You can use gdb -c to show the executable file. However, that invokes gdb to be interactive and not appropriate for integrating into shell scripts which I need to. The workaround for it is to use –batch which turns gdb into non-interactive.

gdb non interactive

I work for iTrinegy and here are my other technical blogs


How to easily experiment your new usplash theme from a terminal

ubuntulogoWhen you have designed your own new splash theme, it is unlikely the first time it looks exactly the way you want it. However, it is inconceivable to test it by building the LiveCD and running from it. It is too time consuming and not practical.    

So here is a quick tutorial on how to launch your new theme from a terminal and show it on your console screen without creating the LiveCD. That means you can keep changing your design and the components of the splash screen such as progress bar, message box, color, positioning, etc. Read more »


What to do when you mess up the setuid bit of all the files from root directory?

unixYou can mess up the access mode of a file if you do a ‘chown -R’ or ‘chmod -R’ over the wrong directory. Well, I did!! This will screw up the setuid bit which can lead to permission problem on some essential utilities, such as mount, dhclient, etc. Read more »