Manually Installing Drupal 6.20 on GoDaddy Free Linux Shared Hosting

GoDaddy offers free hosting when you purchase a domain. The free hosting shows ads on all of the hosted pages and prevents you from installing their offered applications.
Follow these steps to install Drupal 6.x on the free hosting account and hide the ads.
  1. Create the MySQL database. The free hosting allows up to 10 databases.
  2. Download Drupal 6.20 http://ftp.drupal.org/files/projects/drupal-6.20.zip
  3. Expand the downloaded zip (e.g. /drupal62 )
  4. Upload the folder via FTP to your GoDaddy folder /drupal62
  5. Run /drupal62/install.php to finish setting up your Drupal installation.

At this point, your Drupal install is accessible at http://www.example.com/drupal62 (replace example.com with your primary domain on GoDaddy). You can also create a sub domain to point this folder or another domain name and treat it as a stand alone website.

Hiding the Ads

To hide the “free hosting” ads from your site, edit the CSS for your Drupal template and add this entry

#conash3D0{
  display: none;
}

Subversion Error Message on Windows 7/Windows 2008 Server

Some times when I am performing a Subversion task (update, commit, check out) I get an error message stating that files can’t be moved or deleted. A subsequent boot of my machine causes CHKDSK to run (this is what concerned me).

The error message looks like this:

Error: Can't move
Error: '[...]\.svntmpentries'
Error: to
Error: '[...]\.svnentries':
Error: The file or directory is corrupted and unreadable.

This is a known issue with Windows 7 and you can http://support.microsoft.com/kb/982927/en-us”>download a Hot Fix to fix it.

This issue is also addressed in Service Pack 1 for Windows 7 and Windows Server 2008.

Here is a good post on the issue: http://serverfault.com/questions/72561/64-bit-tortoisesvn-on-windows-7-says-file-or-directory-is-corrupted-and-unreadab

Template for SQL Server Stored Procedures

Talking with our in house DBA, it was mentioned that DROP/CREATE is a bad model to follow when updating stored procedures. However, this is the model used in the stored procedure template provided by Visual Studio 2005/2010. Here is a modified template that creates an empty stored procedure if it doesn’t exist and performs an ALTER on all subsequent calls.

IF NOT EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Stored_Procedure_Name')
BEGIN
exec sp_executesql N'CREATE PROCEDURE [dbo].[Stored_Procedure_Name] AS select 1'
END
GO
ALTER Procedure Stored_Procedure_Name
(
  @parameter1 int = 5,
  @parameter2 datatype OUTPUT
)
AS
GO

GRANT EXEC ON Stored_Procedure_Name TO PUBLIC

GO

IIS Express

Web development on the Microsoft platform has always had its hurdles. With Windows XP, your development environment would use IIS 5 where as the server that would host the production site would be IIS 6. Additionally, there was the issue where we were limited to a single website running on that machine (this was a pain when working on multiple projects at the same time).

Microsoft’s virtual web server that would get kicked off by Visual Studi0 (Casini) alleviated some of the hardships by allowing each one of your web projects to run on an individual site. With the release of IIS 7, and particularly the rewrite rules that they provided, we ran into another issue where our production environments supported rest-full, SEO friendly URLs but the virtual web servers initiated by Visual Studio would not be able to process the URLs.

Recently, Microsoft addressed many of these issue with IIS Express. Scott Guthrie blogs about this new tool here: http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx

Custom Event Tracking with Google Analytics

I have been researching a method for tracking clicks to external sites from my site. Google Analytics’s custom event tracking is a nice solution. Here is a link for the asynchronous event tracking scripts for Google Analytics: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html#Anatomy. Keep in mind that to work with this code, you need the 3rd generation of Google Analytics scripts on your site. If you are using urchin.js or ga.js then you need to update your scripts.

Here is an example implementation:

<html>
<head>
<script type="text/javascript">
function LogLinkClick( linkId ){

_gaq.push(['_trackEvent', 'Outgoing Links', 'Click', 'Link ' + linkId]);

alert( "Clicked 'Link " + linkId + "'" );
}
</script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>
<body>
Hello World!<br /><br /><br />

<a href='javascript: LogLinkClick(1);'>Link 1 </a><br />
<a href='javascript: LogLinkClick(3);'>Link 3 </a><br />
<a href='javascript: LogLinkClick(5);'>Link 5 </a><br />
<a href='javascript: LogLinkClick(7);'>Link 7 </a><br />
</body>
</html>

You need to dig around the Google Analytics dashboard to find the event tracking reports.

  1. When you access the main page for Google Analytics, click the View Report link for the profilefor which you are tracking the events.
  2. On the left navigation, select Content
  3. Under Content, select Event Tracking and Categories
UPDATE
Google Analytics has released a beta of their new user interface. To view your custom events in this new user interface, expand the Content tab on the left navigation then Events and Overview.

