Travis's lame ol' blog

yay, Travis finally changed his blog!

- Friday, May 13, 2011

Adding An Easy Shortcut to the JSHint javascript validator to Visual Studio

I went to add JSLint to my Visual Studio tools and was disappointed that the WSH version has disappeared (or was discontinued). Luckily the new and improved JSHint supports a WSH wrapper.

  1. Grab JSHLint.

  2. In Visual Studio → Tools → External Tools…

  3. Add a new tool with the following field values:

    //Nologo "%YourJSHintPath%\env\wsh.js" $(ItemPath)
    Initial directory:
    Use Output window


  4. Open up any *.js file you'd like to validate

  5. Select the all new JSHint from your tools menu:


The output that JSHint provides appears to be much more useful than the old JSLint version as well.

- Monday, July 26, 2010

Embedding an XSLT as a string in a DLL binary

Project Properties - Resources

If you want to distribute a class library that relies on an XSL document and only want to worry about a single DLL then this is probably the easiest solution. In Visual Studio follow these commands (and save): Project Properties → Resources → Add Existing file

In this case, I am embedding a file named Core.xsl with a key named Core. That will generate a bit of code that looks like this:


<data name="Core" type="System.Resources.ResXFileRef, System.Windows.Forms">
	<value>..\Resources\Core.xsl;System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>


