Thursday, August 24, 2006

svnmerge - Subversion merge tracking tool

If you are tracking merges manual in Subversion (SVN) you need to automate merge tracking with svnmerge.
 
Check out this excellent tool at:
 
http://www.dellroad.org/svnmerge/index
 
- Cory

Tuesday, August 22, 2006

Windows Logon Types, Event Logs & an Explaination

If you have any questions about WindowsNT logon types, checkout this page.
 
 
These are often used in the context of the .Net CLR or the Windows Event log.  Good reference material if you find yourself wondering what type of login "8" is.
 
Send you a $1 PayPal payment if you comment on this with the answer for "What is logon type '8'?"
 
I am making this offer to prove a point -- no one reads this blog.

Monday, March 27, 2006

Make Any HTML Form Print Friendly With JavaScript

 
The following code snipet loops over all the form elements looking for "text" form inputs and converts them into wrapping DIV tags.  This browser-based transformation makes printable confirmation pages easy to generate on the server using the same HTML form generation techniques that are used to display the data in an edit-ready format.
 
 
 
var replaced = 0;    
var reDigit = /^\s*\d*\s*$/;
for (var i=0; i < this.document.forms[0].elements.length; i++) {
     if( document.forms[0].elements[i].type == "text" ) {
          var text = this.document.forms[0].elements[i].value;
          if( text == "" ) {
               var newP = document.createElement("p");
               newP.style.fontFamily = "Arial, Verdana, Helvetica, sans-serif";
               newP.style.fontSize = ".90em";
               var txtNode = document.createTextNode("--");
               newP.appendChild(txtNode);
               document.getElementById(document.forms [0].elements[i].id).parentElement.appendChild(newP);
               document.getElementById(document.forms[0].elements[i].id).style.display='none';
          } else {
               var newP = document.createElement ("div");
               newP.style.fontFamily = "Arial, Verdana, Helvetica, sans-serif";
               newP.style.fontSize = ".90em";

               if( this.document.forms[0].elements[i].value.search(reDigit) == -1 ) {
                    newP.style.border = "solid black 1px";
                    newP.style.width = "179px";
                    newP.style.padding = "2px";
                }
               var txtNode = document.createTextNode(text);
               newP.appendChild(txtNode);
               document.getElementById(document.forms[0].elements[i].id).parentElement.appendChild(newP);
               document.getElementById (document.forms[0].elements[i].id).style.display='none';
          }
    }

Saturday, March 04, 2006

The Good, the Bad and the Ugly

I've had some feedback about my growing appreciation of .Net development and Visual Studio.  I must admit, it is true -- I am growing to really enjoy .Net development.
 
The Good
  • .Net lets you catch a lot of errors at compile time
  • The FCL is an amazing collection of utilities.  Spend a lot less time considering alternatives and researching available software modules (CPAN.)
  • The .Net debugging tools and package analysis tools are great when you're in "debugging" mode
  • The Visual Studio IDE has a vast number of extremely useful third-party plug-ins that can really speed up development
  • Generic .Net features such as "region" and XML Comments greatly increase organization and documentation efficiency within large implementations
The Bad
  • .Net makes you wait for a compile before you can test most changes.  This results in much slower development vs. dynamic languages, especially if the required compile gets Ugly (see below) and you have to reboot.
  • .Net, under Windows, is tightly coupled with the OS.  This results in a lot of confusion and non-.Net (OS specific) knowledge is required for many complex implementations
  • The tools development companies that partner with Microsoft to produce VS.Net plug-ins ignore a lot of open-source/industry-standard solutions, opting instead to support Microsoft-centric technologies and approaches (SCM integration, for example)
  • The ASP.Net web development environment contains many foriegn (to the classic web developer) concepts.  This is the result of .Net's attempt to unify the programming model for Win32 and Web application development.  While this decreases the learning curve for developers already familiar with one, it increases and complicates the learning curve for non-.Net developers.  This because a problem when people unfamiliar with ASP.Net perform page and widget design (Human Factors Engineering team) from the perspective of form-post based applications without considering the various complexities of translating concepts to ASP.Net pages and user controls.
  • Visual Studio tries to be all things for all people.  It includes a database designer, an image editor, an XML editor, a CSS editor, a WYSIWYG XHTML editor and countless other edit modes and supported file formats.  While this is useful, the overall quality of each mode suffers.  For example, the XML editor does not provide a "pretty print" feature for XML files that are not human readable (indented) and the CSS editor has limited support for anything but CSS 1.1
The Ugly
  • .Net on Windows involves a lot of file lock related reboots, DLL versioning nightmares and Visual Studio Crashes
  • I am considerable more skilled with XHTML than the Visual Studio designer in 2003.  VS.Net messes up my HTML constantly and I spend an inordinate amount of time fixing it.  I have found ways to introduce "errors" into my XHTML so that the Visual Studio designer won't load them, but that results in further slow-downs because without the designer no auto-vivification of server-side controls occurs.
  • My "development environment", Visual Studio 2003, SQL Server, IE and Visual Studio 6.0sp6 consumes about 1G of RAM while under heavy (debugging) use.  This is an excessive amount of system resources!

Thursday, March 02, 2006

Formatting Date Output in C# with System.DateTime

Here is great page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp

The quick and dirty is, pass the following strings to DateTime.ToString( ); to get these outputs

d 1/3/2002
M/d/yyyy (ShortDatePattern)

D Thursday, January 03, 2002
dddd, MMMM dd, yyyy (LongDatePattern)

f Thursday, January 03, 2002 12:00 AM

F Thursday, January 03, 2002 12:00:00 AM
dddd, MMMM dd, yyyy h:mm:ss tt (FullDateTimePattern)

g 1/3/2002 12:00 AM

G 1/3/2002 12:00:00 AM

m January 03
MMMM dd (MonthDayPattern)

M January 03
MMMM dd (MonthDayPattern)

r Thu, 03 Jan 2002 00:00:00 GMT
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern)