HTML5

I want to stay ahead of the curve when it comes to HTML5 and everything it has to offer so I’m using this blog entry to chronicle my research and any cool tools I find around the interwebs.

I found this nice sandbox the other day http://rendera.heroku.com/. They have some nice example and am learning a lot from it.

W3Schools has a nice primer on HTML5. 

Some questions I have and would like to answer for myself are…

  1. What is the purpose of the <address> node? What do I gain from using it?
  2. How can I integrate HTML5 with ASP.NET Web Controls?

More questions to come.

Enterprise Library Data Access Application Block + SQL Optional Parameters

The Enterprise Library Data Access Block provides a number of ways of calling a stored procedure.

Database _db = DatabaseFactory.CreateDatabase(<Connection String Name>);

Let’s now assume that we have a stored procedure usp_MyStoredProc that takes a single parameter @param1. If this is a require parameter, both of the following statement blocks will result in the same outcome:

public DataSet CallMyStoredProc( int value ){
return _db.ExecuteDataSet( “usp_MyStoredProc”, value )
}

public DataSet CallMyStoredProc( int value ){
DbCommand command = _db.GetStoredProcCommand(“usp_MyStoredProc” );
_db.AddInParameter( command, “param1”, value );
return _db.ExecuteDataSet( command );
}

However, now let’s assume that @param1 is an optional parameter that we don’t want to pass in from our data access method, we are limited in our options.

public DataSet CallMyStoredProc(){
return _db.ExecuteDataSet( “usp_MyStoredProc”)
}

This method will fail with an exception because the parameters provided to the stored procedure (none) don’t match the parameter count for the stored procedure (1).

Creating an actual DbCommand and executing it, however, will not cause an exception. In this scenario, the following code block will work without causing an exception:

public DataSet CallMyStoredProc( int value ){
DbCommand command = _db.GetStoredProcCommand(“usp_MyStoredProc” );
return _db.ExecuteDataSet( command );
}

Setting up Cruise Control .NET 1.5/1.6 on Windows 7 + IIS7

I have been setting up a new continuous integration system on my laptop for some of my personal projects and thought it would be a good time to upgrade to Cruise Control 1.5. I came across some issues during the setup so I have put up my notes on the process in case anyone else has the same issues.
My Development Environment
Windows 7 (64-bit)
IIS 7.5
Cruise Control 1.6
Nant 0.86, Nant 0.91-alpha2
Visual Studio 2008, Visual Studio 2010
Installation Steps
  1. Download the installation package from Sourceforge.net.
    • The release build of version 1.5 is available here on Source Forge.
    • The nightly build for version 1.6 is available here on CCNet Live.
  2. Run the installer. This will copy the files you need and create the IIS site/virtual directories needed to access Cruise Control .NET from your browser.
  3. Open your Internet Information Services (IIS) Manager (Start -> Run -> inetmgr )
  4. Create a new website point the site to <INSTALL PATH>webdashboard.
  5. Change the bindings for the new site to a unique port. ( I use port 90 and the CCNET is then accessed via http://localhost:90)
  6. Open the application pool created for this site and change the ‘Managed pipeline mode’ to ‘Integrated’.
  7. Open the services manager (Start -> Run -> services.msc) and start the Cruise Control .NET service.

Security& Permissions Issues

The default installation may cause issues due to permissions required to create folder (there are folders created on the fly for each CCNET project). It is best practice to have the CruiseControl.NET service running under a service account with proper permissions in the <INSTALL PATH>server and <INSTALL PATH>webdashboard  directories and subdirectories. The service account needs enough permissions to create new folders and files within the .server folder.

Plugins

The new version of Cruise Control .NET has an admin dashboard that allows you to manage the plugins to display on the report pages. To enable the login, you need to modify /webdashboard/dashboard.config and add a password for the <administrationPlugin /> element.

As you install and uninstall the plugins, click the View Log button that appears next to the “Package has been installed” message to view the log of the installation. If there were any complications with the installation (usually permissions related), this log is your best source of information).

Visual Studio 2010 Unit Tests

The Visual Studio 2010 unit test results file has changed slightly from 2008. CCNET 1.6 addresses this issue.

jquery, ajax, and .NET Web Services

Recently, I have been working on a few projects that require an ajax friendly life cycle for an ASP.NET web application. Much of the work I did is based on Rick Strahl’s post: http://www.west-wind.com/weblog/posts/896411.aspx.

Working on top of what I learned from this article, I decided to leverage the rich capabilities of .NET’s Web UI components as part of my ajax implementation using HTML injection. I used jquery to bind a standard button to make a call to my Web Service method.

The service created and populated a standard GridView object. The service would then render that object and return the HTML that was generated. This HTML, once returned by the service call, would be injected into a DIV tag that served as the container for the results table.

