The song Powerhouse is one of those things I just never looked up

May 21, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

Skimming through my RSS news reader, I came across this video of "The Philharmonicas" playing a song called Powerhouse.

It sounded familiar at first and then at about 1:10, I figured out why. It's the tune that is used during assembly line scenes in Looney Tunes shorts. Before the www, I used to wonder what the name was but never really had a way to look it up. Even though I've thought of it since then, I never looked it up. Perhaps that song was stuck in an old mindset.


Command Line XML Validation Against Schema XSD

May 21, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

Even though I do a ton of work with XML files, I don't use actual XML Schema documents very often. It seems like this is the case with most people who work with XML files. After spending some time working with schemas, it's not hard to see why. They are tedious and it is very easy to get by without having to use them. In day-to-day operation, they offer very little value. Especially considering the language is dense to start with and bulky to work with.

One plays where Schemas are very valuable is in testing software while it's still in development or when a change is being put in place. The language has a lot of potential for catching little errors that would otherwise be missed in high level test suites.

The impression I get is that a lot of other folks are running XML without really worrying about created Schemas. One of the main reasons is that I had to search for a couple hours to find a good command line tool that validates an XML document against a schema. The one I found and have so far been pleased with is Sun's "Multi-Schema XML Validator" known as "msv". The most recent version can be downloaded here. Note, if you are using a Mac with it's standard Java install, the latest version won't work out of the gate. Instead you can use the older version which is available here as msv.zip.

The core of msv is stored in a .jar file that is included with the zip. To run msv, the command would be something like:

java -jar /path/to/msv.jar /path/to/schema.xsd /path/to/doc.xml

If the XML doc is valid, you'll see a message like:

start parsing a grammar.

validating /path/to/doc.xml

the document is valid.

If there is an error, msv will report it and let you know what's wrong. Sometimes these can be a little cryptic, but when they are, they have enough info to get you started in the right direction.


Recovering Deleted Photos

May 04, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

If you have ever formatted a compact flash card that had photos on it you still needed, the first thing to do is make sure you don't mess with the card at all. Then,  check out PhotoRec. An open source tool that tries to recover photos that have been deleted. It's a bit cryptic to use, but there is a step-by-step procedure in the documentation that'll walk you thru it. I've used it once with success to help get photos off a friends card.

If things get corrupted, there is also TestDisk, which is bundled with PhotoRec. I haven't used it, but it's worth a shot if you run into real issues with a card.

Other than being Free Open Source Software, these apps have the added bonus of being available on multiple operating systems including Mac and Windows.


Changing the screenshot directory on a Mac

April 30, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

On Macs, there are two great hot-key combinations that can be used for doing screen captures.

  • command + shift + 3 = full screen capture
  • command + shift + 4 = a partial screen capture based on a box you draw.

By default, when you make a grab with these commands the output files are saved directly to your desktop. If you have a messy desktop, they can be hard to find. Using a little command line magic, you can change this output location to any directory you choose. The command itself is:

defaults write com.apple.screencapture location /output/path/directory

You would just need to change "/output/path/directory" to the location where you want the screen grabs to go.

I got found this command on this page from the Mac Developer Tips site. Just putting it here so that I can find it easier in case I ever need it again.


Unix Command Line Tools for Windows

April 30, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

I work on Mac, Linux and Windows machines during the course of an average day. A lot of this work is done on the command line. Since underneath a Mac is the heart of a Linux type machine, the basic commands that work on one also work on the other. Windows machines are a different story. Lots of commands that work on Mac/Linux are different on Windows machines or simply don't exist at all.

For example, when you want to see what's in a directory from the command line the Mac/Linux command is "ls", but on Windows, it's "dir". Since most of my time is spent with Mac/Linux I end up trying to use "ls" frequently when I'm working on a Windows machine. This doesn't hurt anything, but it doesn't work and it is a little break in the concentration.

command-line-ls.png

The good news is that since most of the command line tools on a Linux machine are open source, they can be ported to different operating systems. This is exactly what was done with the Open Source project UnxUtils. It's a collection of most of the key command line tools Linux folks are used to working with. If you spend most of your time on Mac/Linux but have to bounce around the Windows command line on occasion, I highly recommend them.


Awesome video of a moment in time

April 30, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

Found via Laughing Squid. I would hire these guys. Created by Stink Digital.


Controlling Subversion svn with Perl

April 10, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

Controlling Subversions "svn" command with Perl can be a little tricky. The biggest issue is the fact that svn errors are sent to STDERR instead of STDOUT. If you are running the svn command via backticks, perl only captures STDOUT which means you won't see errors. One way around this is to setup the command you fire off in Perl so that it sends STDERR messages to STDOUT so that 100% of the svn output goes back to your Perl script. This can be done by using something like:

my $response = `$cmd 2>&1`;

With that, both the STDOUT and SDTERR output is captured in "$response". If you check out this page on perl.com, you'll see how to determine which content is sent to STDOUT and which is sent to STDERR. This could be used to split out the responses are respond accordingly in your script. I like to approach it a little differently.

Since I already know what the svn command I send will do if it works, I don't really care about the success messages. I only need to know if something goes awry so I can deal with it appropriately. To do this, I use svn's "-q" argument for quite output. With this set, all the commands I use don't return any content to STDOUT if they succeed, while the report errors to STDERR. So, if nothing comes back, everything is good, but if I get a response, something went wrong.

A simple script that tries to export would look like this:

#!/usr/bin/perl -w use strict;

my $svnCmd = 'svn -q export http://www.example.com/svn/path';
my $svnResp = `$svnCmd 2>&1`;

if($svnResp)
{
  print "Something went wrong. SVN Error:\n";
  print $svnResp;
}
else
{
  print "Success!\n";
}

Since there isn't a svn server at the above example.com URL, running this as is would fail and respond with something like:

Something went wrong. SVN Error:
svn: PROPFIND request failed on '/svn/path'
svn: PROPFIND of '/svn/path': 405 Method Not Allowed (http://www.example.com)

If you change the URL to an actual repository you have access to, you'll receive the "Success!" message if you are able to output. Once you have the ability to determine the success or failure of the svn command, it is a lot easier to manage Subversion via scripts. The other benefit of this is that if you run the script in a crontab, the STDERR doesn't get kicked over to send out emails.


Java Classpath for Mac OS X Leopard

April 08, 2009

Note: This post was migrated from my old blog software. It hasn't been cleaned up yet (and might not ever be). Don't be surprised if the formatting, links, images, etc... are messed up.

Doing a little Java development on the Mac. Just making a note to myself about XOM (an XML Object Model). According to the web site, "XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with Java that strives for correctness, simplicity, and performance, in that order.", and "XOM is designed to be easy to learn and easy to use. It works very straight-forwardly, and has a very shallow learning curve. Assuming you're already familiar with XML, you should be able to get up and running with XOM very quickly."

Sounds worthy of looking into.

From a higher perspective, in order to utilize XOM the xom-1.2.1.jar file (which can be downloaded from the XOM page), must be added to the Java class path. On Macs, one possible location for this is '/Library/Java/Extensions/'.


Go To Index Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107


© Alan W. Smith
RSS Feed