Programming

Batch Files

Posted on

 

PHP Code Analysis

Posted on

  • *[http://www.program-transformation.org/PHP/PhpSat PHP-sat: PHP static analysis tool]
  • *[http://www.owasp.org/index.php/Category:OWASP_SWAAT_Project Category:OWASP SWAAT Project]
  • *[http://www.fortifysoftware.com/security-resources/rats.jsp RATS – Rough Auditing Tool for Security]

 

PNG Images in IE6

Posted on Updated on

Transparency in PNG images is not supported in IE6 natively. Here are some work-arounds.

  • IE6 PNG Fix by Twin Helix — this is a very good fix, but there are a couple of gotchas.
    1. First, applying the behavior to all IMG and DIV tags results in some instability–lots of crashes and very slow load times.
    2. Second, there’s also a minor issue with relatively and absolutely positioned links that has a PNG background–a warning is shown that the link may not be accessible; I’ve found no instance where this is actually the case, so I have commented out the alert line in the .htc file.
    3. Third, applying the behavior to many elements results in IE6 hanging on initial page load. Waiting for 2+ minutes or refreshing the page usually results in the browser unfreezing.
  • IE behaviour
  • Christopher Schmitt’s method

Programming Articles

Posted on Updated on

 

Find absolute position of an element

Posted on

While working on a project, I discovered that I needed to find the absolute coordinates of an element in a page in order to dynamically position another element before showing it.

A quick Google search yielded this gem from quirksmode.org: JavaScript – Find position.

Here’s the condensed code:

/**
 * Determines the absolute position of an element
 *
 * @author Peter-Paul Koch
 *
 * @see http://www.quirksmode.org/js/findpos.html
 *
 * @param object obj The element whose absolute position is to be found.
 * @return array An array with two elements: 0 is the left position, 1 is the top position.
 */
function findPos(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop  += obj.offsetTop;
		} while (obj = obj.offsetParent);

		return [curleft,curtop];
	}
}

text/application type is deprecated

Posted on Updated on

This was news to me–RFC4329 explicity declares text/javascript to be obsolete. Instead, application/javascript is to be used. The problem? Not all browsers support it yet.

Here’s the breakdown:

Firefox

  • Firefox 3.5.4 – supported

Internet Explorer

  • IE 8 – NOT supported

Safari

  • Safari 4.0.3 – supported

Chrome

  • Chrome 3.0 – supported

Determining if a method was called statically

Posted on

In PHP, it’s occasionally helpful to call a method sometimes statically and sometimes from class instance. Figuring out which way a method has been called is pretty straightforward, thanks to a function posted in the PHP documentation:

<?php
function foo () {
$isStatic = !(isset($this) && get_class($this) == __CLASS__);
}
?>