Friday, June 8, 2012

R is fantastic (esp with ggplot2)

I keep being amazed at the R language, especially when using the free RStudio IDE.  I've mainly focused on using various analytical packages (like randomForest), but wow ggplot2 is awesome in it's simplicity for doing visualisations.  The following isn't the best data for an example, but you get the idea:


scores = rbind(0.25199,0.26516,0.29329,0.30794,0.30630,0.33529,0.33910,0.34185,0.33703,0.34423,0.34877,0.32457,0.33826,0.33670,0.34237,0.33503,0.33186,0.33125,0.32908,0.34548,0.34357,0.34371,0.35440,0.35082,0.34633,0.35529)
var = rbind(7.62,5.32,9.60,11.38,13.31,14.38,13.60,15.60,12.18,11.98,10.88,25.00,13.59,13.67,14.17,25.27,26.73,25.90,22.97,38.98,21.21,23.86,21.48,23.07,24.38,22.46)


summary(scores)
summary(var)


library(ggplot2)
qplot(scores,var) + geom_smooth()


Monday, May 21, 2012

Using WinMerge as merge/diff tool in TFS


Original source: http://jonfuller.codingtomusic.com/2008/08/26/tfs-using-winmerge-as-your-mergediff-tool/
Thanks Jon!

In VS, go To: Tools/Options/SourceControl/Visual Studio Team Foundation Server/Configure User Tools

Click "Add..."
Extension:  .*
Operation: Compare
Command: C:\Program Files\WinMerge\WinMergeU.exe
Arguments: /e /wl /dl %6 /dr %7 %1 %2
Click "Add..."

Extension:  .*
Operation: Merge
Command: C:\Program Files\WinMerge\WinMergeU.exe
Arguments: /ub /dl %6 /dr %7 %1 %2 %4

The winmerge command line reference can be found here.

Thursday, May 17, 2012

Javascript console.log() and IE

Arg how I loath IE, why doesn't it support console.log(obj)?

To prevent IE from throwing an exception when it encounters console.log, add the following to a site-wide js file:

if (!window.console) console = { log: function () { } };


This makes cross browser testing much easier while in development.

Wednesday, May 16, 2012

Configure Elmah on IIS7.x vs IIS6

Elmah in IIS 7.x:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" /> <!-- false if you also have httpModules in config -->
    <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>
    <handlers>
      <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
    </handlers>
</system.webServer>


Elmah in IIS 6, if you must:

<elmah>
    <!-- See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for more information on remote access and securing ELMAH. -->
    <security allowRemoteAccess="false" />
</elmah>


<system.web>
   <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
    <httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
    </httpHandlers>
</system.web>

Thanks Elmah - you're awesome!

Sunday, April 29, 2012

Contained Javascript Library template

This Javascript template enables a library to be written in its own namespace and handle being included multiple times on a page.
It's based on Douglas Crockford's json2.js library.


var MyLibrary;
if (!MyLibrary) {
    MyLibrary = {};
}


(function () {
    //'use strict';
    if (typeof MyLibrary.myFunction !== 'function') {
        MyLibrary.myFunction = function (arg1, arg2) {
          //...method body here...
          return true;
        };
    }
}());

Thursday, April 26, 2012

Enable IE F12 Dev Tools

New contract, new machine.....and the Internet Explorer F12 debug tools don't work for me.

This fixed it:

Run gpedit.msc
In the left pane, click on to expand Computer Configuration, Administrative Templates, Windows Components, Internet Explorer, and Toolbars.
In the right pane, double click on Turn off Developer Tools
Select Disabled

Arg, how I hate IE.

Wednesday, April 25, 2012

Help Internet Explorer suck less by removing compat mode

The compatibility mode in IE has it's uses, but can cause nightmares when clients are testing.

To remove it as an option add the following as teh first line after the <head> tag in your mark up:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

More info:
http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx
http://stackoverflow.com/questions/3960120/turn-off-ie-8-compatibility-mode-for-site