Run Time Machine Backups Daily, Not Hourly

March 13th, 2010

I’m annoyed by the inability to customize Time Machine’s schedule: I really don’t want hourly backups while I’m trying to use my machine. I also don’t care for changing the interval as many other posts and tips suggest because that does not guarantee a consistent time-of-day to run.

There’s an easy solution that does not require any additional software. First, turn off Time Machine backups (after you have selected a backup disk). Then just add your own schedule(s) to cron. For example, I schedule mine to run every day at 2 AM:

0 2 * * * /System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper

If you’re unfamiliar with how to configure cron, you may wish to have a look at Using the ‘cron’ scheduler.

Workaround bzr-upload FTP “Connection reset by peer” issues

March 12th, 2009

Have problems using the bzr-upload plugin to upload to an FTP server? I recently had repeated troubles getting a large web site to complete the initial full upload to an FTP server on a not so great connection. The upload would start fine, make it partial way through, and quit with the error:

bzr: ERROR: socket.error: (54, 'Connection reset by peer')

Read the rest of this entry »

Re: Boost performance with parallel processing

January 31st, 2009

Martin Roest posted an article about parallel processing. Here’s a more reusable version of the code, OOP style:

Usage with callback function:

< ?php
$pc = new ProcessController(10);
$pc->process($documents, 'processDocument');
?>

It supports static method callbacks:

$pc->process($documents, array('DocumentProcessor', 'processDocument'));

And callbacks on an instance of an object:

$pc->process($documents, array($documentProcessor, 'processDocument'));

Read the rest of this entry »

Redirect After Post, But Not On Failure

January 10th, 2009

Post/Redirect/Get (PRG) is a great practice, but don’t use it when the post is a failure. Here are some reasons:

  • If post failed because of non-validation issue, e.g. if “try again later” was the result, then the client only has to refresh the page to submit the post again.
  • It’s more efficient (greener) and easier to develop: if redirecting even on failure, then you must store the post data in the session and pull it back out to refill the form (or require the user to fill out the entire form again).

Implementation examples follow:

Read the rest of this entry »

Using OS X Leopard’s Spaces Productively

October 29th, 2008

Divide workspaces by projects, not applications.

I use web browsers, terminals, finder windows, and code editors for my software engineering projects.

I also use applications that are project independent and should stay out of the way when not needed yet remain easily accessible without having to switch through a bunch of “spaces.” I consider Mail and iTunes to be such applications. These tend to be applications that only use one window and as a result they are easily managed just by using the Dock and Command-Tab features in Mac OS X.

My setup can be accomplished with two quick steps:

Read the rest of this entry »

Track Download Links Using jQuery and Google Analytics

October 22nd, 2008

Once you’ve got Google Analytics working, you can use jQuery to easily track other links on your site, such as download links.

Read the rest of this entry »

Using Gmail’s IMAP with Apple’s Mail.app, iPhone

October 13th, 2008

I recently purchased an iPhone and decided to switch my PowWeb hosted POP e-mail accounts to Gmail’s free IMAP offerings. Doing this enabled me to read, move, and delete messages on either my iPhone or Laptop and not have to do the same thing again on the other device.

One of my requirements for this change to succeed was that anyone with my existing e-mail address would not have to make any changes. They’d still send to the same address, and e-mail from me would still appear to come from the same address.

I outline the steps I took to accomplish this below.

Read the rest of this entry »

Renaming or Moving a MySQL Database and User

January 24th, 2006

This article covers the renaming the name of a database as well as the user who has privileges on that database. For my example, I am renaming the database from old_db to new_db and also renaming the user old_user to new_user:

Update the mysql database:

shell> mysql -u root -p
mysql> USE mysql;
mysql> UPDATE user SET User='new_user' WHERE User='old_user';
mysql> UPDATE db SET Db='new_db',User='new_user' WHERE User='old_user' AND Db='old_db';
mysql> exit

Find the database location (usually in /usr/local/mysql/data):

sudo find /usr -name "old_db" -type d

Stop the MySQL server, move the database, re-start the MySQL server on Mac OS X:

sudo su -
cd /usr/local/mysql/data
../support-files/mysql.server stop
mv old_db new_db
../support-files/mysql.server start

Adhering to Section 508

October 24th, 2005

As a government entity, it is required by federal law to adhere to Section 508 of the Rehabilitation Act, and meet minimum requirements of the W3C’s Web Content Accessibility Guidelines.

To meet minimum requirements, the entity must satisfy the “Priority 1″ Checkpoint (=Conformance Level “A”). See:

JavaScript Does Not Validate

October 4th, 2005

Remember to put CDATA tags around the actual JavaScript code if it uses < or &. See Script and Style elements at the W3C. For example, use:

<script type="text/javascript">
<![CDATA[
... unescaped script content ...
]]>
</script>

Actually, the above does not work correctly in Mozilla browers such as Firefox. See Properly Using CSS and JavaScript in XHTML Documents. They recommend putting everything in external files. If that’s not possible, use a modification of the above code:

<script type="text/javascript">
//<![CDATA[
... unescaped script content ...
//]]>
</script>

Useful Validation Links: