Wednesday, January 16, 2008

Thursday, January 10, 2008

Heredoc Syntax

Because I always forget...
 

Perl heredoc syntax:
$var = <<EOF;
    text goes here
EOF
 
PHP heredoc syntax:
<?php
$str = <<<EOF
text goes here
EOF;
?>
 

Ruby heredoc syntax:
str = <<EOF
  text goes here
EOF
 
Python:
str = """text goes here
"""
(text is on the same line as the """ for parity with the other examples)

Wednesday, January 9, 2008

JavaScript Tip


Javascript to accept only numbers:

var isNS4 = (navigator.appName=="Netscape")?1:0;

<textarea rows=2 cols=20 name=comments onKeypress="if(!isNS4){if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) event.returnValue = false;}else{if ((event.which > 32 && event.which < 48) || ( event.which > 57 && event.which < 65) || (event.which > 90 && event.which < 97)) return false;}"></textarea>


ASCII values for keys:

numpad
  DOT/DECIMAL  ('.') : 110
  NUMBERS:  0 - 9 =  96 - 105

KEYBOARD
DOT/DECIMAL/PERIOD  ('.') :  190
NUMBERS:   0 - 9 = 48 - 57


CSS support in browsers

This is a good matrix which shows, browser compatibility with CSS.

http://www.westciv.com/style_master/academy/browser_support/index.html