Needed a quick way to add leading zeros to numbers for a js countdown script. Not hard to do, now I can look at this post for the code when I need it again.
function addLeadingZeros(n, totalDigits)
{
if(!totalDigits)totalDigits = 2;
n = String(n);
while (n.length < totalDigits)
n = "0"+n;
return n;
}
var num = 5;
num = addLeadingZeros(num, 3);

Wordpress is great software. I love the UI. I don’t like the extra clutter in the dashboard and neither do some of my clients. Getting rid of it (or adding to it) is fairly easy. See http://codex.wordpress.org/Dashboard_Widgets_API for all that you can do.
If you just need to quickly trim down the dashboard use the code below in your themes functions.php file.
/************************
* Control over widgets in admin dashboard
************************/
add_action('wp_dashboard_setup', '_remove_dashboard_widgets' );
function _remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
}

Found a great time tracking application for windows : Time Sheet .
You can train it to associate an application/document title with a project and track the time entered.
From the website:
"TimeSheet is a powerful automated time & task recording tool for professionals.
It will improve your accountability by increasing the billable hours: let the tool register what you are doing and for how long."
Sometimes whitespace in user entered data can be annoying. Even more annoying if it is imported data, or better yet your fault for not trimming the input. Anyway, its a simple matter to trim a field in MYSQL – see the query below , preserved here for posterity.
UPDATE tablename
SET fieldName = TRIM(fieldName)
Vimeo does not (at the time of this writing) have an iPhone/Pad version of their embed code. After seeing this solution , I had a need to do something similar but with all Vimeo embeds sitewide.
jQuery to the rescue and must be included for this to work – best used in a dom ready event.
var agent=navigator.userAgent.toLowerCase();
var is_iphone = (agent.indexOf('iphone')!='-1');
var is_ipad = (agent.indexOf('ipad')!='-1');
if(is_ipad || is_iphone){
$('embed').each(function(i){
var el = $(this);
if(el.attr('src').indexOf('clip_id') != -1){
var reg = new RegExp(/clip_id=\d*/gi);
var clipid = el.attr('src').match(reg);
embed = "<video src='http://www.vimeo.com/play_redirect?"+ clipid + "&quality=mobile' controls='controls' width='"+el.attr('width')+"' height='"+el.attr('height')+"'></video>";
el.parent().after(embed);
el.parent().remove();
}
})
}
* Note: this solution requires a Vimeo plus account and you need to enable “Mobile Embedding” found in | Settings > Embed – for each embed. Also, vimeo could change their architecture and break this system.
This task is one I seem to be doing repeatedly, so here is a snippet for all the world to enjoy.
import flash.geom.ColorTransform;
private function tint(c:Number, obj:*) {
var myColor:ColorTransform = obj.transform.colorTransform;
myColor.color = c;
obj.transform.colorTransform = myColor;
}
tint(0xffcc00, myMovieClip);
Sometimes in flash you need to get an XMLList from tags while ignoring tag case.
<xml>
<tagName>contents</tagName>
<TAGNAME>contents</TAGNAME>
</xml>
I have a class that extracts XHTML from the page where a swf is embeded. Works great except different browsers return different case for tags. Below is the snippet I used to get a node list no matter the tag case. The example is getting all “span” tags.
var nodeList:XMLList = data..*.(new RegExp('span',"i")["test"](name()));
Posted
on March 30, 2010, 3:10 pm,
by Brian,
under
Uncategorized.
For the sake of my memory I’m posting a simple jQuery ajax routine.
$('a.ajax-enabled').click(function(evt){
evt.preventDefault();
$('#content').load($(this).attr('href') + ' #content');
});
Posted
on February 24, 2010, 3:12 pm,
by Brian,
under
Uncategorized.
The (now) new Firefox 3.6 and possibly other versions place a 1px border around flash elements embedded with swfojbect. This outline is similar to the active link outline. May occur on other object and embed tags as well.

If you’re annoyed by this, there is a simple CSS fix.
a:focus, object:focus {
outline: none;
-moz-outline-style: none;
}
Witty, nerdy, funny.
