Thursday, December 29, 2005

AppTrain: A Rails Form Generator

If you've been thinking about trying out Ruby On Rails, you just have to check out the
AppTrain project on Ruby Forge.There is a step-by-step guide to form generation as well. AppTrain is currently an alpha release, but it still looks quite handy. If you want to install it, use the quick-start. The AppTrain Project seems very committed to making it easy to build rails apps. First, they created a Table Generator, and now they are working on a form generator. That's all some simpler administrative apps need!

Monday, December 19, 2005

SQLServer2000: Capture output of EXEC statements

About 2 years ago, I discovered that I could capture the results of an EXEC (@string_variable) statement. We had a server process that logged in as System Admin (SA), so it could perform a directory scan, bulk insert any files it found, and move those files to a "processed" subdirectory.

This process can be used to run any DOS command, and inserts each line of text as a record into a table. We still use this trick to log program responses to a journal table. When reading the sample code, notice that we are using two single-quote characters back-to-back to cause a single quoted argument to be sent to the xp_cmdshell extended command (really a registered DLL accessible only to SA).

Here's an example:

DECLARE @s varchar(255);
CREATE TABLE #cmdOutput(Line varchar(200)) ;
SET @s='INSERT INTO #cmdOutput EXEC master.dbo.xp_cmdshell ''dir c:\temp\*.txt /b''';
EXEC (@s) ;
DROP TABLE #cmdOutput;

A word of caution: Do not use this code in front-line production. It is best suited to maintenance tasks, where the system admin password does not need to be shared with half of the office. If you need to convert this to front-line production code, write a simple application to read the directory, and either parse lines and call a stored procedure for each line, or call a bulk insert for each file (this still requires special permission, but it doesn't require SA).

Wednesday, December 14, 2005

Use and Abuse of XML

This may be considered a rant by some, but here goes.

XML is a data structure which is easily parsed by 3rd party applications. This does not mean that the data can be easily interpreted as information, that is the responsibility of the XML data designer. Depending on your audience, you may have to spell out units (pounds, kilograms, minutes, seconds, etc.). Also, XML IS NOT FAST. Do not use XML between internal components in your application if at all possible.

Thank you for your attention.

Tuesday, December 13, 2005

How to flag spam on BlogSpot

I like, but it has a fair amount of blog-spam. I was searching on the keyword "blacksmith" today, and ran across a number of spammer pages, with javascript that removed the "Flag Content as Objectionable" button. If you are a programmer, you can easily flag these pages anyway, by viewing the HTML source, and searching for "flag". Look for
var ID = 1234567;
and surf to
to help Blogger find these nasties. Once you've done it a few times, it doesn't take long at all.