Stable quicksort in Javascript
October 28th, 2008
Firefox < v3.0 doesn't have a stable Array.sort() function - that is, it doesn't maintain indexes for elements of equal value. This is undefined in the ECMA spec, and has been fixed in Firefox as of version 3 (and curiously enough has been stable in IE all along). As a result, I set out to find a stable, efficient Array.sort() replacement/supplement.
Read the rest of this entry »
MySQL inner join to perform update from same table
September 9th, 2008
Typically, using SELECT in a subquery to perform an UPDATE on the same table, such as:
UPDATE table1 AS target
SET field1 = (
SELECT field2
FROM table1 AS source
WHERE source.id = target.id
)
is illegal in MySQL. To achieve the desired effect, you can perform an INNER JOIN in the UPDATE:
UPDATE table1 AS target INNER JOIN table1 AS source USING(id) SET target.field1 = source.field2
Apache cache control for dynamic or secure content
June 10th, 2008
Cache control is a potentially hit-and-miss pursuit, but the most reliable and straightforward method I’ve found (that works for IE 6+ and Firefox), although it relies on access to your Apache server configuration, is simply setting Cache-Control headers manually.
Read the rest of this entry »
HTML DOCTYPE can be your friend - or your enemy…
February 3rd, 2008
When you just need to get the job done, sometimes it pays to visit the wayback machine. Recent DOCTYPEs can wreak havoc on even simple layouts when relying on deprecated functionality.
DynDNS Updater: Enabling support for other service providers
August 26th, 2007
(Applies to v3.1.0.15) DynDNS Updater is a simple, free to use dynamic DNS utility: it automatically detects changes to your external IP address - such as when your ISP renews your DHCP lease - and forwards this information to your DNS service provider to ensure your domain name always points to your most current IP.
However, this utility is distributed by DynDNS.org (although designed and supported by third party Kana Solution) primarily to support the use of their specific service. But with a little tweaking, you can make this well-designed utility work for other service providers - for this example we’ll be using the domain registrar Namecheap.com, one of the better rated affordable service providers.
IE Bug: Extra space inside edges of divs & table cells
August 26th, 2007
IE is leaving room for ascenders and descenders on characters within the elements - even if there is not text present. To workaround, set the element (div or table cell)’s properties like such:
font-size: 0px line-height: 0px
Perhaps changing the content’s vertical-align property (to middle?) might also help…