Aliovox Blog

Every now and then it would be nice to have a print statement for javascript.  Alert is ok, but if you want the contents of an array, it can be time consuming.

 

function debugln($line) {

// make a div with id="debug_area"
var debugit = document.getElementById("debug_area");
debugit.appendChild(document.createTextNode($line));
debugit.appendChild(document.createElement("br"));
}

function myonload() {

this.debugln("test message");

this.debugln("this message is on another line");

}

 


 

 

Find is a great utility which we use all the time, here is how to find a file

find . -name "file.c" -print

suppose you want to zip up a set of files

find directory_a directory_b file_a -print | zip -@

if there is a directory with thousands of entries, find will blow out, and you need to use xargs:

find . -name "*.cpp" -print | xargs grep -e "some text"

If you have subversion, and you do a search files, and not the .svn files, use:

find . -name .svn -prune -o -type f -print | xargs grep -e "some text"