R Thu, 03 Jan 2002 00:00:00 GMT
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern)

s 2002-01-03T00:00:00
yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern)

t 12:00 AM
h:mm tt (ShortTimePattern)

T 12:00:00 AM
h:mm:ss tt (LongTimePattern)

u 2002-01-03 00:00:00Z
yyyy'-'MM'-'dd HH':'mm':'ss'Z' (UniversalSortableDateTimePattern)

U Thursday, January 03, 2002 8:00:00 AM

y January, 2002
MMMM, yyyy (YearMonthPattern)

Y January, 2002
MMMM, yyyy (YearMonthPattern)

Tuesday, February 21, 2006

.Net 1.1 and System.Math.Round -- Banker's Round and .5

The provided Math.Round function implements "bankers rounding", which rounds to the nearest even number when a number ends in .5
 
This means that both 1.5 and 2.5 round to 2.  This is not what most e-commmerce and real-world implementations need.  Here is a "normal" or "US round" function.
 
 
/// <summary>
/// Rounds the specified to round.
/// </summary>
/// <param name="toRound"> To round.</param>
/// <param name="digits"> The digits.</param>
/// <returns></returns>
namepsace MathUtils {
 public static decimal Round( decimal toRound, int digits ) {
   toRound *= (decimal )(Math.Pow(10d,(double)digits));
   if( toRound - Decimal.Truncate(toRound) >= .5m ) {
      toRound += 1;
   }
   toRound = Decimal.Truncate(toRound);
   toRound /= (decimal)( Math.Pow(10d,(double)digits));
   return toRound;
 }
}

Saturday, February 18, 2006

How to Pretty-Print an XML Document with C#

Used this today XML formatting with C# web page.

Thought I'd post a link. I'ts about formatting, indenting XML output in C# or VB.Net.

Check it out!

Tuesday, February 14, 2006

Tuesday, January 24, 2006

Another Web Project Annoyance

YAWPA (Yet Another Web Project Annoyance)

- Visual Studio 2003
- IIS 6

When I have a solution in debug mode attached to aspnet_wp.exe and try to open another solution that uses a web project, the second instance of Visual Studio just freezes ... no warning, no error, nothing.

Really annoying!  I was just trying to open the other solution so I could check something in a non-web project for reference and got sucked into trying to figure out why it wouldn't load.  Took me a few minutes to figure it out but I've been coding for many hours now and my problem solving skills are starting to suffer I think.

Monday, January 23, 2006

PInvoke How-Tos!

Matt Tiemeyer found this site today while we were digging up some obscure PInvoke API documentation called PInvoke.net ... it's like a Wiki with everything you wanted to know about PInvoke and lots of sample code.  Very great resource ... added it to my bookmarks and you should too.

From the Site:

It's time to stop writing PInvoke signatures from scratch! Instead, copy and paste your way to productivity!

And this site has more than just signatures & type definitions. For example:

  • Folks like you are sharing gotchas, tips, and samples specific to managed code. For example, check out why you shouldn't call CoInitializeSecurity from managed code.
  • Alternative managed APIs are suggested as a replacement for using PInvoke in the first place.
  • This site contains miscellaneous community resources that are helpful for being successful at unmanaged code interoperability. Feel free to add to these pages, too!

Wednesday, January 18, 2006

Monday, January 09, 2006

Tuesday, December 27, 2005

SwitchTower Development Tool

I have been working on a cluster-aware .Net/VB/C++/ASP.Net/COM+ deployment system similar in concept to SwitchTower.

Friday, December 09, 2005

Uninstalling Existing StrongName Keys with sn.exe Created By Other Users

