Have the Server Watch Your Account

This crontab entry will email you a report of all the files modified within the past 24 hours.

find $HOME -mtime 0

Search for files in your home directory which have been modified in the last twenty-four hours. This command works this way because the time since each file was last modified is divided by 24 hours and any remainder is discarded. That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.

http://linux.about.com/od/commands/l/blcmdl5_crontab.htm

Describes how to set up a cron job, so the command will execute periodically and email you the results.

MAILTO=me

5 0 * * * find $HOME/public_html -mtime 0

This simple command will let you know when files have been added to your server. You may want to disallow some files or directories.

Cool Hover Effect

The link above provides a nice hover effect, done with CSS and a tiny bit of javascript.

The approach is to use two divs. The outer or container div has a background image assigned through CSS. The inner div contains the text, and is hidden (display:none) on page load. The inner div uses a white background, with opacity to mute the background image and make it easier to view the image.

On hover, the inner div is changed to display:block.

Both divs have an id and class. The outer div id is required to assign the background image, the class is used to set float:left, and any other common attributes. The inner div id is used to identify it in the javascript, so the display attribute can be controlled, and the class is used to describe and position the text and opacity.

The code was written to run within a loop, hence the 1 on the ids.

Debugging Web Pages in IE

Tricks for debugging web pages under IE, if you don’t have any tools.

  • Comment out all but the code that doesn’t work. Often the code that’s not working is broken because of something else.
  • Have a separate CSS file, just for IE
  • Use alert to halt javascript execution. This lets you see which command was executed prior to the failure.
  • If you have a complex page, use View Source, then paste the text into a file under vi. Use grep “<div” | wc -l, and grep “</div” | wc -l to count the number of open and close divs.
  • If you are using a template language such as Smarty, hard-code values for quick tests.
  • Be sure to clear the cache, aka delete the temporary Internet files. Otherwise, CSS and javascript changes may not take effect.
  • Refer to w3schools.com to check for supported attributes for various browsers.
  • Be creative. If .style.display=’none’ doesn’t work, try removing the node.
  • Limit the versions of IE you will support, and alert the user. IE6 is a good starting point.
  • Accept some problems. For example, IE6 and Apache sometimes have trouble with .png transparency. Either make those images a different filetype, or allow them to display as the server delivers them and the browser displays them. It is not worth striving for perfection to support software that will eventually become obsolete.
  • Use server-side logic to deliver the best code for the browser. Again, this should be limited to that which is absolutely necessary, but it is often easier to prepare the page well on the server, than to adjust it once it has been delivered to the browser.
  • Use FireBug. It is bundled with dojo, and probably available as a stand-alone component.

Polished UI - Cost Effectively

Tactics to produce a polished (web) user interface, in a cost-effective manner.

This is different than the design, in that these issues are related to the user’s interaction, rather than the visual presentation. For example, the visual presentation would include the page layout, images, graphics, choice of color, attractive menus and page navigation. User interface is more commonly a part of applications, and is intended to help the user accomplish what they must do with the application. The user interface must be fairly easy to understand, and should be polished to present a professional appearance.

  • Start with a toolkit and if possible, a theme that works with it.
  • Find an icon set. The link above is excellent. You may need more than one set, and, since you only need to purchase it once, it is worth choosing carefully. Be aware of any license restrictions.
  • Be creative. If you can’t find the ‘perfect’ icon, use a keyboard character, or a different icon.
  • Keep it simple.
  • Disable controls the user can’t use, based on the current state of the page.
  • Remember the functionality probably takes precedence over the UI. When pressed for time, get it working, then make it pretty.
  • Limit the list of supported browsers. IE6+ and FF2+ is a good starting point.
  • Keep track of the time spent per page. This will allow you to give better estimates, and help management understand the costs of the project.
  • Donate to support any free tools you use.

dojo Form Demo

This is a very simple demonstration of a dojo form. Please use ‘View Source’ to view the code.

Supporting server-side PHP.

json.php

Returns the submitted input. Demonstrates a ’successful’ transaction.

<?php
header('Content-type: application/json');
echo <<<END
{"sText":"{$_REQUEST['sText']}"}
END;
?>

error.php

Returns a 503, service not available.

<?php
header("HTTP/1.0 503 Service Not Available");echo 'Server side error';
exit();
?>

timeout.php

Sleeps for 3 seconds to force a timeout.

<?php
sleep(3);
?>