Home     Wordpress     Codex

Archive for September, 2008

Inexpensive (semi-)persistent hit counting

September 24th, 2008 by admin | 1 Comment | Filed in Uncategorized

The vast majority of database queries (at least, in a web application) are SELECT statements. In my experience, unless you get Digg’ed, it’s usually somewhere between 80% and 90% reads vs writes. The exception to this rule is web forums and other software which tracks hits.  For every page query, you have to increment the thread’s ‘hit’ column. This involves opening a database connection, submitting your update query, and closing the socket once the transactions been completed. As you can imagine, this quickly becomes very expensive. vBulletin’s method of dealing with this is simply not reporting accurate hit stats. Unacceptable in my opinion.

Alternatively, what one could do is store the hits in an array and access the memory directly for every query. Any page render queries this array instead of the database. In practice, I’d probably store this in memcache. At a given interval, a call gets made to the memory (memcached store) and the number of hits incremented gets commited to the database. Since you’re only storing the hits incremented, this should scale pretty well if necessary between application servers. If the memcache happens to crash, in most cases no important data is lost.

Change Facebook Back to the Old Layout

September 13th, 2008 by admin | 8 Comments | Filed in Uncategorized

The new Facebook layout change has been met with a certain amount of opposition. Up until recently, there was an option which allowed users to revert back to the “Classic” theme. All good things must come to an end, though. Lucky for us, Facebook has to keep backwards compatibility for older browsers. By forging our client to seem as though we’re using an antiquated browser, Facebook returns the Classic theme instead of the newer one. This only works for Firefox unfortunately, but I’m sure you could do something similar in Chrome.

1) Download the User Agent Switcher
2) Restart Firefox
3) Go to Tools -> Add-Ons
4) Click the Extensions tab, select User Agent Switcher, then click Options
5) Click User Agents, and then Add
6) Fill the fields with the following information

Description: IE5.5
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0 )
App Name: Microsoft Internet Explorer
App Version: 4.0 (compatible; MSIE 5.5; Windows NT 5.0)

All set!

Edit, 1:54 AM EST 16 Sept 08
Seems like this may or not still be working. Varied accounts.
If it doesn’t work, try this link:
http://www.new.facebook.com/?fbnew_opt_out=1