When trying to a strongname in Windows XP with sn.exe -d, we got an "8013141C" error - "Failed  to install  key  pair  -- Object  already  exists.".  This was caused by having the same key installed under a different domain, domain user, or local user account.

The hack to fix this is:
  1. Browse to  %SystemDrive%\Documents and  Settings\AllUsers\ApplicationData\Microsoft\Crypto\RSA\MachineKeys
  2. Grant rights to Adminstrators, or whatever group you belong  to
  3. Take Ownership of this folder (click Advanced under Security, and then click the Ownership tab at the top)
  4. Apply the changes to the children ("Replate permission...")

Subversion and ASP.Net

ASP.Net and Subversion have a point of contention. ASP.Net does not like files that start with "." and Subversion uses folders called ".svn". A work-around for Subversion < 1.2.6 exists in the form of a "hacked" version of SVN.exe that uses "_svn" instead of ".svn". This same hack is provided as a special (unsupported) version of TortoiseSVN that also uses "_svn". However, if you use the TSVN hack, you cannot use the SVN.exe that comes with versions < 1.2.6.
When Subversion 1.3.0 is released, this will not be an issue:

See:

Subversion 1.3 Release Notes
and
ASP.Net Hack Notes

You can, in the mean-time, download a modified 1.2.x EXE from Jonathan Malek's blog or a modified 1.1.3 or 1.1.4 modified EXE from another entry.

I am currently using the 1.2.0 binary with the TortoiseSVN ASP.Net hack until SVN 1.3 is released.

Monday, November 14, 2005

Development Links Today

If you haven't seen this,


and you use Win32 .Net applications, you should look.

Trying to use WebDAV under Windows without luck?

Sometimes, Enterprise Manager just won't load ... then what?

Thanks for visiting! Checkout my under-redesign site at http://www.frognet.net/~digital/

New Mono Release Today

The Mono team released a new version today.
 
 
Check it out.

Tuesday, November 08, 2005

Development Tools

I'm using customized versions of the following software:
A fairly simple set of modifications and Perl scripts are used to tie these tools together.

Friday, September 16, 2005

Creating New Processes in .Net and ASP.Net

Did you know that Process.Start always uses the security context of the parent ASP.NET process?
 
Need proof?  Write a simple ASP.Net application that launches "whoami.exe" and captures the result.  No matter how you configure your Web.Config file, you will always see the "ASPNET" local machine account.  You could, yes, change Machine.Config however, that will change the process owner of all spawned processes and the entire ASP.Net application framework.  Probably not what you want.
 
 
 
An alternate implementation of a method called CreateProcessAsUser() can be found in this CreateProcessAsUser blog entry on Ode to Code.
 
 
My research into this topic, for a work-related issue, led me to this Building Secure ASP.NET Applications site .  If any of the above links confuse you -- tokens or impersonation, for example -- this Microsoft Patterns & Practices chapter is very useful.  Not only does it explain a lot of the basic Win32 security concepts required for making effective use of ASP.Net impersonation and the CreateProcessAsUser() method but you can learn a fair amount related to general .Net security and secure application design.

Testing .Net Applications

A series of links to highly useful Unit Testing systems.
 

I hope these links help you explore different tools for building better Unit tests.

Tuesday, July 26, 2005

CPAN for Mono and C#

One of the reasons that Perl remains one of the most cost effective and fastest development systems available today is CPAN the Comprehensive Perl Archive Network, a public web site that maintains literally tens of thousands of Perl modules, scripts and documents. This site allows Perl programmers to re-use and rapidly repurpose existing Perl code for new projects without reinventing the wheel.

One CPAN you will find vast quantities of high quality, high performance software. If C# and Mono are expected to succeed, they will need a similar site to CPAN, PEAR (PHP's CPAN) or PyPI (Python's CPAN.)

Without a community site for sharing open source modules, Mono and C# will never reach the level of rapid development you can find in LAMPpp application development. A brave soul (Joshua Tauberer) has created MonoLibs, a directory of open-source C# libraries for Mono and Microsoft .NET.

I encourage you to take a look and, perhaps, even contribute the C# code you are working on.

Friday, July 22, 2005

Live Mono CD Images

The Mono Live CD is a way for you to try out Linux, the Mono Framework 1.1.7, and the newest desktop applications without modifying your current computing environment.

You can download MonoLive here and test it out on any machine that has a bootable CD-ROM drive. The MonoLive CD-ROM also includes all the files you need to install the Mono environment in Windows XP.

In addition to Mono, the MonoLive CD-ROM also includes a number of good Linux utilities created with or supporting Mono:

  1. Develop, compile and run software with MonoDevelop.
  2. Listen to your music collection in style with Muine.
  3. Take notes with Tomboy.
  4. Manage your photos with F-Spot.
  5. Search music, photos, chats, and documents with Beagle.
  6. Explore web applications such as ASP.NET Forums, IBuySpy, and mojoPortal.