Archive for the ‘Web’ Category

Content Expirator – jQuery Content Expiration Plugin

Saturday, March 27th, 2010

Content ExpiratorContent Expirator is a jQuery utility plugin that provides an easy way to give DOM elements an expiration date. If the element is found to be expired, its 'display' parameter is set to 'none'. A better approach would be to perform this function server side with a server side language, but this is a quick and easy way to implement it client side.

Download: jquery.content_expirator-0.1.0.js


Let's say your client has given you a flyer to put on their website for an event.

<img src="easter_flyer_2010.jpg" class="aligncenter" alt="Easter Flyer" />

After Easter is over, you're going to want to take this flyer off of their site. Instead of manually editing the site on the Monday after Easter to take it down, you can give it an expiration date so that it isn't displayed after Easter.

<img src="easter_flyer_2010.jpg" class="exp-2010-04-04 aligncenter" alt="Easter Flyer" />

The Content Expirator looks for an element containing a class name (must be the first one listed) containing the prefix 'exp'. When it comes across one, it compares the date (formatted year-month-day) with the current day to decide if the element's 'display' (style) parameter should be set to 'none'.

Calling The Function:


// looks for -> 'exp-year-month-day'

custom prefix:

// looks for -> 'end-year-month-day'
<script> <html> Result:


Round Half To Even With Javascript

Monday, November 30th, 2009

Updated: v0.2.1

(special thanks to: Donatas v0.2.0 (

The following script provides an easy way to perform unbiased rounding, convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, or bankers' rounding using Javascript.


var numToRound = 10.005;
result: 10.00

var numToRound = 10.0015;
result: 10.002

var numToRound = 10.00500000001;
result: 10.01

var numToRound = 1005001;
result: 1010000


<script> <html> Result:


WordPress postMash Widget

Tuesday, July 21st, 2009

I really like the postMash plugin for WordPress. It allows you to drag and drop your posts into any order. This is great when using posts as events. You can put them into the order that they'll occur rather than the order that you posted them. The only problem is that the Recent Posts widget won't match your post order once you've re-ordered them.

Here I've modified the Recent Posts widget (file: /wp-includes/default-widgets.php) so that it'll work with this plugin.

Insert the following code after line #545 ($r = new WP_Query(array('showposts' =>...)(WP ver-2.8)

$r->set('orderby', 'menu_order');  
$r->set('order', 'ASC');