Archive for the ‘Working on the web’ Category

Add leading zeros to a number in Javascript

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 [...]

Remove Crap from Wordpress dashboard

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 [...]

Time Sheet, a nice Windows app for time tracking

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 [...]

Trimming whitespace from a field in MYSQL

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 Embeds on the iPhone

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.

[...]

I love Google Chrome’s Error messages

Witty, nerdy, funny.

Simple JQuery to resize embeds

Sometimes Youtube or other embeds may not work in a given site layout.
Here is a bit of jQuery that loops over each object or embed tag and sizes them according to a maximum width, while respecting the aspect ratio.
Since this is a javascript solution, a visitor must have js enabled for the resizing to [...]

Great site for creating sitemaps and other diagrams

http://www.lovelycharts.com/ is a slick site for creating all sorts of diagrams and organizational documents.

A workaround for MOUSE_WHEEL on the Mac

Matt Giger has written an AS3 class that allows access to the MOUSE_WHEEL event on OS X. It uses javascript injection via ExternalInterface to proxy the event from the browser. Check it here