My initial implementation is a naive solution that renders full HTML on the server side and passes that back to the client-side. My ASP.NET page already has a script manager so I added a reference to my web service (simple .asmx in this scenario).

My service defines a method Foo:

namespace Client.Project.Services
{
///
/// Summary description for ConceptServices
///
[WebService(Namespace = “http://tempuri.org/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, Name = “MyBinding”)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class ConceptServices : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public String Foo()
{
return “Hello World!”;
}
}
}

To make a call to this method via client-side javascript, simple use the fully qualified name for the method:
Client.Project.Services.Foo( successMethod, failureMethod )
Assuming Foo is overloaded to take in parameters, you would pass in those parameters first:

var i = 3
var s = “bar”
Client.Project.Services.Foo( i, s, successMethod, failureMethod );
function successMethod( o ){
//o is the value returned by the web service call
}

Continuous Integration with Cruise Control, .NET (C#, WPF, ASP.NET) Projects, and NAnt

UPDATE: NAnt 0.91 Alpha 2 has been released with support for .NET 4. Download it here.
UPDATE: CruiseControl.NET 1.5 (Final) has been released and is available here.
UPDATE CruiseControl.NET 1.5 RC1 has been released and is available here.

My Cruise Control .NET implementation consists of numerous development projects each with multiple different Cruise Control .NET projects associated with it (one per environment per branch). In order to make the projects more maintainable, I have created a separate configuration file for each development project. Defining variables and separating ccnet.config configuration file into smaller files allows for easier maintenance of each project over their lifetimes.

Defining and using variables

Variables can be defined using the following format

<cb:define KEY=”VALUE” />

To reference that variable later in the configuration file, simply use $(KEY)

Check out the Cruise Control .NET website for complete explanation of variables using the pre-processor.

Separating the configuration files

<!DOCTYPE cruisecontrol [
<!ENTITY PROJECT_NAME SYSTEM “file:project.xml“>
]>
<cruisecontrol xmlns:cb=”urn:ccnet.config.builder”>
&PROJECT_NAME;
</cruisecontrol>

project.xml would, then, contain the regular xml configuration for a Cruise Control .NET project:

<?xml version=”1.0″ encoding=”utf-8″?>
<project name=”My Project” category=”A Category”>
<workingDirectory>MyProject</workingDirectory>
<artifactDirectory>MyProject</artifactDirectory>
<webURL></webURL>
<triggers>
<intervalTrigger seconds=”900″ buildCondition=”IfModificationExists” />
<scheduleTrigger time=”04:00″ buildCondition=”ForceBuild” />
</triggers>
<labeller type=”svnRevisionLabeller”>
<pattern>Version {major}.{minor}.{build}.{revision}</pattern>
<major>1</major>
<minor>0</minor>
<url>$(SvnBaseUrl)</url>
</labeller>
<sourcecontrol type=”svn”>
<trunkUrl>$(SvnBaseUrl)</trunkUrl>
<workingDirectory>$(BaseDirectory)</workingDirectory>
<cb:SvnOptions />
</sourcecontrol>
<tasks>
<nant>
<executable>$(NAntExecutablePath)</executable>
<baseDirectory>$(BaseDirectory)</baseDirectory>
<targetList>
<target>dist.deploy</target>
</targetList>
</nant>
</tasks>
<publishers>
<xmllogger />
<cb:include href=”EmailConfig.xml”/>
</publishers>
</project>

On caveat with this idea is that changes to the separate configuration files are not recognized until the cruise control is restarted by either restarting the service or modifying the ccnet.config file.

Building and Deploying ASP.NET Web Applications

The NAnt target below is a full parameterized call to MsBuild.exe to compile any solution. ThoughtWorks.CruiseControl.MsBuild.dll provides an MSBuild logger that allows Cruise Control .NET to report the bulid output.

<target name=”build”>
<exec program=”${MSBuildPath}”>
<arg line='”${SolutionFile}”‘ />
<arg line=”/property:Configuration=${SolutionConfiguration}” />
<arg value=”/target:Rebuild” />
<arg value=”/verbosity:normal” />
<arg value=”/nologo” />
<arg line=’/logger:”C:Program FilesCruiseControl.NETserverThoughtWorks.CruiseControl.MsBuild.dll”‘/>
</exec>
</target>

Parameters

MSBuildPath – The path to the MsBuild executable.

For .NET Framework versions 2.0 and 3.5  on a 32-bit Windows OS, use C:WINDOWSMicrosoft.NETFrameworkv2.0.50727MsBuild.exe
For .NET Framework version 4.0, use C:WINDOWSMicrosoft.NETFrameworkv4.0.30319MsBuild.exe

SolutionFile – The relative path from the build file to the solution file. Fully qualified paths are also allowed.

SolutionConfiguration – “Release” or “Debug”.