21 August 2007

50 things my wife would not do on a job

My wife was digging through some old paperwork and found a career counseling exercise she did about five years ago. The prompt was "name 50 things you would not do on a job." I love her ability to brainstorm, especially in career guidance-like situations. Check out number forty-four...

  1. Sit and use a computer all day
  2. Cut down trees
  3. Play any sport
  4. Clean windows on a sky scraper
  5. Cut and color hair
  6. Install electrical equipment
  7. Fix any cars
  8. Teach math
  9. Collect money at a tollbooth
  10. Collect garbage
  11. Typing all dialog in a court room
  12. Test makeup products on animals
  13. Operate on someone
  14. Feed and clean up after animals at the zoo
  15. Write people speeding tickets, parking tickets, etc.
  16. Knit
  17. Commentate for sports events
  18. Call people's homes and try to sell them things
  19. Mow lawns
  20. Fly an airplane
  21. Ride a tractor
  22. Fix traffic lights
  23. Sell food in the stands at sporting events
  24. Paint houses
  25. Fix toilets
  26. Shovel snow
  27. Climb a mountain
  28. Save someone from a shark
  29. Wax bikini lines, legs, upper lips, eye brows, etc.
  30. Crack someone's back
  31. Try out new medications
  32. Sew clothing
  33. Print newspapers
  34. Deliver mail all day
  35. Fix roofing
  36. Build furniture
  37. Give people manicures or pedicures
  38. Drive public transportation
  39. Be a mascot for a team
  40. Walk a tight rope
  41. Coach any sport
  42. Flip burgers at a fast food restaurant
  43. Check people for lice
  44. Put make up on dead people
  45. Pass laws in the senate
  46. Kill animals for food
  47. Patrol the ghetto
  48. Check people for STDs
  49. Dance at a strip club
  50. Give people bad news about their health

10 July 2007

Running jslint against many files in the Windows CLI

As much as I like some of the newer dojo-friendly Eclipse-based JavaScript+HTML+CSS IDEs like Aptana and Eclipse ATF, they all seem to barf on my JavaScript+JSP+JSTL+Portlet taglib source. Using the web-based JSLint JavaScript Verifier directly definitely works better, but there's only so many times I'm willing to copy and paste code into a browser when hunting down problems. There are some folks that have talked about validating within Ant builds but my development team is on a pre-1.6 copy of Ant which makes putting the pieces together a bit troublesome. It's pretty straightforward to run JSLint from the command line with Rhino but it's not well suited to running against a directory of files at once.

After some messing around with Windows XP batch files I got a useful little utility working. Once you download Rhino into a RHINO_HOME directory along with a copy of jslint.js, you can use this little batch file to run JSLint against many files at the same time:

@echo off
rem Windows batch file to run jslint on a collection of JavaScript files
rem see http://agentzlerich.blogspot.com/2007/07/running-jslint-against-many-files-in.html
rem for original post

rem To use, download Rhino from http://www.mozilla.org/rhino/
rem and uncompress it in a folder.  Set RHINO_HOME environment
rem variable to point to the folder.  Download JavaScript Lint (jslint)
rem from http://www.jslint.com/rhino/index.html and place it into
rem RHINO_HOME.  Ensure JAVA_HOME points to your JRE

if "%RHINO_HOME%"=="" goto rhinoHomeNotSet
if "%JAVA_HOME%"=="" goto javaHomeNotSet
if "%1"=="" goto noJavaScriptFilesSpecified

rem N.B. next line is wrapped!
for %%f in (%*) do echo. & echo Processing %%f & "%JAVA_HOME%\bin\java" -classpath "%RHINO_HOME%\js.jar" org.mozilla.javascript.tools.shell.Main "%RHINO_HOME%\jslint.js" %%f
exit /b %ERRORLEVEL%;

:noJavaScriptFilesSpecified
echo No JavaScript files were specified as parameters. Exiting.
exit /b 0

:rhinoHomeNotSet
echo Variable RHINO_HOME is not set! Aborting.
exit /b 1

:javaHomeNotSet
echo Variable JAVA_HOME is not set! Aborting.
exit /b 1

20 June 2007

Programmatic GreekingWidget for dojo

When playing with dojo's fancy container and layout widgets, it is nice to be able to greek quickly. Pasting a bunch of generated lorem ipsum text gets old quickly, so here's a programmatic, custom dojo widget that'll generate as much or as little placeholder text as you need. The JavaScript source code uses the dojo 0.4.x APIs. Please feel free to use and improve this widget however you like. Here's an HTML snippet that demonstrates the widget's usage...

<html>
<head>
        <title>Usage and unit tests for GreekingWidget</title>

        <script type="text/javascript">
            djConfig = { isDebug: true };
        </script>

        <!-- Be sure to point to your local dojo installation -->
        <script type="text/javascript" src="dojo-0.4.3-widget/dojo.js"></script>

        <!-- Be sure to point to where you save the source code -->
        <script type="text/javascript" src="GreekingWidget.js"></script>

        <style type="text/css">
            .FooBarClass {
                color: red;
            }
        </style>
</head>
<body>
        <h2>Usage and unit tests for GreekingWidget</h2>

        <h3>Default options</h3>
        <div dojoType="GreekingWidget"></div>

        <h3>One sentence</h3>
        <div dojoType="GreekingWidget"
            paragraphs="1"
            sentencesPer="1"
            loremIpsum="true"></div>

        <h3>Generate blockquotes</h3>
        <div dojoType="GreekingWidget" 
            paragraphs="2" 
            tag="blockquote"></div>

        <h3>Add CSS class to make them red</h3>
        <div dojoType="GreekingWidget" 
            paragraphs="2" 
            addClass="FooBarClass"></div>

        <h3>Add CSS style to make them tiny</h3>
        <div dojoType="GreekingWidget" 
            paragraphs="2" 
            sentencesPer="20"
            addStyle="font-size:xx-small;"></div>

</body>
</html>
And here's the test page output...

12 June 2007

The joys of JavaScript error messages

Today I meant to type

someObject.someProperty
but instead I typed
someObject..someProperty
with the incorrect extra period.

Firefox kicked back the amazingly helpful

XML descendants internal method called on incompatible Object
which I stared at dumbfounded. All of Firebug's glorious power was seemingly useless against this error. It didn't help that I was working atop a custom Dojo build.

Then I flipped back to my editor which thankfully still had the cursor next to the extra period. A simple backspace and I was moving again...