Friday, April 27, 2007

Recommended reading for developers

Another list from "Coding Horror" - programming and human factors by Jeff Atwood.

Blog here.

Reading list here.

Enjoy!

Thursday, April 19, 2007

ASP : Deploying web site from Visual Studio 5

From the ASP solution,

File / Add / New Project / Setup and Deployment / Web Setup Project

Type in a name and enter "OK".

The entry will now be in "Solution Explorer". Right-click and select "Add / Project Output". Ensure "Content Files" is selected and click "OK".

Now we want to build it. Right-click again and select build. This will create the .msi file in the directory.

Enjoy!

SOAP : Asynchronous web service

Had to implement an asynchronous web service which did not need to be real-time so no response was needed.

Had me a bit puzzled until I realised that a web service can return void!

i.e. in ASP:

[WebMethod]
public void webMethod(Some parameter)

compiles and runs no problem.

So what does it return?

The WSDL shows:


s:element name="webMethodResponse"
s:complexType /
/s:element


So it actually returns null!

Enjoy!

Wednesday, April 11, 2007

Windows : Getting a file list

Often need to put a list of files into a Word document or some such.

One way is to activate the command prompt (DOS box), navigate to the required directory and type:

dir /ON /B > dir.txt

The /ON option lists the files in alphabetic order. Further options are:


/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order


The /B option uses a bare format (i.e. no heading information or summary).

The pipe option (>) sends the results to a file called dir.txt in the current directory.

From here, it can be cut & pasted into the Word document.

BTW, if you ever need to get information about a DOS command, type:

help "command"

e.g. help dir

Enjoy!

Unix : sum

Often transfer large files around using FTP or whatever e.g. ear and war files and it's useful to see if they were transferred without error.

sum is a useful utility to use for this.

It calculates and prints a 16-bit checksum for the named file and the number of 512-byte blocks in the file.


sum abcd.ear
05612 25680


Enjoy!

Monday, March 19, 2007

SOAP : WSCF - Web Services Contract First

"Contract first" involves creating the WSDL first and then using that to generate the code. There aren't many tools to do this.

Essentially, this approach involves modelling the messages, data and interfaces at the start and then publishing them as a contract before coding the implementation begins. Typically, modelling of the data and messages is done using a XML Schema (i.e. XSD files) and the contract is formalised using the Web Services Description Language (WSDL files).

thinktecture offer their free tool to do this which is nicely integrated with Visual Studio (2003 and 2005) and also allows a command line interface.

Get it from here.

Documentation and walk-through here.

Two MSDN articles which cover this are:

here and

here

Enjoy!

Monday, February 26, 2007

C# : Predefining an array

The classic way of creating an array is:


Document[] doc = new Document[2];
doc[0] = new Document();
doc[0].code = "ABC";
doc[1] = new Document();
doc[1].code = "DEF";


but a more elegant way is:


Document doc1 = new Document();
doc1.code = "ABC";
Document doc2 = new Document();
doc2.code = "DEF";
? = new Document[] {doc1, doc2};


Enjoy!

Tuesday, January 23, 2007

C# : XML in a C# string

Note: "Left quote" replaced by #, "Right quote" replaced by ^

How do you do this? It has quotes, slashes etc. e.g.

string zzz = "#employees xsi="http://www.w3.org/2001/XMLSchema-instance"^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";

won't compile.

You could put a "@" in front to make it a verbatim string literal but it still won't compile.

The trick is to make each quote (") a double quote ("") e.g.

string zzz = @"#employees xsi=""^#employee-record^#employee-id^00001#/EMPLOYEE-ID^#employee-from^01 10 2006#/EMPLOYEE-FROM^#employee-to^01 11 2006#/EMPLOYEE-TO^#employee^#employee-id^00001#/EMPLOYEE-ID^#employee-name^Washington#/EMPLOYEE-NAME^#employee-firstname^George#/EMPLOYEE-FIRSTNAME^#employee-dob^01 01 1930#/EMPLOYEE-DOB^#/employee^#/EMPLOYEE-RECORD^#/employees^";

which does compile.

Enjoy!

Thursday, January 11, 2007

Windows XP : cisvc.exe hogs the hard drive

My PC randomly just sat there with the hard disk light on but I wasn't doing anything - plus it was dog-slow.

Using the excellent Process Explorer, I discovered that the "cisvc.exe" program was the cause of the problem. This is part of indexing services.

My first solution was simply to suspend this via Process Explorer. (Right click on cisvc.exe). This helped but I had to do it every time on start-up.

So I googled and found one possible solution:

My Computer - right click on the C: drive - Properties - uncheck "Allow Indexing Service to index this disk for fast file searching" in the General tab.

This helped but the problem still remained.

Then I found another, better solution:

Control panel - Administrative Tools - Computer Management - expand "Services and Applications" - right-click on "Indexing Service" - "All Tasks -> Tune Performance". Then decide what level you want.

Enjoy!

Tuesday, December 19, 2006

Unix : Exporting a schema / stored procedure packages

Often you need to update the stored procedure packages for a schema.

So you laboriously export them via DDL and pretty them up and then run them on the target schema and then commit them.

Sometimes it's just easier to export the schema as an Oracle dump (which includes all the related stored procedures) and then import them on the target schema.

An example of the export command is:

exp login/password@schema file=target file directory/export name.dmp

Enjoy!

Friday, November 10, 2006

Unix : Libraries in an executable

A useful command to do this is:

ldd executable name

This will list out all the libraries required by that executable.

Enjoy!

Monday, November 06, 2006

Misc : Folder / file comparisons with hard drive and FTP

I frequently have problems comparing folders on my PC with folders on a machine that is accessible mainly by FTP.

An excellent tool for this is Beyond Compare which allows all combinations of local driver and FTP including FTP to FTP.

Also allows custom compares so you could create a preprocessor to do some manipulation before the actual compare.

A massive time saver.

Enjoy!