public static string Core {
	get {
		return ResourceManager.GetString("Core", resourceCulture);
XSL file properties

Be sure to set the properties of the file so that its Build Action is set as an Embedded Resource.

Now when you compile, the entire contents of the XSL file get embedded directly into the DLL as a string. You can now use the new property like this:

public static XslCompiledTransform GetXsl(XmlDocument xDoc)
	bool enableDocumentFunction = false;
	bool enableScript = true;
	XsltSettings xslSettings = new XsltSettings(enableDocumentFunction, enableScript);

	// only enable debugging in DEBUG mode
	bool isDebug = true;
#if (!DEBUG)
	isDebug = false;

	XslCompiledTransform xsl = new XslCompiledTransform(isDebug);
	xsl.Load(xDoc, xslSettings, new XmlUrlResolver());

	return xsl;

public static XslCompiledTransform GetXsl()
	XmlDocument xDoc = new XmlDocument();
	XslCompiledTransform xsl = GetXsl(null, xDoc);
	return xsl;

Previous XSLT stuff:

Compiling An XSLT Into A DLL Binary

- Monday, July 19, 2010

Compiling an XSLT into a DLL binary

Project Properties - Pre-Build Event

Did you know that Microsoft provides tools to compile XSLT files into DLLs? Neither did I before a client recently suggested that I do that on a recent project. It turns out it's extremely easy.

Fire up your favorite console and run the following:

"%PROGRAMFILES%\Microsoft SDKs\Windows\v6.0A\bin\xsltc.exe" /out:SomeProjectPath\bin\SomeXsltDllFileName.dll /class:SomeXsltClassName PathAndFileNameOfXslt.xsl

xsltc.exe might be located somewhere else on your PC and be sure to update the appropriate info in the command above. If it works you can add a reference to this new DLL in your project and use the new class in your code:

XslCompiledTransform xsl = new XslCompiledTransform();

You can also add a pre-build event command line to your project:

"%PROGRAMFILES%\Microsoft SDKs\Windows\v6.0A\bin\xsltc.exe" /out:$(ProjectDir)bin\SomeXsltDllFileName.dll /class:SomeXsltClassName $(ProjectDir)RelativePathAndFileNameOfXsltInProject.xsl

Then every time you hit CTRL+SHIFT+B it will build your XSLT's DLL automagically each time. Here's a sample of what your output should look like:

------ Build started: Project: ProjectName, Configuration: Debug Any CPU ------
Build started 7/22/2010 2:36:11 PM.

Target PreBuildEvent:
    "%PROGRAMFILES%\Microsoft SDKs\Windows\v6.0A\bin\xsltc.exe" /settings:script+ /out:D:\Projects\ProjectName\bin\SomeXsltDllFileName.dll /class:SomeXsltClassName D:\Projects\ProjectName\Xslt\NameOfXslt.xsl
    Microsoft (R) XSLT Compiler version 3.5.30729
    [Microsoft (R) .NET Framework version 2.0.50727]
    Copyright (C) Microsoft Corporation. All rights reserved.
Target CoreCompile:
    C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:bin\SomeXsltDllFileName.dll /reference:bin\SomeXsltDllFileName.script.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\ProjectName.dll /target:library ClassFiles.cs

Compile complete -- 0 errors, 0 warnings

Target _CopyFilesMarkedCopyLocal:
    Copying file from "bin\SomeXsltDllFileName.dll" to "bin\Debug\SomeXsltDllFileName.dll".
    Copying file from "bin\SomeXsltDllFileName.script.dll" to "bin\Debug\SomeXsltDllFileName.script.dll".
Target CopyFilesToOutputDirectory:
    Copying file from "obj\Debug\ProjectName.dll" to "bin\Debug\ProjectName.dll".
    ProjectName -> D:\Projects\ProjectName\bin\Debug\ProjectName.dll
    Copying file from "obj\Debug\ProjectName.pdb" to "bin\Debug\ProjectName.pdb".

Build succeeded.

Time Elapsed 00:00:02.31

More info:

- Monday, August 31, 2009

Adding An Easy Shortcut to the JSLint javascript validator to Visual Studio

Update: 2011-05-13: JSLint WSH no longer available, see JSHint WSH.

Ever wish that Visual Studio had a JSLint add-in? Inspired by a reply to my tweet, I discovered the following solution.

  1. Grab the WSH version of JSLint.

  2. Add this jslint.bat file to the same folder you have JSLint in:

    @echo off
    cscript jslint.js //Nologo < %1
    echo Done.
  3. In Visual Studio → Tools → External Tools…

  4. Add a new tool with the following field values:

    Initial directory:
    Use Output window

    VS: External Tools

  5. Open up any *.js file you'd like to validate

  6. Select the all new JSLint from your tools menu:

    VS: Tools Menu

  7. Try not to let JSLint hurt your feelings too much:

    VS: Output From JSLint

In short, JSLint is awesome.

- Monday, June 08, 2009

Welcome to the new TraviBlog

Hello and welcome to the newly re-skinned TraviBlog. This site is running on a version of dasBlog. I forget which version I originally downloaded, but I've heavily modified the source to be standards-compliant, accessible, removed as many images as possible and also added this ugly theme. Really though, who cares about the theme since most people read blogs in an RSS reader right?

If you want the source feel free to post a comment and let me know and I can generate a huge diff file showing the changes that I've made to the original source.

- Monday, February 16, 2009

Brilliant CSS for the KBD element

Stack Overflow recently implemented some brilliant CSS for <kbd> tags:

	padding: 5px 3px;
	white-space: nowrap;
	color: #000;
	background-color: #EEE;
	border-top: solid 2px #CCC;
	border-right: solid 4px #AAA;
	border-bottom: solid 5px #888;
	border-left: solid 3px #BBB;

There's something inherently beautiful about CSS used to style HTML to look like the physical object it represents.

Example: CTRL+C

- Monday, September 22, 2008

Conversations around the Campfire: an Obama/McCain CSS comparison

This conversation originated at work when we started comparing the CSS used by McCain and Obama (thanks for the link Sam!)...

Ralph W.
Travis H.
compare with:
even by the file names alone you can tell that obama's is a more scalable solution
Ralph W.
It's even localized
/* Espanol Navigation 2.0
-------------------------------------------------------------- */
Travis H.
i like how the absolute last section of mccain's is for the header
Ernie B.
that is so fitting
Ralph W.
cause you can only get head in the white house by going down
Travis H.
TEXT-TRANSFORM: uppercase;
Ernie B.
Ralph W.
that's great
Travis H.
it looks like his css was developed by the department of redundancy department since the font-family is defined in almost every selector
Ralph W.
more of the same
Travis H.
haha, good one
Ernie B.
may as well be tables
Travis H.
INPUT.groovybutton {
not that there's anything wrong with that
i love this class name:
DIV.actioncenterbluebutton_red A {
interesting, Obama's uses EM sizing while McCain's uses PX
Ralph W.
not that there's anything wrong with that
Ernie B.
also fitting
Travis H.
I swear it's as if their CSS files directly correspond with their campaigns
Obama knows the IE6 hack:
* html #nav li * { position: relative; }
interesting, they also use CSS sprites
those trendy fuckers
wow and their spanish classnames are actually spanish!
#nav-donacion {
Ralph W.
McCain blocks those classes at the firewall...see what I did there?

This conversation has been reproduced without anyone's permission

- Friday, September 19, 2008

Conversations around the Campfire: an Apple/Palin comparison

This conversation originated at work when Ralph and I started flaming our resident MacTard developer, Ernie.

Travis H.
*grabs some gasoline*
Travis H.
Mac's are the Sarah Palin of the computing world
Ernie B.
in what respect, charlie?
Ralph W.
not true...Mac's do not have Tina Fey glasses
Travis H.
"we're enterprise ready, we sold an ipod in Russia"
Travis H.
also, i heard that the iphone 3g is retarded
Travis H.
and that the nano is pregnant
Ralph W.
3g has down syndrome ... get it right
Travis H.
you can put EFI in a PC, but it's still a pig
Ralph W.
What's the difference between Ernie on a PC and Ernie on a Mac?
Ralph W.

I have to pick on Ern while I can, I think pretty soon I might be the only developer in the company on a non-Mac PC.

This conversation has been reproduced without anyone's permission

- Wednesday, July 16, 2008

Replacing Notepad with Notepad 2 on XP SP3, the easiest way possible

After installing SP3 on XP I noticed that Notepad was reverted back to its crappy self, so I decided to write a handy batch script to install Notepad2 again. This script will work in XP SP2+. Place the batch file in the same directory as notepad2.exe and run it.


@echo off
echo This will kill all open instances of Notepad.
echo To cancel, end this batch file now (ctrl+c), or hit any key to continue.
echo Killing all instances of notepad running...
TASKKILL /F /IM notepad.exe /T
echo Backing up...
call :backup %systemroot%\servicepackfiles\i386
call :backup %systemroot%
call :backup %systemroot%\System32
call :backup %systemroot%\System32\dllcache
echo Installing...
copy notepad2.exe %systemroot%\servicepackfiles\i386\notepad.exe /y
copy notepad2.exe %systemroot%\notepad.exe /y
copy notepad2.exe %systemroot%\System32\notepad.exe /y
copy notepad2.exe %systemroot%\System32\dllcache\notepad.exe /y
echo Done.
goto :end
call set npath=%1
set count=0
for %%i in (%npath%\notepad.original*.exe) do (
set nname=%%i
set /a count=count+1
echo backing up to %npath%\notepad.original%count%.exe
copy %npath%\notepad.exe %npath%\notepad.original%count%.exe /y

So That's What Happened To Doogie Howser, M.D.

It's actually kinda funny.

(if you were looking for more Doogie, Hulu will save the day)