Category Archive for 'How To'

Pre-encoding vs. mod_deflate

Tuesday, June 3rd, 2008

Recently I configured Apache to serve pre-encoded files with encoding-negotiation. In theory this should be faster than using mod_deflate, which has to re-encode every hit, but testing was in order.
My mod_deflate setup consisted of a directory with this .htaccess:
AddOutputFilterByType DEFLATE application/x-javascript
BrowserMatch \bMSIE\s[456] no-gzip
BrowserMatch \b(SV1|Opera)\b !no-gzip
and a pre-minified version of jquery-1.2.3 (54,417 bytes) saved as “before.js”. [...]

Apache HTTP encoding negotiation notes

Sunday, May 25th, 2008

Now that Minify 2 is out, I’ve been thinking of expanding the project to take on the not-straightforward task of serving already HTTP encoded files on Apache and allowing Apache to negotiate the encoding version; taking CGI out of the picture would be the natural next step toward serving these files as efficiently as possible.
All [...]

Minifying Javascript and CSS on mrclay.org

Thursday, March 27th, 2008

Minify v2 is coming along, but it’s time to start getting some real-world testing, so last night I started serving this site’s Javascript and CSS (at least the 6 files in my WordPress templates) via a recent Minify snapshot.
As you can see below, I was serving 67K over 6 requests and was using some [...]

Distance and bearings between GPS coordinates in SQL

Wednesday, January 16th, 2008

Another post from my sql abominations series. I’m running this on MySQL 5 particularly.
Assume you have a table of locations with Latitude and Longitude for each one. In my case the table is “station”, primary key being “LocID”. With help from this article, first we create a view to get 3D coordinates (6378 = Earth’s [...]

Average direction in SQL

Wednesday, August 15th, 2007

Given a column of polar directions in degrees, this is a single SQL expression to compute their average, for use in a GROUP BY query. Some functions may be MySQL-specific.
IF(DEGREES(ATAN2(
-AVG(SIN(RADIANS(direction_deg)))
,-AVG(COS(RADIANS(direction_deg))))
) < 180
[...]

Hacking a 3rd party script for bookmarklet fun

Wednesday, June 27th, 2007

A few weeks ago I created a simple bookmarklet that loads del.icio.us’s PlayTagger script into the current page. This post covers how some problems with this script were worked through.
Too late
The first challenge was that PlayTagger was designed to initialize itself (let’s call this method “init“) on window.onload: If a user fired the bookmarklet after [...]