ContentFull

Graphviz(dot) font problem on mac

May 11th, 2008

If you happened to have installed graphviz without first installing fontconfig (one is never told to do so, but supposedly one should) then you are probably seeing messages such as

Error: Could not find/open font : Times-Roman

To solve this annoying error you need to add the following extra parameter when calling any graphviz program

-Gfontpath=/System/Library/Fonts

Comment

Unexpected hummor in error message

January 3rd, 2008

While working with PHP4 thinking it was PHP5 I received the following error message

Parse error: parse error, unexpected t_paamayim_nekudotayim

Exactly, what on Earth does t_paamayim_nekudotayim mean?!
Answer: Hebrew for two (paamayim) colons (nekudotayim). More compilers and interpreters should incorporate humor into their products for it makes errors and hair-pulling situations much more relaxing.

Category: Hummor, Programming

Comment

Ajax and form submission

July 17th, 2007

Situation: You have a form which you would like to validate before submitting. you also want to show error messages without having to reload the page. Example:

Suppose you want to call a function called validate() when either the user presses enter or clicks the button. The trick I discovered with Prototype is as follows:

function checkForSubmission(element,func){
Event.observe(element, ‘keypress’, function(event){
if(event.keyCode==13)
func();
});
}

Now for the example above, when the page loads you simply call

checkForSubmission(“login”,validate);

If the user presses enter in any of the two text boxes or clicks the button the form will now validate itself. Simple solution to a tricky situation.

Update: It seems that in Safari events happen in a different order: onSubmit event takes place before the onKeyPress event. To get around this you need to return false when onSubmit occurs. Easiest solution is to add the following to the form tag.

onSubmit=“return false;”

Category: Programming

Comment

Crafted and populated by André Cohen